Reconstruct lab story, interactions, patrol and jet pack practice flow
This commit is contained in:
1 parent
58424120bb
commit
c929f942e1
84 files changed
+7957
-305
No files matched your search
@@ -0,0 +1,43 @@
|
||||
using GamePort.Assets;
|
||||
|
||||
namespace GamePort.Game;
|
||||
|
||||
/// <summary>
|
||||
/// The two inventory-state groups serialized by the original TSK writer.
|
||||
/// Preserves unknown existing values; this is not a complete inventory UI or
|
||||
/// implementation of the separate 29-item consumable-count group.
|
||||
/// </summary>
|
||||
public sealed class SceneInventory
|
||||
{
|
||||
private readonly int[] states;
|
||||
public int SelectedGadget { get; private set; } = -1;
|
||||
public event Action<int>? GadgetSelected;
|
||||
|
||||
public SceneInventory(IEnumerable<int> savedStates)
|
||||
{
|
||||
states = savedStates.ToArray();
|
||||
if (states.Length != OriginalSave.InventoryCount)
|
||||
throw new ArgumentException("Expected the original 19 inventory states", nameof(savedStates));
|
||||
}
|
||||
|
||||
public int State(int group, int item) => states[Offset(group, item)];
|
||||
|
||||
public void SetState(int group, int item, int state) => states[Offset(group, item)] = state;
|
||||
|
||||
public void SelectGadget(int item)
|
||||
{
|
||||
if (item != -1 && (item is < 0 or >= 9 || State(0, item) == 0))
|
||||
throw new ArgumentOutOfRangeException(nameof(item), "Gadget is outside the recovered group or unavailable");
|
||||
SelectedGadget = item;
|
||||
GadgetSelected?.Invoke(item);
|
||||
}
|
||||
|
||||
public int[] Snapshot() => states.ToArray();
|
||||
|
||||
private static int Offset(int group, int item) => group switch
|
||||
{
|
||||
0 when item is >= 0 and < 9 => item,
|
||||
1 when item is >= 0 and < 10 => 9 + item,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(item), "Only the two serialized inventory groups are recovered here"),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user