Document architecture checkpoint and restore original task callback order
This commit is contained in:
1 parent
69d0187a21
commit
531883aaac
45 files changed
+2935
-43
No files matched your search
@@ -528,8 +528,28 @@ public sealed class SceneDirector
|
||||
// animated actor's TaskName activation contract. Applying the latter
|
||||
// here disables the lab exit even when SCENE reaches60.
|
||||
if (source.Kind == "LOAD") return;
|
||||
// Carl413F30 captures SCENE before generic40E340, then executes his
|
||||
// derived policy in the same callback, before the next registry actor.
|
||||
var carlScene = source.Kind == "3CAR" ? tasks.Get("SCENE") : 0;
|
||||
var active = source.Kind == "3PIC" ? TaskActivation.Pickup(source, state) : TaskActivation.Animated(source, state);
|
||||
if (active.HasValue) { actor.Active = actor.Visible = active.Value; ActorChanged?.Invoke(actor); }
|
||||
if (active.HasValue) actor.Active = actor.Visible = active.Value;
|
||||
var carlOverride = source.Kind == "3CAR" && level.Code == "LV1B";
|
||||
if (carlOverride)
|
||||
{
|
||||
//414068..414118. Other levels' derived policies remain unported.
|
||||
if (carlScene is < 0 or > 60) actor.Active = actor.Visible = false;
|
||||
else
|
||||
{
|
||||
if (carlScene > 30 && FindActor("CARLESC3") is { } marker)
|
||||
{
|
||||
actor.AIstate = 6;
|
||||
actor.Position = marker.Position;
|
||||
}
|
||||
// At60 retain the generic activation result.
|
||||
if (carlScene < 60) actor.Active = actor.Visible = true;
|
||||
}
|
||||
}
|
||||
if (active.HasValue || carlOverride) ActorChanged?.Invoke(actor);
|
||||
}
|
||||
|
||||
private void Block(GamEntity source, string detail, string? next)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,6 +6,9 @@ namespace GamePort.Game;
|
||||
public sealed class TaskStates
|
||||
{
|
||||
private readonly List<SavedTask> tasks;
|
||||
/// <summary>45FB5B objective dispatch, before task records or actor callbacks change.</summary>
|
||||
public event Action<string, int>? Assigning;
|
||||
/// <summary>45FBD9 entity dispatch, after all matching task records change.</summary>
|
||||
public event Action<string, int>? Assigned;
|
||||
public TaskStates(IEnumerable<SavedTask> initial) => tasks = initial.ToList();
|
||||
private static bool Equal(string a, string b) => Fold(a) == Fold(b);
|
||||
@@ -16,6 +19,7 @@ public sealed class TaskStates
|
||||
public int Get(string? name) => name == null ? 0 : tasks.FirstOrDefault(t => Equal(t.Name, name))?.State ?? 0;
|
||||
public void SetExisting(string name, int value)
|
||||
{
|
||||
Assigning?.Invoke(name, value);
|
||||
for (var i = 0; i < tasks.Count; i++)
|
||||
if (Equal(tasks[i].Name, name)) tasks[i] = tasks[i] with { State = value };
|
||||
// Original broadcasts even repeated assignments and unknown task names.
|
||||
|
||||
@@ -320,7 +320,7 @@ internal static class Program
|
||||
var tasks = new TaskStates(save.Tasks);
|
||||
storyTasks = tasks;
|
||||
director = new SceneDirector(level!, tasks, resources.Duration);
|
||||
interactions = new SceneInteractions(director, tasks, save, level!.Code);
|
||||
interactions = new SceneInteractions(director, tasks, save);
|
||||
objectivePanel = new ObjectivePanel(interactions.CurrentObjective);
|
||||
interactions.ObjectiveChanged += objectivePanel.Select;
|
||||
simulation!.Energy = interactions.Energy;
|
||||
|
||||
Reference in new issue
Block a user