Recover retained route state and complete PostLoad availability tails
This commit is contained in:
1 parent
1dddfefc68
commit
9ad5a8ef6b
36 files changed
+1559
-32
No files matched your search
@@ -117,6 +117,24 @@ public sealed class LabSimulation
|
||||
CameraEye = DesiredEye().Eye;
|
||||
}
|
||||
|
||||
public PlayerLevelState? CaptureLevelState(int selectedGadget) => Noclip ? null
|
||||
: new(LevelCode, selectedGadget, movementMode, jumpState.HoldSeconds, jumpState.EffectRemaining);
|
||||
|
||||
/// <summary>Apply after destination construction. Init re-applies authored
|
||||
/// body vectors and clears speed/turn; PostLoad resets jump, not these scalars.
|
||||
/// Grounding and the next controller/fire tick may change them independently.</summary>
|
||||
public bool ApplyRetainedLevelState(PlayerLevelState state)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(state);
|
||||
if (!state.SupportsDestination(LevelCode)) return false;
|
||||
if (state.MovementMode is < 0 or > 1 || !float.IsFinite(state.HoldSeconds)
|
||||
|| state.HoldSeconds < 0 || !float.IsFinite(state.EffectRemaining))
|
||||
throw new ArgumentOutOfRangeException(nameof(state));
|
||||
movementMode = state.MovementMode;
|
||||
jumpState = new(0, state.HoldSeconds, state.EffectRemaining);
|
||||
return true;
|
||||
}
|
||||
|
||||
// EXE 0x47F940 truncates, then degree lookup masks to the 16384-entry table.
|
||||
// Table generated with modern trig; x87 bit-identical table recovery is pending.
|
||||
public static (float Sin, float Cos) Trig(float degrees)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace GamePort.Game;
|
||||
|
||||
/// <summary>
|
||||
/// Retained scalars proven through route GAM read, Init and PostLoad callbacks.
|
||||
/// This is in-memory ordinary-load state, never part of the original TSK format.
|
||||
/// Other gadget cleanup branches/levels need their own lifecycle proof.
|
||||
/// </summary>
|
||||
public sealed record PlayerLevelState(string SourceLevel, int SelectedGadget,
|
||||
int MovementMode, float HoldSeconds, float EffectRemaining)
|
||||
{
|
||||
public bool SupportsDestination(string level) => IsRoute(SourceLevel) && IsRoute(level)
|
||||
&& SelectedGadget is -1 or 3;
|
||||
|
||||
private static bool IsRoute(string level) => level is "LV1B" or "VR04" or "LEV1";
|
||||
}
|
||||
@@ -25,9 +25,10 @@ public sealed class SceneInventory
|
||||
public void SetState(int group, int item, int state) => states[Offset(group, item)] = state;
|
||||
|
||||
/// <summary>
|
||||
/// Jimmy PostLoad423DEF..423EC1: enable these eight owned gadgets, then
|
||||
/// disable them in numeric VR01..VR08. State4 is unavailable ownership,
|
||||
/// distinct from unowned0. Other wire values and item8 remain unchanged.
|
||||
/// Jimmy PostLoad: enable eight owned gadgets, disable them in VR01..08,
|
||||
/// then re-enable that tutorial's gadget in the later level-specific tail.
|
||||
/// LV1B disables gadgets1/7. Other level-specific tails remain unported.
|
||||
/// State4 is unavailable ownership, distinct from unowned0.
|
||||
/// </summary>
|
||||
public void ApplyLevelAvailability(string levelCode)
|
||||
{
|
||||
@@ -38,8 +39,19 @@ public sealed class SceneInventory
|
||||
// Exactly the eight original FourCC values in the source numeric range.
|
||||
if (levelCode.Length == 4 && levelCode.StartsWith("VR0", StringComparison.Ordinal)
|
||||
&& levelCode[3] is >= '1' and <= '8')
|
||||
{
|
||||
foreach (var item in items)
|
||||
if (states[item] == 1) states[item] = 4;
|
||||
//4242AF..424400: each practice scene enables its matching gadget.
|
||||
var practiceItem = levelCode[3] - '1';
|
||||
if (states[practiceItem] == 4) states[practiceItem] = 1;
|
||||
}
|
||||
else if (levelCode == "LV1B")
|
||||
{
|
||||
//424102: lab restrictions follow the common enable pass.
|
||||
foreach (var item in new[] { 1, 7 })
|
||||
if (states[item] == 1) states[item] = 4;
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectGadget(int item)
|
||||
|
||||
Reference in new issue
Block a user