50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using ProjectM.Simulation;
|
|
using Unity.Entities;
|
|
using Unity.NetCode;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectM.Client
|
|
{
|
|
/// <summary>
|
|
/// Client-side boon-pick sender: a static enqueue (the Step-14 3-card modal / execute_code) drained into
|
|
/// <see cref="BoonPickRequest"/> RPCs. Carries only the option INDEX — the server resolves it against the
|
|
/// sender's own authoritative <c>BoonOffer</c> and validates lifecycle/pending, so a stale or forged pick is
|
|
/// simply dropped. Statics reset on play-enter (the stale-bridge hazard).
|
|
/// </summary>
|
|
[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;
|
|
}
|
|
|
|
/// <summary>Queue a boon pick (0/1/2). The HUD card click + execute_code drive this.</summary>
|
|
public static void PickBoon(byte optionIndex)
|
|
{
|
|
s_PendingIndex = optionIndex;
|
|
s_Pending++;
|
|
}
|
|
|
|
protected override void OnCreate()
|
|
{
|
|
RequireForUpdate<NetworkId>();
|
|
}
|
|
|
|
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 });
|
|
}
|
|
}
|
|
}
|
|
}
|