Add wildlife navigation support
This commit is contained in:
@@ -3,7 +3,7 @@ import unreal
|
||||
|
||||
MAP_PATH = "/Game/Agrarian/Maps/L_GroundZeroTerrain_Test"
|
||||
CHARACTER_CLASS_PATH = "/Game/Agrarian/Blueprints/Characters/BP_AgrarianPlayerCharacter"
|
||||
RABBIT_LABEL = "AGR_RabbitWildlife_01"
|
||||
RABBIT_LABELS = ["AGR_DemoRabbitWildlife_01", "AGR_RabbitWildlife_01"]
|
||||
|
||||
|
||||
def get_actor_label(actor):
|
||||
@@ -27,6 +27,14 @@ def find_actor_by_label(label):
|
||||
return None
|
||||
|
||||
|
||||
def find_actor_by_any_label(labels):
|
||||
for label in labels:
|
||||
actor = find_actor_by_label(label)
|
||||
if actor:
|
||||
return actor
|
||||
return None
|
||||
|
||||
|
||||
def enum_name(value):
|
||||
return str(value).split(".")[-1].lower()
|
||||
|
||||
@@ -45,9 +53,9 @@ def main():
|
||||
raise RuntimeError(f"Could not load map: {MAP_PATH}")
|
||||
|
||||
character_class = load_blueprint_class(CHARACTER_CLASS_PATH)
|
||||
rabbit = find_actor_by_label(RABBIT_LABEL)
|
||||
rabbit = find_actor_by_any_label(RABBIT_LABELS)
|
||||
if not rabbit:
|
||||
raise RuntimeError(f"Could not find placed rabbit wildlife: {RABBIT_LABEL}")
|
||||
raise RuntimeError(f"Could not find placed rabbit wildlife by labels: {RABBIT_LABELS}")
|
||||
|
||||
character = unreal.AgrarianEditorAutomationLibrary.spawn_actor_in_editor_world(
|
||||
character_class,
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Validate native wildlife navigation support wiring."""
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def read_text(relative_path: str) -> str:
|
||||
path = REPO_ROOT / relative_path
|
||||
if not path.exists():
|
||||
raise AssertionError(f"Missing required file: {relative_path}")
|
||||
return path.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def require(needle: str, haystack: str, context: str) -> None:
|
||||
if needle not in haystack:
|
||||
raise AssertionError(f"Missing {needle!r} in {context}")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
errors: list[str] = []
|
||||
|
||||
try:
|
||||
build_cs = read_text("Source/AgrarianGame/AgrarianGame.Build.cs")
|
||||
require('"AIModule"', build_cs, "AgrarianGame.Build.cs")
|
||||
require('"NavigationSystem"', build_cs, "AgrarianGame.Build.cs")
|
||||
except AssertionError as exc:
|
||||
errors.append(str(exc))
|
||||
|
||||
try:
|
||||
header = read_text("Source/AgrarianGame/AgrarianWildlifeBase.h")
|
||||
for marker in [
|
||||
"bUseNavigationMovement",
|
||||
"NavigationAcceptanceRadius",
|
||||
"NavigationRepathDistance",
|
||||
"NavigationProjectionExtent",
|
||||
"ChooseReachableWanderTarget",
|
||||
"ProjectPointToNavigation",
|
||||
"RequestNavigationMove",
|
||||
"DirectMoveTowardLocation",
|
||||
]:
|
||||
require(marker, header, "AgrarianWildlifeBase.h")
|
||||
except AssertionError as exc:
|
||||
errors.append(str(exc))
|
||||
|
||||
try:
|
||||
source = read_text("Source/AgrarianGame/AgrarianWildlifeBase.cpp")
|
||||
for marker in [
|
||||
'#include "AIController.h"',
|
||||
'#include "NavigationSystem.h"',
|
||||
"AutoPossessAI = EAutoPossessAI::PlacedInWorldOrSpawned",
|
||||
"AIControllerClass = AAIController::StaticClass()",
|
||||
"SpawnDefaultController()",
|
||||
"GetRandomReachablePointInRadius",
|
||||
"ProjectPointToNavigation",
|
||||
"MoveToLocation",
|
||||
"EPathFollowingRequestResult::Failed",
|
||||
"StopMovement()",
|
||||
"DirectMoveTowardLocation",
|
||||
]:
|
||||
require(marker, source, "AgrarianWildlifeBase.cpp")
|
||||
except AssertionError as exc:
|
||||
errors.append(str(exc))
|
||||
|
||||
try:
|
||||
roadmap = read_text("AGRARIAN_DEVELOPMENT_ROADMAP.md")
|
||||
require("[x] Add navigation support for wildlife.", roadmap, "AGRARIAN_DEVELOPMENT_ROADMAP.md")
|
||||
docs = read_text("Docs/TechnicalDesignDocument.md")
|
||||
require("Wildlife Navigation", docs, "Docs/TechnicalDesignDocument.md")
|
||||
require("falls back to direct movement input", docs, "Docs/TechnicalDesignDocument.md")
|
||||
except AssertionError as exc:
|
||||
errors.append(str(exc))
|
||||
|
||||
if errors:
|
||||
for error in errors:
|
||||
print(f"ERROR: {error}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
print("Wildlife navigation support is wired.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user