Exemple #1
0
        protected override void OnCreate()
        {
            m_NewGhosts        = new NativeList <T>(16, Allocator.Persistent);
            m_NewGhostIds      = new NativeList <int>(16, Allocator.Persistent);
            m_InitialArchetype = EntityManager.CreateArchetype(ComponentType.ReadWrite <T>(),
                                                               ComponentType.ReadWrite <GhostComponent>());

            m_GhostUpdateSystemGroup = World.GetOrCreateSystem <GhostUpdateSystemGroup>();
            m_GhostMap           = m_GhostUpdateSystemGroup.GhostEntityMap;
            m_ConcurrentGhostMap = m_GhostMap.AsParallelWriter();
            m_DestroyGroup       = GetEntityQuery(ComponentType.ReadOnly <T>(),
                                                  ComponentType.Exclude <GhostComponent>(),
                                                  ComponentType.Exclude <PredictedGhostSpawnRequestComponent>());
            m_SpawnRequestGroup = GetEntityQuery(ComponentType.ReadOnly <T>(),
                                                 ComponentType.ReadOnly <PredictedGhostSpawnRequestComponent>());
            m_PlayerGroup = GetEntityQuery(ComponentType.ReadOnly <NetworkStreamConnection>(),
                                           ComponentType.ReadOnly <NetworkIdComponent>(), ComponentType.Exclude <NetworkStreamDisconnected>());

            m_InvalidGhosts                 = new NativeList <Entity>(1024, Allocator.Persistent);
            m_DelayedSpawnQueue             = new NativeQueue <DelayedSpawnGhost>(Allocator.Persistent);
            m_CurrentDelayedSpawnList       = new NativeList <DelayedSpawnGhost>(1024, Allocator.Persistent);
            m_ConcurrentDelayedSpawnQueue   = m_DelayedSpawnQueue.AsParallelWriter();
            m_PredictedSpawnQueue           = new NativeQueue <DelayedSpawnGhost>(Allocator.Persistent);
            m_CurrentPredictedSpawnList     = new NativeList <DelayedSpawnGhost>(1024, Allocator.Persistent);
            m_ConcurrentPredictedSpawnQueue = m_PredictedSpawnQueue.AsParallelWriter();
            m_Barrier = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();

            m_PredictSpawnGhosts        = new NativeList <PredictSpawnGhost>(16, Allocator.Persistent);
            m_PredictionSpawnCleanupMap = new NativeHashMap <int, int>(16, Allocator.Persistent);

            m_ClientSimulationSystemGroup = World.GetOrCreateSystem <ClientSimulationSystemGroup>();
        }
Exemple #2
0
        protected override void OnCreate()
        {
            serializers = default(TGhostDeserializerCollection);
            m_GhostUpdateSystemGroup = World.GetOrCreateSystem <GhostUpdateSystemGroup>();
            m_ghostEntityMap         = m_GhostUpdateSystemGroup.GhostEntityMap;

            playerGroup = GetEntityQuery(
                ComponentType.ReadWrite <NetworkStreamConnection>(),
                ComponentType.ReadOnly <NetworkStreamInGame>(),
                ComponentType.Exclude <NetworkStreamDisconnected>());

            m_Barrier          = World.GetOrCreateSystem <BeginSimulationEntityCommandBufferSystem>();
            m_CompressionModel = new NetworkCompressionModel(Allocator.Persistent);
#if UNITY_EDITOR || DEVELOPMENT_BUILD
            m_NetStats        = new NativeArray <uint>(serializers.Length * 3 + 3 + 1, Allocator.Persistent);
            m_StatsCollection = World.GetOrCreateSystem <GhostStatsCollectionSystem>();
#endif
            m_GhostDespawnSystem = World.GetOrCreateSystem <GhostDespawnSystem>();

            serializers.Initialize(World);

            RequireSingletonForUpdate <GhostPrefabCollectionComponent>();
        }