Exemplo n.º 1
0
        public static void InitServerSystems()
        {
            serverWorld = new World("ServerWorld");
            serverSimulationSystemGroup = serverWorld.GetOrCreateSystem <ServerSimulationSystemGroup>();

#if true
            foreach (var sys in allSystems)
            {
                var groups = sys.GetCustomAttributes(typeof(UpdateInGroupAttribute), true);
                foreach (var grp in groups)
                {
                    var group = grp as UpdateInGroupAttribute;

                    if (group.GroupType == typeof(ServerSimulationSystemGroup) ||
                        group.GroupType == typeof(ClientAndServerSimulationSystemGroup))
                    {
                        serverSimulationSystemGroup.AddSystemToUpdateList(serverWorld.GetOrCreateSystem(sys) as ComponentSystemBase);
                    }
                    else if (group.GroupType == typeof(ClientSimulationSystemGroup) ||
                             group.GroupType == typeof(ClientPresentationSystemGroup))
                    {
                        // do nothing
                    }
                    else
                    {
                        var mask = GetTopLevelWorldMask(group.GroupType);
                        if ((mask & WorldType.ServerWorld) != 0)
                        {
                            var groupSys = serverWorld.GetOrCreateSystem(group.GroupType) as ComponentSystemGroup;
                            groupSys.AddSystemToUpdateList(serverWorld.GetOrCreateSystem(sys) as ComponentSystemBase);
                        }
                    }
                }
            }

            serverSimulationSystemGroup.SortSystemUpdateList();
#endif
            // TODO: LZ:
            //      Use serverWorld to get rid of the warning:
            //      'ServerSimulationSystemGroup' can't be added to 'TickServerSimulationSystem' because they are in different worlds. ('ServerWorld' vs 'Default World')
            //var ticker = serverWorld.GetOrCreateSystem<TickServerSimulationSystem>();
            var ticker = World.Active.GetOrCreateSystem <TickServerSimulationSystem>();
            ticker.AddSystemToUpdateList(serverSimulationSystemGroup);
        }
Exemplo n.º 2
0
        protected override void OnCreate()
        {
            serializers  = default(TGhostSerializerCollection);
            m_DataStream = new DataStreamWriter(2048, Allocator.Persistent);
            ghostGroup   = GetEntityQuery(typeof(GhostComponent), typeof(GhostSystemStateComponent));
            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);

            m_FreeGhostIds         = new NativeQueue <int>(Allocator.Persistent);
            m_AllocatedGhostIds    = new NativeArray <int>(1, Allocator.Persistent);
            m_AllocatedGhostIds[0] = 1; // To make sure 0 is invalid

            connectionGroup = GetEntityQuery(
                ComponentType.ReadWrite <NetworkStreamConnection>(),
                ComponentType.ReadOnly <NetworkStreamInGame>());

            m_ServerSimulation = World.GetExistingSystem <ServerSimulationSystemGroup>();
            m_Barrier          = World.GetOrCreateSystem <BeginSimulationEntityCommandBufferSystem>();
            m_ReceiveSystem    = World.GetOrCreateSystem <NetworkStreamReceiveSystem>();

            m_ConnectionStates      = new List <ConnectionStateData>(256);
            m_ConnectionStateLookup = new NativeHashMap <Entity, int>(256, Allocator.Persistent);
            m_CompressionModel      = new NetworkCompressionModel(Allocator.Persistent);

            m_SerialSpawnChunks = new NativeList <PrioChunk>(1024, Allocator.Persistent);
        }
Exemplo n.º 3
0
 protected override void OnCreate()
 {
     serverSimulationSystemGroup = World.GetExistingSystem <ServerSimulationSystemGroup>();
 }