Document architecture checkpoint and restore original task callback order

This commit is contained in:
UnixNight committed 2026-10-25 12:56:17 -04:00
1 parent 69d0187a21
commit 531883aaac
45 files changed
+2935 -43

No files matched your search

+7 -25
View File
@@ -15,7 +15,6 @@ public sealed class SceneInteractions
private readonly SceneDirector director;
private readonly TaskStates tasks;
private readonly OriginalSave initial;
private readonly string levelCode;
private readonly int[] itemStates;
private readonly HashSet<int> contacts = [];
private readonly HashSet<string> unsupported = [];
@@ -34,15 +33,15 @@ public sealed class SceneInteractions
public event Action<DirectorActor, string>? ConversationStarted;
public event Action<int>? ObjectiveChanged;
public SceneInteractions(SceneDirector director, TaskStates tasks, OriginalSave save, string? levelCode = null)
public SceneInteractions(SceneDirector director, TaskStates tasks, OriginalSave save)
{
this.director = director; this.tasks = tasks; initial = save;
this.levelCode = levelCode ?? save.LevelCode;
Inventory = new SceneInventory(save.InventoryStates);
itemStates = save.ItemStates.ToArray(); Score = save.Score;
Energy = save.PlayerValue;
CurrentObjective = save.OtherCounter;
ReturnLevel = save.ReturnLevel; ReturnStart = save.ReturnStart;
tasks.Assigning += OnTaskAssigning;
tasks.Assigned += OnTaskAssigned;
Reset();
}
@@ -68,7 +67,6 @@ public sealed class SceneInteractions
{
contacts.Clear();
HideCollected();
ApplyCarlTask();
}
public void HideCollected()
@@ -191,36 +189,20 @@ public sealed class SceneInteractions
}
}
private void OnTaskAssigned(string name, int value)
private void OnTaskAssigning(string name, int value)
{
HideCollected();
if (Equal(name, "SCENE"))
{
//45F990 jump tables ->406F50: clear the transient objective flags,
//select this objective and set its flag1; TSK writes selector4F8194.
//45FB5B ->406F50 runs BEFORE records change at45FB7F and before
//entity slot424 callbacks at45FBD9. TSK writes selector4F8194.
var objective = ObjectiveForScene(value);
if (objective != 0) { CurrentObjective = objective; ObjectiveChanged?.Invoke(objective); }
ApplyCarlTask();
}
}
private void ApplyCarlTask()
private void OnTaskAssigned(string name, int value)
{
//Carl's override413F30 follows generic activation; LV1B branch414068.
//Other levels' custom visibility/position policies are not ported here.
if (levelCode != "LV1B") return;
var state = tasks.Get("SCENE");
foreach (var actor in director.Actors.Where(a => a.Kind == "3CAR" && Equal(a.SourceGam?.Text("TaskName"), "SCENE")))
{
if (state is < 0 or > 60) { actor.Visible = actor.Active = false; continue; }
if (state > 30 && director.FindActor("CARLESC3") is { } marker)
{
actor.AIstate = 6;
actor.Position = marker.Position;
}
//At60 the override leaves the generic activation result unchanged.
if (state < 60) actor.Active = actor.Visible = true;
}
HideCollected();
}
private static bool Equal(string? a, string? b) => a is not null && b is not null