Add campfire cooking placeholder

This commit is contained in:
2026-05-17 18:50:59 -07:00
parent c61b226f47
commit 0ac4bec3cf
7 changed files with 135 additions and 3 deletions
+17 -1
View File
@@ -207,6 +207,22 @@ def make_stack(data):
return stack
def set_default_property(cdo, property_name, value):
property_names = [property_name]
if isinstance(value, bool):
property_names.append(f"b_{property_name}")
property_names.append("b" + "".join(part.capitalize() for part in property_name.split("_")))
for reflected_name in property_names:
try:
cdo.set_editor_property(reflected_name, value)
return
except Exception:
continue
raise RuntimeError(f"Could not set default property {property_name}")
def apply_defaults(blueprint, config):
blueprint_path = f"{config['folder']}/{config['asset']}"
unreal.BlueprintEditorLibrary.compile_blueprint(blueprint)
@@ -222,7 +238,7 @@ def apply_defaults(blueprint, config):
elif property_name == "harvest_yields":
value = [make_stack(stack_data) for stack_data in value]
cdo.set_editor_property(property_name, value)
set_default_property(cdo, property_name, value)
mesh_path = config.get("mesh")
if mesh_path:
@@ -0,0 +1,56 @@
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
REQUIRED = {
ROOT / "Source" / "AgrarianGame" / "AgrarianCampfire.h": [
"bool bCookingPlaceholderEnabled = true;",
"float CookingSecondsRequired = 30.0f;",
"float CookingProgressSeconds = 0.0f;",
"bool CanCook() const;",
"float GetCookingProgressRatio() const;",
],
ROOT / "Source" / "AgrarianGame" / "AgrarianCampfire.cpp": [
"DOREPLIFETIME(AAgrarianCampfire, bCookingPlaceholderEnabled);",
"DOREPLIFETIME(AAgrarianCampfire, CookingSecondsRequired);",
"DOREPLIFETIME(AAgrarianCampfire, CookingProgressSeconds);",
"CookingProgressSeconds = FMath::Min(CookingSecondsRequired, CookingProgressSeconds + DeltaSeconds);",
"bool AAgrarianCampfire::CanCook() const",
"float AAgrarianCampfire::GetCookingProgressRatio() const",
],
ROOT / "Scripts" / "setup_playable_blueprints.py": [
"def set_default_property(cdo, property_name, value):",
"property_names.append(f\"b_{property_name}\")",
"property_names.append(\"b\" + \"\".join(part.capitalize() for part in property_name.split(\"_\")))",
],
ROOT / "Scripts" / "verify_playable_blueprints.py": [
"def get_property(cdo, property_name, expected_value):",
"property_names.append(f\"b_{property_name}\")",
"property_names.append(\"b\" + \"\".join(part.capitalize() for part in property_name.split(\"_\")))",
],
ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md": [
"- [x] Add cooking placeholder if needed.",
],
ROOT / "Docs" / "TechnicalDesignDocument.md": [
"minimal replicated cooking placeholder",
],
}
def main():
missing = []
for path, snippets in REQUIRED.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 SystemExit("Campfire cooking placeholder verification failed:\n" + "\n".join(missing))
print("PASS: campfire cooking placeholder is implemented and documented.")
if __name__ == "__main__":
main()
+16 -1
View File
@@ -94,6 +94,21 @@ def nearly_equal(left, right):
return left == right
def get_property(cdo, property_name, expected_value):
property_names = [property_name]
if isinstance(expected_value, bool):
property_names.append(f"b_{property_name}")
property_names.append("b" + "".join(part.capitalize() for part in property_name.split("_")))
for reflected_name in property_names:
try:
return cdo.get_editor_property(reflected_name)
except Exception:
continue
raise RuntimeError(f"Could not read property {property_name}")
def main():
failures = []
@@ -110,7 +125,7 @@ def main():
cdo = unreal.get_default_object(generated_class)
for property_name, expected_value in expected.get("properties", {}).items():
actual_value = cdo.get_editor_property(property_name)
actual_value = get_property(cdo, property_name, expected_value)
if str(actual_value) != expected_value and not nearly_equal(actual_value, expected_value):
failures.append(f"{path} {property_name} expected {expected_value}, got {actual_value}")