Add campfire extinguish logic
This commit is contained in:
@@ -33,8 +33,7 @@ void AAgrarianCampfire::Tick(float DeltaSeconds)
|
||||
FuelSeconds = FMath::Max(0.0f, FuelSeconds - DeltaSeconds);
|
||||
if (FuelSeconds <= 0.0f)
|
||||
{
|
||||
bLit = false;
|
||||
UpdateVisualState();
|
||||
SetLit(false);
|
||||
}
|
||||
|
||||
WarmNearbyCharacters(DeltaSeconds);
|
||||
@@ -69,8 +68,6 @@ void AAgrarianCampfire::Interact_Implementation(AAgrarianGameCharacter* Interact
|
||||
if (Inventory && Inventory->RemoveItem(TEXT("wood"), 1))
|
||||
{
|
||||
AddFuel(90.0f);
|
||||
bLit = true;
|
||||
UpdateVisualState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,9 +78,21 @@ void AAgrarianCampfire::AddFuel(float Seconds)
|
||||
FuelSeconds += FMath::Max(0.0f, Seconds);
|
||||
if (FuelSeconds > 0.0f)
|
||||
{
|
||||
bLit = true;
|
||||
SetLit(true);
|
||||
}
|
||||
UpdateVisualState();
|
||||
else
|
||||
{
|
||||
UpdateVisualState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::Extinguish()
|
||||
{
|
||||
if (HasAuthority())
|
||||
{
|
||||
FuelSeconds = 0.0f;
|
||||
SetLit(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +101,16 @@ void AAgrarianCampfire::OnRep_FireState()
|
||||
UpdateVisualState();
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::SetLit(bool bNewLit)
|
||||
{
|
||||
if (bLit != bNewLit)
|
||||
{
|
||||
bLit = bNewLit;
|
||||
}
|
||||
|
||||
UpdateVisualState();
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::UpdateVisualState()
|
||||
{
|
||||
if (FireLight)
|
||||
|
||||
@@ -46,10 +46,14 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire")
|
||||
void AddFuel(float Seconds);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Agrarian|Fire")
|
||||
void Extinguish();
|
||||
|
||||
protected:
|
||||
UFUNCTION()
|
||||
void OnRep_FireState();
|
||||
|
||||
void SetLit(bool bNewLit);
|
||||
void UpdateVisualState();
|
||||
void WarmNearbyCharacters(float DeltaSeconds);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user