Add inventory persistence restore hook
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
FILES = {
|
||||
"AgrarianSaveGame.h": ROOT / "Source" / "AgrarianGame" / "AgrarianSaveGame.h",
|
||||
"AgrarianInventoryComponent.h": ROOT / "Source" / "AgrarianGame" / "AgrarianInventoryComponent.h",
|
||||
"AgrarianInventoryComponent.cpp": ROOT / "Source" / "AgrarianGame" / "AgrarianInventoryComponent.cpp",
|
||||
"AgrarianPersistenceSubsystem.cpp": ROOT / "Source" / "AgrarianGame" / "AgrarianPersistenceSubsystem.cpp",
|
||||
"InventoryDataModel.md": ROOT / "Docs" / "InventoryDataModel.md",
|
||||
"TechnicalDesignDocument.md": ROOT / "Docs" / "TechnicalDesignDocument.md",
|
||||
"AGRARIAN_DEVELOPMENT_ROADMAP.md": ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md",
|
||||
}
|
||||
|
||||
EXPECTED = {
|
||||
"AgrarianSaveGame.h": [
|
||||
"TArray<FAgrarianItemStack> Inventory",
|
||||
],
|
||||
"AgrarianInventoryComponent.h": [
|
||||
"RestoreSavedItems",
|
||||
"const TArray<FAgrarianItemStack>& SavedItems",
|
||||
],
|
||||
"AgrarianInventoryComponent.cpp": [
|
||||
"UAgrarianInventoryComponent::RestoreSavedItems",
|
||||
"Items = SavedItems",
|
||||
"BroadcastInventoryChanged()",
|
||||
],
|
||||
"AgrarianPersistenceSubsystem.cpp": [
|
||||
"SavedPlayer.Inventory = InventoryComponent->Items",
|
||||
"InventoryComponent->RestoreSavedItems(SavedPlayer->Inventory)",
|
||||
],
|
||||
"InventoryDataModel.md": [
|
||||
"`UAgrarianInventoryComponent::RestoreSavedItems`",
|
||||
"`OnInventoryChanged`",
|
||||
"Recompute derived values such as total weight",
|
||||
],
|
||||
"TechnicalDesignDocument.md": [
|
||||
"Inventory persistence saves",
|
||||
"`FAgrarianSavedPlayer::Inventory`",
|
||||
"`UAgrarianInventoryComponent::RestoreSavedItems`",
|
||||
"`OnInventoryChanged`",
|
||||
],
|
||||
"AGRARIAN_DEVELOPMENT_ROADMAP.md": [
|
||||
"[x] Add persistence for inventory.",
|
||||
"`FAgrarianSavedPlayer::Inventory`",
|
||||
"`RestoreSavedItems`",
|
||||
"listeners are notified after load",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
missing = []
|
||||
for label, path in FILES.items():
|
||||
text = path.read_text(encoding="utf-8")
|
||||
for snippet in EXPECTED[label]:
|
||||
if snippet not in text:
|
||||
missing.append(f"{label}: {snippet}")
|
||||
|
||||
if missing:
|
||||
raise RuntimeError("Inventory persistence verification failed: " + "; ".join(missing))
|
||||
|
||||
print("Agrarian inventory persistence verification complete.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user