using Unity.Collections;
using Unity.Entities;
using Unity.NetCode;
namespace ProjectM.Server
{
///
/// Shared server-side RPC sender resolution: a request's ReceiveRpcCommandRequest.SourceConnection →
/// its → the conn→player map that every RPC-receive system builds (the
/// AbilityUpgradeSystem / ReadyToggle idiom). The MAP BUILD stays per-caller — each system's player query
/// carries different extra required components (InventorySlot / EquipmentSlot / StatModifier / BoonOffer /
/// PlayerReady / …) — but the RESOLVE step is byte-for-byte identical across sites, so it lives here once.
/// Burst-safe (plain reads; called from [BurstCompile] receivers).
///
public static class PlayerResolve
{
/// True (with set) iff has a
/// present in . Behaviour-identical to the inline
/// HasComponent<NetworkId>(conn) && map.TryGetValue(GetComponent<NetworkId>(conn).Value, out player).
public static bool TryResolve(ref SystemState state, NativeHashMap map, Entity conn, out Entity player)
{
player = Entity.Null;
return state.EntityManager.HasComponent(conn)
&& map.TryGetValue(state.EntityManager.GetComponentData(conn).Value, out player);
}
}
}