Add fire suppression hooks
This commit is contained in:
@@ -439,6 +439,55 @@ void AAgrarianCampfire::ContainFire()
|
||||
MaintainFire(false, true);
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::ApplyFireSuppression(float SuppressionAmount, FName SuppressionSource)
|
||||
{
|
||||
if (!HasAuthority())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const float SafeSuppressionAmount = FMath::Max(0.0f, SuppressionAmount);
|
||||
if (SafeSuppressionAmount <= 0.0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FireSuppressionPressure = FMath::Clamp(FireSuppressionPressure + (SafeSuppressionAmount / 100.0f), 0.0f, 1.0f);
|
||||
ReduceFireRisks(SafeSuppressionAmount);
|
||||
ReduceActiveFireIntensity(SafeSuppressionAmount);
|
||||
|
||||
if (SuppressionSource == TEXT("rain") || SuppressionSource == TEXT("water"))
|
||||
{
|
||||
FuelSeconds = FMath::Max(0.0f, FuelSeconds - SafeSuppressionAmount);
|
||||
}
|
||||
|
||||
const float TotalActiveFire = GrassFireIntensity + ForestFireIntensity + StructureFireIntensity;
|
||||
if (FuelSeconds <= 0.0f && TotalActiveFire <= 1.0f)
|
||||
{
|
||||
Extinguish();
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::ApplyWaterSuppression()
|
||||
{
|
||||
ApplyFireSuppression(WaterSuppressionStrength, TEXT("water"));
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::ApplyDirtSandSuppression()
|
||||
{
|
||||
ApplyFireSuppression(DirtSandSuppressionStrength, TEXT("dirt_sand"));
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::ApplyFirebreakSuppression()
|
||||
{
|
||||
ApplyFireSuppression(FirebreakSuppressionStrength, TEXT("firebreak"));
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::ApplyToolSuppression()
|
||||
{
|
||||
ApplyFireSuppression(ToolSuppressionStrength, TEXT("tool"));
|
||||
}
|
||||
|
||||
float AAgrarianCampfire::GetFireRiskRatio() const
|
||||
{
|
||||
return FMath::Clamp(FireRiskScore / 100.0f, 0.0f, 1.0f);
|
||||
@@ -602,6 +651,11 @@ void AAgrarianCampfire::UpdateFireRisk(float DeltaSeconds)
|
||||
|
||||
LitDurationSeconds += DeltaSeconds;
|
||||
SecondsSinceMaintenance += DeltaSeconds;
|
||||
if (IsWetWeatherActive())
|
||||
{
|
||||
const float RainSuppression = GetCurrentWeather() == EAgrarianWeatherType::Storm ? 0.2f : 0.1f;
|
||||
FireSuppressionPressure = FMath::Clamp(FireSuppressionPressure + (RainSuppression * DeltaSeconds), 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
const float RiskGrowth = GetFireRiskGrowthPerSecond();
|
||||
FireRiskScore = FMath::Clamp(FireRiskScore + (RiskGrowth * DeltaSeconds), 0.0f, 100.0f);
|
||||
@@ -863,3 +917,15 @@ void AAgrarianCampfire::ReduceFireRisks(float Amount)
|
||||
ForestIgnitionRiskScore = FMath::Clamp(ForestIgnitionRiskScore - (SafeAmount * 0.5f), 0.0f, 100.0f);
|
||||
StructureIgnitionRiskScore = FMath::Clamp(StructureIgnitionRiskScore - (SafeAmount * 0.75f), 0.0f, 100.0f);
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::ReduceActiveFireIntensity(float Amount)
|
||||
{
|
||||
const float SafeAmount = FMath::Max(0.0f, Amount);
|
||||
GrassFireIntensity = FMath::Clamp(GrassFireIntensity - SafeAmount, 0.0f, 100.0f);
|
||||
ForestFireIntensity = FMath::Clamp(ForestFireIntensity - (SafeAmount * 0.75f), 0.0f, 100.0f);
|
||||
StructureFireIntensity = FMath::Clamp(StructureFireIntensity - (SafeAmount * 0.85f), 0.0f, 100.0f);
|
||||
const float TotalIntensity = GrassFireIntensity + ForestFireIntensity + StructureFireIntensity;
|
||||
ActiveFireSpreadRadius = TotalIntensity > 0.0f
|
||||
? FMath::Clamp(BaseFireSpreadRadius + (TotalIntensity * 12.0f), 0.0f, MaxFireSpreadRadius)
|
||||
: 0.0f;
|
||||
}
|
||||
|
||||
@@ -183,6 +183,18 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Fire|Spread", meta = (ClampMin = "0"))
|
||||
float FireSuppressionPressure = 0.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Fire|Suppression", meta = (ClampMin = "0"))
|
||||
float WaterSuppressionStrength = 35.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Fire|Suppression", meta = (ClampMin = "0"))
|
||||
float DirtSandSuppressionStrength = 24.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Fire|Suppression", meta = (ClampMin = "0"))
|
||||
float FirebreakSuppressionStrength = 30.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Fire|Suppression", meta = (ClampMin = "0"))
|
||||
float ToolSuppressionStrength = 18.0f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Fire|Weather", meta = (ClampMin = "1"))
|
||||
float RainFuelDrainMultiplier = 1.5f;
|
||||
|
||||
@@ -228,6 +240,21 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire|Risk")
|
||||
void ContainFire();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire|Suppression")
|
||||
void ApplyFireSuppression(float SuppressionAmount, FName SuppressionSource);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire|Suppression")
|
||||
void ApplyWaterSuppression();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire|Suppression")
|
||||
void ApplyDirtSandSuppression();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire|Suppression")
|
||||
void ApplyFirebreakSuppression();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire|Suppression")
|
||||
void ApplyToolSuppression();
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Agrarian|Fire|Risk")
|
||||
float GetFireRiskRatio() const;
|
||||
|
||||
@@ -265,4 +292,5 @@ protected:
|
||||
float GetFireSpreadWeatherMultiplier() const;
|
||||
float GetActiveBurningFuelScore() const;
|
||||
void ReduceFireRisks(float Amount);
|
||||
void ReduceActiveFireIntensity(float Amount);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user