using ProjectM.Simulation; using Unity.Entities; using Unity.NetCode; using UnityEngine; namespace ProjectM.Client { /// /// Client-side boon-pick sender: a static enqueue (the Step-14 3-card modal / execute_code) drained into /// RPCs. Carries only the option INDEX — the server resolves it against the /// sender's own authoritative BoonOffer and validates lifecycle/pending, so a stale or forged pick is /// simply dropped. Statics reset on play-enter (the stale-bridge hazard). /// [WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)] public partial class BoonSendSystem : SystemBase { static int s_Pending; static byte s_PendingIndex; [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] static void ResetStatics() { s_Pending = 0; s_PendingIndex = 0; } /// Queue a boon pick (0/1/2). The HUD card click + execute_code drive this. public static void PickBoon(byte optionIndex) { s_PendingIndex = optionIndex; s_Pending++; } protected override void OnCreate() { RequireForUpdate(); } protected override void OnUpdate() { while (s_Pending > 0) { s_Pending--; var req = EntityManager.CreateEntity(typeof(BoonPickRequest), typeof(SendRpcCommandRequest)); EntityManager.SetComponentData(req, new BoonPickRequest { Index = s_PendingIndex }); } } } }