// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" /** * Re-reads the place every NPC schedule sends its NPCs to. * * A schedule names its anchor by PersistentId and keeps a copy of where that anchor stood when it was * picked beside it, see FScheduledAction::AnchorTransform. That copy is what an NPC is sent at while * its anchor sits in a cell nobody has loaded, and it is written once, when the anchor is picked in * the details panel. The furniture it is a copy of can be moved afterwards without anybody picking * anything again, and then the two disagree: the schedule says the bed is where it used to be, and * the level says otherwise. * * This is the sweep that closes that gap. It stands every anchor the open level can answer for * against the copy its schedule holds, writes the ones that have moved, and saves the assets that * changed. It is an editor tool rather than something the game runs, because the drift is a fault in * the authored data and not in what a running game does with it: nothing reads the copy while it can * see the anchor itself, so a game never notices, and the schedule only starts lying when an NPC * meets a level that has the anchor streamed out. * * The one thing it cannot answer is an anchor that is not in the open level, which is either * furniture in a cell that is not loaded or a schedule naming something that is gone. Nothing here * can tell those two apart, so both are counted and reported rather than guessed at, and the copies * they belong to are left exactly as they were. */ namespace ScheduleAssetRecheck { /** What one sweep found, so that a caller can say it out loud rather than only log it. */ struct FResult { /** Assets the registry handed over, whether or not anything in them had moved. */ int32 NumAssetsScanned = 0; /** Assets that no longer agreed with the level, and so were written and saved. */ int32 NumAssetsUpdated = 0; /** Actions carrying an anchor, which is every action there is a place to check for. An action * with no anchor happens wherever the NPC already is and has nothing to go stale. */ int32 NumAnchorsChecked = 0; /** Copies that had moved, or that had never been recorded at all. */ int32 NumAnchorsUpdated = 0; /** Anchors no actor in the open level claims, whose copies were left as they were. */ int32 NumAnchorsUnresolved = 0; }; /** Walks every NpcScheduleAsset in the project, refreshes the anchor copy of every action whose * anchor is standing in the open level, and saves the assets that changed. * * The editor world is the only one read, so what this answers for is exactly what the level in * front of the author can see, and a schedule whose anchors live in some other level is left * alone by the same rule that leaves an unloaded cell alone. What it did is reported through a * notification and the log, and returned here as well, for a caller that wants the numbers. */ FResult RecheckAllScheduleAssets(); }