Implement timed Invisible gadget and shared energy warnings
This commit is contained in:
1 parent
3527d33810
commit
1897dd2b90
44 files changed
+2466
-39
No files matched your search
@@ -19,6 +19,7 @@ public sealed class LabSimulation
|
||||
private readonly Func<Vector3, Vector3, SupportHit?>? cameraRay;
|
||||
private readonly Func<Vector3, Vector3, SupportHit?>? ceilingRay;
|
||||
private readonly OriginalBodyPhysics? originalBody;
|
||||
private readonly PlayerEnergy energy;
|
||||
private readonly Vector3 sourceStart;
|
||||
private readonly float startYaw, modelMinimumY, rootHeight, startFloor;
|
||||
private float targetYaw, extraAirAcceleration, shadowDistance, lateralContribution;
|
||||
@@ -28,13 +29,28 @@ public sealed class LabSimulation
|
||||
private bool forceFall;
|
||||
private Vector3 noclipEntry;
|
||||
private float noclipEntryYaw;
|
||||
private int gadgetMode = -1;
|
||||
public bool Noclip { get; private set; }
|
||||
public bool HasNoclipEntry { get; private set; }
|
||||
public float NoclipSpeed { get; set; } = 600;
|
||||
public Func<int>? JetpackInventoryState { get; set; }
|
||||
public string LevelCode { get; set; } = "LV1B";
|
||||
public int GadgetMode { get; set; } = -1;
|
||||
public float Energy { get; set; } = 20;
|
||||
public InvisibleGadget Invisible { get; } = new();
|
||||
public int GadgetMode
|
||||
{
|
||||
get => gadgetMode;
|
||||
set
|
||||
{
|
||||
if (gadgetMode == 2) Invisible.Release();
|
||||
gadgetMode = -1;
|
||||
if (value == 2 && !Invisible.Equip(Energy, IgnoresGadgetEnergy)) return;
|
||||
gadgetMode = value;
|
||||
}
|
||||
}
|
||||
public bool IgnoresGadgetEnergy => PlayerEnergy.IsTutorial(LevelCode);
|
||||
public float Energy { get => energy.Value; set => energy.Value = value; }
|
||||
public bool LowEnergyWarning => energy.LowWarning;
|
||||
public event Action<int>? EnergySound;
|
||||
//Source260/live15C serves both body collision and contact tests. The name
|
||||
//predates source-body integration; burst100 is not an interaction-only size.
|
||||
public float InteractionRadius { get; private set; } = 60;
|
||||
@@ -84,12 +100,13 @@ public sealed class LabSimulation
|
||||
public LabSimulation(SceneCollision collision, Mesh standingPose, Vector3 start, float yaw,
|
||||
Func<Vector3, Vector3, SupportHit?>? cameraRay = null,
|
||||
Func<Vector3, Vector3, SupportHit?>? ceilingRay = null,
|
||||
OriginalStaticCollision? originalCollision = null)
|
||||
OriginalStaticCollision? originalCollision = null, PlayerEnergy? energy = null)
|
||||
{
|
||||
this.collision = collision;
|
||||
this.cameraRay = cameraRay;
|
||||
this.ceilingRay = ceilingRay;
|
||||
originalBody = originalCollision == null ? null : new OriginalBodyPhysics(originalCollision);
|
||||
this.energy = energy ?? new PlayerEnergy();
|
||||
sourceStart = start;
|
||||
startYaw = yaw;
|
||||
var bounds = standingPose.Bounds();
|
||||
@@ -107,6 +124,8 @@ public sealed class LabSimulation
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (gadgetMode == 2) gadgetMode = -1;
|
||||
Invisible.Reset();
|
||||
var floor = collision.GroundHeight(sourceStart, 2500)!.Value;
|
||||
Position = new(sourceStart.X, floor + (UsesOriginalBody ? 0 : SceneCollision.Skin), sourceStart.Z);
|
||||
Velocity = Vector3.Zero;
|
||||
@@ -162,7 +181,7 @@ public sealed class LabSimulation
|
||||
return ((float)Math.Sin(radians), (float)Math.Cos(radians));
|
||||
}
|
||||
|
||||
public void Step(PlayerInput input, bool controlled = true)
|
||||
public void Step(PlayerInput input, bool controlled = true, bool? anyControlled = null)
|
||||
{
|
||||
if (Noclip) { StepNoclip(input); return; }
|
||||
//47E554 global body integration precedes473740 registry callbacks.
|
||||
@@ -176,8 +195,11 @@ public sealed class LabSimulation
|
||||
//424BE0..424C34 runs this wrapper before437940's ownership gate.
|
||||
StepCeiling();
|
||||
if (controlled) StepPlayer(input);
|
||||
Invisible.Step(FixedStepClock.Step, anyControlled ?? controlled, input.Fire, input.Jump,
|
||||
Energy, IgnoresGadgetEnergy, AdjustEnergy);
|
||||
var effect = JetpackBurst.StepEffect(jumpState, Grounded, FixedStepClock.Step, Energy, LevelCode);
|
||||
jumpState = effect.State; Energy = effect.Energy; JetpackEffectVisible = effect.Visible;
|
||||
jumpState = effect.State; JetpackEffectVisible = effect.Visible;
|
||||
if (effect.Visible) AdjustEnergy(-FixedStepClock.Step * JetpackBurst.EnergyPerSecond);
|
||||
EffectSteps++;
|
||||
if (controlled && InputAfterPlayerUpdate) StepInput(input);
|
||||
Steps++;
|
||||
@@ -192,6 +214,7 @@ public sealed class LabSimulation
|
||||
|
||||
public void StopForPrimaryFire() => Speed = 0;
|
||||
public void SetShooting(bool shooting) => Shooting = shooting;
|
||||
public void AdjustEnergy(float delta) => energy.Adjust(delta, LevelCode, id => EnergySound?.Invoke(id));
|
||||
|
||||
private void StepCeiling()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user