Verify water gathering interaction
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
FILES = {
|
||||
"AgrarianWaterSource.h": ROOT / "Source" / "AgrarianGame" / "AgrarianWaterSource.h",
|
||||
"AgrarianWaterSource.cpp": ROOT / "Source" / "AgrarianGame" / "AgrarianWaterSource.cpp",
|
||||
"AgrarianGameCharacter.cpp": ROOT / "Source" / "AgrarianGame" / "AgrarianGameCharacter.cpp",
|
||||
"GroundZeroWaterSource.md": ROOT / "Docs" / "Terrain" / "GroundZeroWaterSource.md",
|
||||
"verify_ground_zero_water_source.py": ROOT / "Scripts" / "verify_ground_zero_water_source.py",
|
||||
}
|
||||
|
||||
REQUIRED_SNIPPETS = {
|
||||
"AgrarianWaterSource.h": [
|
||||
"class AGRARIANGAME_API AAgrarianWaterSource : public AActor, public IAgrarianInteractable",
|
||||
"float WaterRestoreAmount = 45.0f;",
|
||||
"virtual FText GetInteractionText_Implementation",
|
||||
"virtual bool CanInteract_Implementation",
|
||||
"virtual void Interact_Implementation",
|
||||
],
|
||||
"AgrarianWaterSource.cpp": [
|
||||
"bReplicates = true;",
|
||||
"Drink from {0}",
|
||||
"Interactor != nullptr && Interactor->GetSurvivalComponent() != nullptr",
|
||||
"if (!HasAuthority() || !Interactor)",
|
||||
"SurvivalComponent->AddWater(WaterRestoreAmount);",
|
||||
],
|
||||
"AgrarianGameCharacter.cpp": [
|
||||
"FindFocusedInteractable",
|
||||
"IAgrarianInteractable::Execute_CanInteract",
|
||||
"IAgrarianInteractable::Execute_GetInteractionText",
|
||||
"ServerInteract(HitActor);",
|
||||
"FVector::DistSquared(TargetActor->GetActorLocation(), GetActorLocation())",
|
||||
"IAgrarianInteractable::Execute_Interact(TargetActor, this);",
|
||||
],
|
||||
"GroundZeroWaterSource.md": [
|
||||
"The water source is an interactable actor.",
|
||||
"it restores thirst through `UAgrarianSurvivalComponent::AddWater`",
|
||||
"Interaction text: `Drink from Fresh Water Spring`",
|
||||
],
|
||||
"verify_ground_zero_water_source.py": [
|
||||
"WATER_SOURCE_LABEL = \"AGR_GZ_FreshWaterSource_01\"",
|
||||
"EXPECTED_WATER_RESTORE = 45.0",
|
||||
"is not an AgrarianWaterSource",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
missing = []
|
||||
for label, path in FILES.items():
|
||||
text = path.read_text(encoding="utf-8")
|
||||
for snippet in REQUIRED_SNIPPETS[label]:
|
||||
if snippet not in text:
|
||||
missing.append(f"{label}: missing {snippet!r}")
|
||||
|
||||
if missing:
|
||||
raise SystemExit("Water gathering interaction verification failed:\n" + "\n".join(missing))
|
||||
|
||||
print(
|
||||
"PASS: water gathering interaction uses the shared focused interact path, "
|
||||
"server-authoritative water restoration, Ground Zero placement verification, "
|
||||
"and player-facing documentation."
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user