Planting interaction blocker implemented, ui showing planting mode
This commit is contained in:
@@ -153,13 +153,6 @@ void ASeedBedActor::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
Super::EndPlay(EndPlayReason);
|
||||
}
|
||||
|
||||
void ASeedBedActor::OnConstruction(const FTransform& Transform)
|
||||
{
|
||||
Super::OnConstruction(Transform);
|
||||
|
||||
RefreshAllSlotVisuals();
|
||||
}
|
||||
|
||||
void ASeedBedActor::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
@@ -213,7 +213,6 @@ public:
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
virtual void OnConstruction(const FTransform& Transform) override;
|
||||
|
||||
/** Creates (or rebuilds) the components of a single slot and adds it to the slot map */
|
||||
FSeedBedSeedSlot& CreateSlot(FIntVector2 SlotCoordinate, bool bRebuildIfExisting);
|
||||
|
||||
@@ -190,11 +190,6 @@ void AEleriPlayerController::SetupInputComponent()
|
||||
PlayerEnhancedInputComponent->BindAction(WaterSeedAction, ETriggerEvent::Started, this, &AEleriPlayerController::OnHarvestSeed);
|
||||
}
|
||||
|
||||
if (PlantSeedAction)
|
||||
{
|
||||
PlayerEnhancedInputComponent->BindAction(PlantSeedAction, ETriggerEvent::Started, this, &AEleriPlayerController::OnPlantSeedAction);
|
||||
}
|
||||
|
||||
if (UiBackAction)
|
||||
{
|
||||
PlayerEnhancedInputComponent->BindAction(UiBackAction, ETriggerEvent::Started, this, &AEleriPlayerController::OnControllerBackAction);
|
||||
@@ -1132,7 +1127,10 @@ void AEleriPlayerController::OnInteract(const FInputActionValue &Value)
|
||||
return;
|
||||
|
||||
if (PlayerCharacter->GetIsPlanting())
|
||||
{
|
||||
TryPlantSelectedSeed();
|
||||
return;
|
||||
}
|
||||
|
||||
// Ask the InteractionSystem plugin's subsystem for the closest valid interactable
|
||||
// and fire the interaction on it if we have one.
|
||||
@@ -1149,7 +1147,11 @@ void AEleriPlayerController::OnInteractExit(const FInputActionValue &Value)
|
||||
if (!IsValid(PlayerCharacter))
|
||||
return;
|
||||
|
||||
// if (PlayerCharacter->GetIsPlanting()) PlayerCharacter->PlantSeed();
|
||||
if (PlayerCharacter->GetIsPlanting())
|
||||
{
|
||||
ClearSeedToPlant();
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerCharacter->OnInteractExit.Broadcast();
|
||||
OnChangeInputContext.Broadcast(1);
|
||||
@@ -1200,22 +1202,6 @@ void AEleriPlayerController::SetPlantingMode(bool bActive)
|
||||
return;
|
||||
|
||||
PlayerCharacter->SetPlanting(bActive);
|
||||
|
||||
// Planting gets its own context so it can take a key over without touching the other contexts
|
||||
if (IsValid(PlantingContext))
|
||||
{
|
||||
if (UEnhancedInputLocalPlayerSubsystem *Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer()))
|
||||
{
|
||||
if (bActive)
|
||||
{
|
||||
Subsystem->AddMappingContext(PlantingContext, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
Subsystem->RemoveMappingContext(PlantingContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AEleriPlayerController::TryPlantSelectedSeed()
|
||||
@@ -1260,14 +1246,6 @@ void AEleriPlayerController::TryPlantSelectedSeed()
|
||||
}
|
||||
}
|
||||
|
||||
void AEleriPlayerController::OnPlantSeedAction(const FInputActionValue &Value)
|
||||
{
|
||||
if (!IsValid(PlayerCharacter))
|
||||
return;
|
||||
|
||||
TryPlantSelectedSeed();
|
||||
}
|
||||
|
||||
void AEleriPlayerController::StartMinigame(EMinigameType MinigameType, const TSoftObjectPtr<UBaseMinigameDataAsset> &DataAsset)
|
||||
{
|
||||
if (!IsValid(PlayerCharacter) ||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "Components/StatForgeComponent.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "ProjectEleri/Items/SeedBedActor.h"
|
||||
#include "Subsystem/InteractionSubsystem.h"
|
||||
|
||||
|
||||
#if WITH_EDITOR
|
||||
@@ -339,6 +340,10 @@ void AMyCharacter::SetPlanting(bool bActive)
|
||||
|
||||
if (bIsPlanting)
|
||||
{
|
||||
// Planting takes over the interact input, so keep the plugin's interaction UI out of the way.
|
||||
// The plugin knows nothing about planting - it just holds/releases a generic UI block.
|
||||
UInteractionSubsystem::AddInteractionUIBlock(this, this);
|
||||
|
||||
SeedBedActors.Empty();
|
||||
TArray<AActor*> OutActors;
|
||||
UGameplayStatics::GetAllActorsOfClass(this, ASeedBedActor::StaticClass(), OutActors);
|
||||
@@ -349,12 +354,16 @@ void AMyCharacter::SetPlanting(bool bActive)
|
||||
}
|
||||
else
|
||||
{
|
||||
UInteractionSubsystem::RemoveInteractionUIBlock(this, this);
|
||||
|
||||
if (LastClosestSeedBedActor)
|
||||
{
|
||||
LastClosestSeedBedActor->StopHighlightingSlot();
|
||||
LastClosestSeedBedActor = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerController->GetMainGameWidget()->SwitchKeybindsDisplay(bActive ? 6 : 1);
|
||||
}
|
||||
|
||||
void AMyCharacter::BeginWatering()
|
||||
|
||||
@@ -225,14 +225,6 @@ public:
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Action Input")
|
||||
UInputAction* WaterSeedAction;
|
||||
|
||||
/** Action used to plant the selected seed into the closest seed bed slot */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Action Input")
|
||||
UInputAction* PlantSeedAction;
|
||||
|
||||
/** Mapping context pushed while planting, it may only contain actions that planting needs */
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Action Input")
|
||||
UInputMappingContext* PlantingContext;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Book Input")
|
||||
UInputAction* BookNextPageAction;
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Book Input")
|
||||
|
||||
Reference in New Issue
Block a user