Implement original gadget panel and playable shrink ray

This commit is contained in:
UnixNight committed 2026-10-27 12:18:45 -04:00
1 parent 0272f7bef7
commit 7b5230ceb8
57 files changed
+3545 -48

No files matched your search

+106
View File
@@ -0,0 +1,106 @@
using System.Numerics;
namespace GamePort.Game;
public readonly record struct ShrinkCandidate(string Tag, Vector3 Position, bool BodyEnabled = true,
bool ShrinkEnabled = true, bool Shrunk = false);
/// <summary>Ordinary owned-item3/mode-1 continuous426E40 scan, not a projectile.</summary>
public sealed class ShrinkRay
{
private float textureTime;
public int TexturePhase { get; private set; }
public bool Visible { get; private set; }
public Vector3 Position { get; private set; }
public float Yaw { get; private set; }
public void StepTexture(float seconds)
{
Seconds(seconds);
textureTime += seconds;
//Float accumulation compared with the source stored double0.1.
if ((double)textureTime <= .1) return;
TexturePhase = (TexturePhase + 1) % 3;
textureTime = 0;
}
public void Hide() => Visible = false;
public void Reset() { Visible = false; TexturePhase = 0; textureTime = 0; }
public IReadOnlyList<string> Fire(Vector3 root, float yaw, float seconds,
IEnumerable<ShrinkCandidate> candidates, Func<Vector3, Vector3, SupportHit?> wallQuery)
{
Seconds(seconds);
if (!float.IsFinite(yaw)) throw new ArgumentOutOfRangeException(nameof(yaw));
Visible = true; Position = root; Yaw = yaw;
List<string> hits = [];
foreach (var target in candidates)
{
if (!target.BodyEnabled || !target.ShrinkEnabled || target.Shrunk
|| target.Position.Y <= root.Y - 150 || target.Position.Y >= root.Y + 60) continue;
var difference = target.Position - root;
var distance = difference.Length();
if (distance >= 1500) continue;
var heading = OriginalHeading.Degrees(difference);
//No added angle-seam wrapping in the recovered comparison.
if (heading <= yaw - 5 || heading >= yaw + 5) continue;
var (sin, cos) = LabSimulation.Trig(yaw);
var start = root + Vector3.UnitY * 150;
var end = start + new Vector3(-sin * distance, 0, cos * distance);
if (wallQuery(start, end) != null) continue;
hits.Add(target.Tag);
}
return hits;
}
private static void Seconds(float seconds)
{
if (!float.IsFinite(seconds) || seconds < 0 || seconds >= 1)
throw new ArgumentOutOfRangeException(nameof(seconds));
}
}
/// <summary>Bounded original3SOL body settling and shrink state; combat/path AI remain open.</summary>
public sealed class ShrinkSoldier(DirectorActor actor)
{
public DirectorActor Actor { get; } = actor;
public Vector3 Velocity { get; private set; }
public bool Grounded { get; private set; }
public bool Shrunk { get; private set; }
public float Remaining { get; private set; }
public int AuthoredMode { get; } = actor.SourceGam?.Integer("AIState",2) ?? 2;
public int PreviousMode { get; private set; }
public int ShrinkRevision { get; private set; }
public float HitMarker { get; private set; }
public void MarkScoredHit() => HitMarker = 1;
public void Reset()
{
Velocity = Vector3.Zero; Grounded = Shrunk = false; Remaining = 0;
ShrinkRevision = 0; HitMarker = 0; Actor.Animation = "WALK";
}
public void StepBody(OriginalScenePhysics physics, float seconds)
{
var result = physics.Step(Actor.Position, Velocity, 90, 1, Grounded, seconds);
Actor.Position = result.Body.Position; Velocity = result.Body.Velocity; Grounded = result.Supported;
}
public void Shrink()
{
if (Shrunk) return;
PreviousMode = Actor.AIstate; Actor.AIstate = 5;
Actor.Animation = "SHRINK"; Remaining = 30; Shrunk = true; ShrinkRevision++;
}
public void StepTimer(float seconds)
{
if (!float.IsFinite(seconds) || seconds < 0 || seconds >= 1) throw new ArgumentOutOfRangeException(nameof(seconds));
if (!Shrunk || Remaining <= 0) return;
Remaining -= seconds;
//Source44AE85: exact zero does not expire and is skipped next tick.
if (Remaining >= 0) return;
Remaining = 0; Shrunk = false; HitMarker = 0;
PreviousMode = Actor.AIstate;
Actor.AIstate = AuthoredMode; Actor.Animation = "WALK"; Actor.Speed = 200;
}
}