protected override void OnCreate() { _rpcData = new NativeList <RpcData>(16, Allocator.Persistent); _rpcTypeHashToIndex = new NativeHashMap <ulong, int>(16, Allocator.Persistent); RegisterRpc <RpcSetNetworkId, RpcSetNetworkId>(); rpcExecuteGroup = GetEntityQuery( ComponentType.ReadWrite <IncomingRpcDataStreamBufferComponent>(), ComponentType.ReadWrite <OutgoingRpcDataStreamBufferComponent>(), ComponentType.ReadWrite <NetworkStreamConnection>(), ComponentType.Exclude <NetworkStreamDisconnected>()); RequireForUpdate(rpcExecuteGroup); _barrier = World.GetOrCreateSystem <BeginSimulationEntityCommandBufferSystem>(); _receiveSystem = World.GetOrCreateSystem <NetworkStreamReceiveSystem>(); }
protected override void OnCreate() { _connectionStates = new UnsafeHashMap <Entity, ConnectionStateData>(128, Allocator.Persistent); _newGhosts = new NativeHashMap <int, Entity>(16, Allocator.Persistent); _ghostPredictionSystemGroup = World.GetExistingSystem <GhostPredictionSystemGroup>(); NetworkStreamReceiveSystem networkStreamReceiveSystem = World.GetExistingSystem <NetworkStreamReceiveSystem>(); _driver = networkStreamReceiveSystem.Driver; _compressionModel = new NetworkCompressionModel(Allocator.Persistent); _unreliablePipeline = networkStreamReceiveSystem.UnreliablePipeline; EntityQueryDesc filterSpawn = new EntityQueryDesc { All = new ComponentType[] { typeof(GhostComponent) }, None = new ComponentType[] { typeof(GhostSystemStateComponent) } }; EntityQueryDesc filterDespawn = new EntityQueryDesc { All = new ComponentType[] { typeof(GhostSystemStateComponent) }, None = new ComponentType[] { typeof(GhostComponent) } }; ghostSpawnGroup = GetEntityQuery(filterSpawn); ghostDespawnGroup = GetEntityQuery(filterDespawn); ghostGroup = GetEntityQuery(ComponentType.ReadOnly <GhostComponent>(), ComponentType.ReadOnly <GhostSystemStateComponent>()); connectionGroup = GetEntityQuery(ComponentType.ReadWrite <NetworkStreamConnection>(), ComponentType.ReadOnly <NetworkStreamInGame>(), ComponentType.Exclude <NetworkStreamDisconnected>()); }