Add campfire extinguish logic
This commit is contained in:
@@ -582,7 +582,9 @@ Target deliverable: A small group can join a server, spawn into one biome, gathe
|
||||
- [x] Create fire actor.
|
||||
- [x] Add fuel amount.
|
||||
- [x] Add ignition interaction.
|
||||
- [ ] Add extinguish logic.
|
||||
- [x] Add extinguish logic. Added native campfire extinguish support that
|
||||
clears fuel, turns off replicated lit state, and reuses the fire visual
|
||||
update path used by natural fuel depletion.
|
||||
- [x] Add warmth radius.
|
||||
- [x] Add light source.
|
||||
- [ ] Add cooking placeholder if needed.
|
||||
|
||||
@@ -288,6 +288,10 @@ controller is silent until loops are assigned; placeholder or final audio can be
|
||||
added by setting the exposed sound properties on the placed controller or a
|
||||
Blueprint child.
|
||||
|
||||
Campfires expose native extinguish logic through `AAgrarianCampfire::Extinguish`.
|
||||
Extinguishing clears remaining fuel, turns off replicated lit state, and reuses
|
||||
the same visual update path as natural fuel depletion.
|
||||
|
||||
The first real-weather adapter is `UAgrarianWeatherProviderSubsystem`. It uses
|
||||
Open-Meteo forecast requests keyed by tile center latitude/longitude, parses the
|
||||
current temperature, daily low/high, precipitation, wind, humidity, cloud cover,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
EXPECTED = {
|
||||
ROOT / "Source" / "AgrarianGame" / "AgrarianCampfire.h": [
|
||||
"void Extinguish();",
|
||||
"void SetLit(bool bNewLit);",
|
||||
],
|
||||
ROOT / "Source" / "AgrarianGame" / "AgrarianCampfire.cpp": [
|
||||
"void AAgrarianCampfire::Extinguish()",
|
||||
"FuelSeconds = 0.0f;",
|
||||
"SetLit(false);",
|
||||
"void AAgrarianCampfire::SetLit(bool bNewLit)",
|
||||
"UpdateVisualState();",
|
||||
],
|
||||
ROOT / "Docs" / "TechnicalDesignDocument.md": [
|
||||
"Campfires expose native extinguish logic",
|
||||
],
|
||||
ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
|
||||
"- [x] Add extinguish logic.",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
missing = []
|
||||
for path, snippets in EXPECTED.items():
|
||||
text = path.read_text(encoding="utf-8")
|
||||
for snippet in snippets:
|
||||
if snippet not in text:
|
||||
missing.append(f"{path.relative_to(ROOT)} missing {snippet!r}")
|
||||
|
||||
if missing:
|
||||
raise RuntimeError("Fire extinguish verification failed: " + "; ".join(missing))
|
||||
|
||||
print("PASS: campfire extinguish logic is implemented and documented.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -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,10 +78,22 @@ void AAgrarianCampfire::AddFuel(float Seconds)
|
||||
FuelSeconds += FMath::Max(0.0f, Seconds);
|
||||
if (FuelSeconds > 0.0f)
|
||||
{
|
||||
bLit = true;
|
||||
SetLit(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateVisualState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::Extinguish()
|
||||
{
|
||||
if (HasAuthority())
|
||||
{
|
||||
FuelSeconds = 0.0f;
|
||||
SetLit(false);
|
||||
}
|
||||
}
|
||||
|
||||
void AAgrarianCampfire::OnRep_FireState()
|
||||
@@ -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