using ProjectM.Simulation;
using Unity.Entities;
using Unity.NetCode;
using UnityEngine;
namespace ProjectM.Client
{
///
/// Client-side portal-interact sender: a static flag (the portal prompt / E-key) drained into a single
/// RPC. Coalesced (one per drain — repeat E while the server is still in
/// RoomExplore is harmless, the server latches once). Statics reset on play-enter.
///
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)]
public partial class PortalInteractSendSystem : SystemBase
{
static bool s_pending;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void ResetStatics() => s_pending = false;
/// Request leaving via the portal (the HUD prompt / E-key near the portal drives this).
public static void Interact() => s_pending = true;
protected override void OnCreate() => RequireForUpdate();
protected override void OnUpdate()
{
if (!s_pending) return;
s_pending = false;
EntityManager.CreateEntity(typeof(PortalInteractRequest), typeof(SendRpcCommandRequest));
}
}
}