Fix lab cutscene control, landing steering, clipping and objective timeout
This commit is contained in:
1 parent
976e677019
commit
ca08c468ba
33 files changed
+871
-64
No files matched your search
@@ -0,0 +1,86 @@
|
||||
namespace GamePort.Game;
|
||||
|
||||
/// <summary>
|
||||
/// Objective pad timing from EXE406F50/407070. Layout offset belongs to the
|
||||
/// separate gadget UI layout; O controls the animation timer, not that offset.
|
||||
/// Current rendering has one selected objective rather than the full44 flags.
|
||||
/// </summary>
|
||||
public sealed class ObjectivePanel
|
||||
{
|
||||
public const float SlideInSeconds = .7f; //48D974.
|
||||
public const float SlideScale = 1.4285714626312256f; //48D970, original float reciprocal.
|
||||
public const float SlideDistance = 100; //48D96C.
|
||||
public const float HoldUntilSeconds = 7; //Integer4EC498.
|
||||
public const float ExitDuration = 1.7f; //48D940.
|
||||
public const float HiddenInitialTime = 20; //4018A8/423EC6.
|
||||
public static float ExitEnd => HoldUntilSeconds + ExitDuration;
|
||||
|
||||
private bool objectiveKeyHeld;
|
||||
private bool openingSoundPlayed;
|
||||
private bool renderAllowed;
|
||||
public int CurrentObjective { get; private set; }
|
||||
public float Elapsed { get; private set; } = HiddenInitialTime;
|
||||
public float LayoutOffset { get; }
|
||||
public bool PadVisible => renderAllowed && CurrentObjective > 0 && Elapsed < ExitEnd;
|
||||
public bool ContentVisible => PadVisible && Elapsed >= SlideInSeconds && Elapsed < HoldUntilSeconds;
|
||||
public float SlideOffset => Elapsed < SlideInSeconds ? (1 - Elapsed * SlideScale) * SlideDistance
|
||||
: Elapsed < HoldUntilSeconds ? 0 : (Elapsed - HoldUntilSeconds) * SlideScale * SlideDistance;
|
||||
public float YOffset => LayoutOffset + (PadVisible ? SlideOffset : 0);
|
||||
public event Action<int>? SoundEffect;
|
||||
|
||||
/// <summary>Loaded selector starts hidden; source initializes its independent timer to20.</summary>
|
||||
public ObjectivePanel(int initialObjective = 0, float layoutOffset = -69)
|
||||
{
|
||||
if (initialObjective is < 0 or > 43) throw new ArgumentOutOfRangeException(nameof(initialObjective));
|
||||
if (!float.IsFinite(layoutOffset) || layoutOffset is < -480 or > 480)
|
||||
throw new ArgumentOutOfRangeException(nameof(layoutOffset));
|
||||
CurrentObjective = initialObjective;
|
||||
LayoutOffset = layoutOffset;
|
||||
}
|
||||
|
||||
/// <summary>Source406F50: positive assignments reset timing, even for the same selector.</summary>
|
||||
public void Select(int objective)
|
||||
{
|
||||
if (objective <= 0) return;
|
||||
if (objective > 43) throw new ArgumentOutOfRangeException(nameof(objective));
|
||||
CurrentObjective = objective;
|
||||
Show();
|
||||
}
|
||||
|
||||
/// <summary>Also used after source practice No404D97 resets the panel timer to0.</summary>
|
||||
public void Show() => Elapsed = 0;
|
||||
|
||||
/// <summary>407142..407198 edge latch. O hides an opening/stationary panel, otherwise opens it.</summary>
|
||||
public void Key(bool held)
|
||||
{
|
||||
if (held && !objectiveKeyHeld)
|
||||
Elapsed = Elapsed >= 0 && Elapsed < HoldUntilSeconds ? HoldUntilSeconds : 0;
|
||||
objectiveKeyHeld = held;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UI clock4043D9..4043F9 advances only with a non-null controlled entity.
|
||||
/// Modal4044D7..404504 forces exit time and hides pad/content. Pause/focus policy
|
||||
/// is explicit: caller supplies0 elapsed while its UI clock is paused.
|
||||
/// </summary>
|
||||
public void Step(float seconds, bool hasControlledActor = true, bool modalActive = false)
|
||||
{
|
||||
if (!float.IsFinite(seconds) || seconds < 0) throw new ArgumentOutOfRangeException(nameof(seconds));
|
||||
if (hasControlledActor)
|
||||
{
|
||||
var next = Elapsed + seconds;
|
||||
if (!float.IsFinite(next)) throw new ArgumentOutOfRangeException(nameof(seconds));
|
||||
Elapsed = next;
|
||||
}
|
||||
if (modalActive) Elapsed = ExitEnd;
|
||||
renderAllowed = hasControlledActor && !modalActive;
|
||||
if (!PadVisible) return;
|
||||
if (Elapsed < SlideInSeconds)
|
||||
{
|
||||
if (openingSoundPlayed) return;
|
||||
openingSoundPlayed = true;
|
||||
SoundEffect?.Invoke(216); //4070BA..4070CA.
|
||||
}
|
||||
else if (Elapsed < HoldUntilSeconds) openingSoundPlayed = false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user