Run body and fire phases during scripted control locks

This commit is contained in:
UnixNight committed 2026-10-26 12:21:25 -04:00
1 parent 5876da112c
commit c285b57091
35 files changed
+1503 -45

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
using System.Numerics;
namespace GamePort.Game;
/// <summary>Connect recovered raw-owner preparations and authored transforms to
/// the port's player body. Full scene scheduling/other actor classes stay separate.</summary>
public sealed class PlayerSceneBinding : IDisposable
{
private readonly SceneDirector director;
private readonly LabSimulation player;
private readonly SceneInventory inventory;
private readonly string tag;
public int UnsupportedGadgetCleanups { get; private set; }
public PlayerSceneBinding(SceneDirector director, LabSimulation player, SceneInventory inventory, string tag)
{
this.director = director; this.player = player; this.inventory = inventory; this.tag = tag;
director.ActorPreparing += Prepare;
director.AuthoredTransformChanged += Transform;
}
public bool Step(PlayerInput input)
{
var acceptsInput = director.Controlled || player.Noclip;
player.Step(input, acceptsInput);
var rotation = director.FindActor(tag)?.Rotation ?? Vector3.Zero;
director.SyncActor(tag, player.ActorRoot, rotation with { Y = player.Yaw });
return acceptsInput;
}
private void Prepare(DirectorActor actor, ScriptPreparation action)
{
if (!string.Equals(actor.Tag, tag, StringComparison.OrdinalIgnoreCase)) return;
if (action == ScriptPreparation.StopMotion) player.PrepareForScript();
else if (action == ScriptPreparation.ReleaseGadget)
{
//427FF0 has distinct cases. Only no-selection/jetpack cleanup is
//implemented; do not turn the other gadget cases into blanket resets.
if (inventory.SelectedGadget is -1 or 3)
{ inventory.SelectGadget(-1); player.GadgetMode = -1; }
else UnsupportedGadgetCleanups++;
}
}
private void Transform(DirectorActor actor)
{
if (string.Equals(actor.Tag, tag, StringComparison.OrdinalIgnoreCase))
player.ApplyAuthoredTransform(actor.Position, actor.Rotation.Y);
}
public void Dispose()
{
director.ActorPreparing -= Prepare;
director.AuthoredTransformChanged -= Transform;
}
}