Add campfire cooking placeholder
This commit is contained in:
@@ -36,6 +36,11 @@ void AAgrarianCampfire::Tick(float DeltaSeconds)
|
||||
SetLit(false);
|
||||
}
|
||||
|
||||
if (CanCook())
|
||||
{
|
||||
CookingProgressSeconds = FMath::Min(CookingSecondsRequired, CookingProgressSeconds + DeltaSeconds);
|
||||
}
|
||||
|
||||
WarmNearbyCharacters(DeltaSeconds);
|
||||
}
|
||||
}
|
||||
@@ -45,6 +50,9 @@ void AAgrarianCampfire::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& Ou
|
||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
DOREPLIFETIME(AAgrarianCampfire, bLit);
|
||||
DOREPLIFETIME(AAgrarianCampfire, FuelSeconds);
|
||||
DOREPLIFETIME(AAgrarianCampfire, bCookingPlaceholderEnabled);
|
||||
DOREPLIFETIME(AAgrarianCampfire, CookingSecondsRequired);
|
||||
DOREPLIFETIME(AAgrarianCampfire, CookingProgressSeconds);
|
||||
}
|
||||
|
||||
FText AAgrarianCampfire::GetInteractionText_Implementation(const AAgrarianGameCharacter* Interactor) const
|
||||
@@ -96,6 +104,21 @@ void AAgrarianCampfire::Extinguish()
|
||||
}
|
||||
}
|
||||
|
||||
bool AAgrarianCampfire::CanCook() const
|
||||
{
|
||||
return bLit && bCookingPlaceholderEnabled && CookingSecondsRequired > 0.0f;
|
||||
}
|
||||
|
||||
float AAgrarianCampfire::GetCookingProgressRatio() const
|
||||
{
|
||||
if (CookingSecondsRequired <= 0.0f)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
return FMath::Clamp(CookingProgressSeconds / CookingSecondsRequired, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::OnRep_FireState()
|
||||
{
|
||||
UpdateVisualState();
|
||||
|
||||
@@ -39,6 +39,15 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Fire", meta = (ClampMin = "0"))
|
||||
float WarmthPerSecond = 0.02f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "Agrarian|Fire|Cooking")
|
||||
bool bCookingPlaceholderEnabled = true;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "Agrarian|Fire|Cooking", meta = (ClampMin = "0"))
|
||||
float CookingSecondsRequired = 30.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "Agrarian|Fire|Cooking", meta = (ClampMin = "0"))
|
||||
float CookingProgressSeconds = 0.0f;
|
||||
|
||||
virtual FText GetInteractionText_Implementation(const AAgrarianGameCharacter* Interactor) const override;
|
||||
virtual bool CanInteract_Implementation(const AAgrarianGameCharacter* Interactor) const override;
|
||||
virtual void Interact_Implementation(AAgrarianGameCharacter* Interactor) override;
|
||||
@@ -49,6 +58,12 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire")
|
||||
void Extinguish();
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Agrarian|Fire|Cooking")
|
||||
bool CanCook() const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Agrarian|Fire|Cooking")
|
||||
float GetCookingProgressRatio() const;
|
||||
|
||||
protected:
|
||||
UFUNCTION()
|
||||
void OnRep_FireState();
|
||||
|
||||
Reference in New Issue
Block a user