Add campfire maintenance gameplay hooks
This commit is contained in:
@@ -178,7 +178,7 @@ void AAgrarianCampfire::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& Ou
|
||||
|
||||
FText AAgrarianCampfire::GetInteractionText_Implementation(const AAgrarianGameCharacter* Interactor) const
|
||||
{
|
||||
return bLit ? FText::FromString(TEXT("Add fuel")) : FText::FromString(TEXT("Light fire"));
|
||||
return bLit ? FText::FromString(TEXT("Maintain fire")) : FText::FromString(TEXT("Light fire"));
|
||||
}
|
||||
|
||||
bool AAgrarianCampfire::CanInteract_Implementation(const AAgrarianGameCharacter* Interactor) const
|
||||
@@ -198,6 +198,10 @@ void AAgrarianCampfire::Interact_Implementation(AAgrarianGameCharacter* Interact
|
||||
{
|
||||
AddFuel(90.0f);
|
||||
}
|
||||
else if (bLit)
|
||||
{
|
||||
WatchFire();
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::CapturePersistentState_Implementation(UAgrarianPersistentActorComponent* PersistentComponent) const
|
||||
@@ -407,8 +411,32 @@ void AAgrarianCampfire::MaintainFire(bool bClearArea, bool bContainFire)
|
||||
bFireContained = true;
|
||||
}
|
||||
|
||||
const float RiskReduction = (bFireAreaCleared ? 12.0f : 4.0f) + (bFireContained ? 12.0f : 4.0f);
|
||||
FireRiskScore = FMath::Clamp(FireRiskScore - RiskReduction, 0.0f, 100.0f);
|
||||
float RiskReduction = WatchedMaintenanceRiskReduction;
|
||||
if (bClearArea)
|
||||
{
|
||||
RiskReduction += ClearedAreaRiskReduction;
|
||||
}
|
||||
if (bContainFire)
|
||||
{
|
||||
RiskReduction += ContainedFireRiskReduction;
|
||||
}
|
||||
|
||||
ReduceFireRisks(RiskReduction);
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::WatchFire()
|
||||
{
|
||||
MaintainFire(false, false);
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::ClearAreaAroundFire()
|
||||
{
|
||||
MaintainFire(true, false);
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::ContainFire()
|
||||
{
|
||||
MaintainFire(false, true);
|
||||
}
|
||||
|
||||
float AAgrarianCampfire::GetFireRiskRatio() const
|
||||
@@ -826,3 +854,12 @@ float AAgrarianCampfire::GetActiveBurningFuelScore() const
|
||||
|
||||
return FMath::Max(0.0f, VegetationFuelScore + StructureFuelScore);
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::ReduceFireRisks(float Amount)
|
||||
{
|
||||
const float SafeAmount = FMath::Max(0.0f, Amount);
|
||||
FireRiskScore = FMath::Clamp(FireRiskScore - SafeAmount, 0.0f, 100.0f);
|
||||
GrassIgnitionRiskScore = FMath::Clamp(GrassIgnitionRiskScore - (SafeAmount * 0.75f), 0.0f, 100.0f);
|
||||
ForestIgnitionRiskScore = FMath::Clamp(ForestIgnitionRiskScore - (SafeAmount * 0.5f), 0.0f, 100.0f);
|
||||
StructureIgnitionRiskScore = FMath::Clamp(StructureIgnitionRiskScore - (SafeAmount * 0.75f), 0.0f, 100.0f);
|
||||
}
|
||||
|
||||
@@ -114,6 +114,15 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Fire|Risk", meta = (ClampMin = "0", ClampMax = "1"))
|
||||
float ContainedFireRiskMultiplier = 0.35f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Fire|Risk", meta = (ClampMin = "0"))
|
||||
float WatchedMaintenanceRiskReduction = 8.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Fire|Risk", meta = (ClampMin = "0"))
|
||||
float ClearedAreaRiskReduction = 24.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Fire|Risk", meta = (ClampMin = "0"))
|
||||
float ContainedFireRiskReduction = 28.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "Agrarian|Fire|Vegetation", meta = (ClampMin = "0", ClampMax = "100"))
|
||||
float GrassIgnitionRiskScore = 0.0f;
|
||||
|
||||
@@ -210,6 +219,15 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire|Risk")
|
||||
void MaintainFire(bool bClearArea, bool bContainFire);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire|Risk")
|
||||
void WatchFire();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire|Risk")
|
||||
void ClearAreaAroundFire();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire|Risk")
|
||||
void ContainFire();
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Agrarian|Fire|Risk")
|
||||
float GetFireRiskRatio() const;
|
||||
|
||||
@@ -246,4 +264,5 @@ protected:
|
||||
void UpdateServerAuthoritativeFireSpread(float DeltaSeconds);
|
||||
float GetFireSpreadWeatherMultiplier() const;
|
||||
float GetActiveBurningFuelScore() const;
|
||||
void ReduceFireRisks(float Amount);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user