using Unity.Collections; using Unity.Mathematics; using Unity.NetCode; namespace ProjectM.Simulation { /// /// Twin-stick player input (server-authoritative, input-only clients). Gathered once per frame /// on the owning client in and streamed to the server via /// AutoCommandTarget. Netcode source-gen produces InputBufferData plus the /// copy/apply systems from this type. The [GhostField]s let remote owners be predicted; the /// data replays deterministically under rollback. /// public struct PlayerInput : IInputComponentData { /// WASD / left-stick movement, normalized to roughly -1..1 per axis. [GhostField(Quantization = 1000)] public float2 Move; /// Right-stick / cursor aim direction (normalized). Zero => face movement direction. [GhostField(Quantization = 1000)] public float2 Aim; /// Primary ability fire. InputEvent survives the frame→tick→rollback boundary so a press fires exactly once. [GhostField] public InputEvent Fire; /// Dodge dash. InputEvent twin of : survives the frame-tick-rollback boundary /// so one press dashes exactly once; read by the predicted DashSystem (MC-1). [GhostField] public InputEvent Dash; /// Active input scheme this tick (: 0 = mouse/keyboard, 1 = gamepad). /// The server reads it so the auto-target assist applies only to gamepad shots; precise mouse aim is left /// exact. A byte (not an enum): it is compared inside the Burst-compiled AbilityFireSystem. [GhostField] public byte Scheme; public FixedString512Bytes ToFixedString() { var s = new FixedString512Bytes(); s.Append(Move.x); s.Append(','); s.Append(Move.y); s.Append(';'); s.Append(Aim.x); s.Append(','); s.Append(Aim.y); s.Append(';'); s.Append(Fire.Count); s.Append(';'); s.Append(Scheme); s.Append(';'); s.Append(Dash.Count); return s; } } }