Example #1
0
        protected override void OnUpdate()
        {
            var entity   = GetSingletonEntity <SpawnMenuArray>();
            var requests = EntityManager.GetBuffer <SpawnMenuRequest>(entity);

            if (requests.Length == 0)
            {
                return;
            }

            var array = requests.ToNativeArray(Allocator.Temp);

            requests.Clear();
            foreach (var spawnMenu in array)
            {
                var menuTemplate = MenuUtilities.GetMenuTemplate(spawnMenu.Type);
                if (menuTemplate == MenuTemplate.Null)
                {
                    continue;
                }

                var e    = GameCreateUtilities.CreateMenuItem(EntityManager);
                var menu = EntityManager.GetComponentData <MenuItem>(e);
                menu.Index       = spawnMenu.index;
                menu.ProductId   = (ushort)menuTemplate.Product;
                menu.MaterialId1 = (ushort)menuTemplate.Material1;
                menu.MaterialId2 = (ushort)menuTemplate.Material2;
                menu.MaterialId3 = (ushort)menuTemplate.Material3;
                menu.MaterialId4 = (ushort)menuTemplate.Material4;
                EntityManager.SetComponentData(e, menu);
                FSLog.Info($"Spawn Menu:{spawnMenu.Type},index:{ menu.Index }");
            }

            array.Dispose();
        }
Example #2
0
        protected override void OnCreate()
        {
            var entity = EntityManager.CreateEntity(typeof(SpawnMenuArray));

            SetSingleton(new SpawnMenuArray());
            EntityManager.AddBuffer <SpawnMenuRequest>(entity);
            MenuUtilities.Init();
        }
        protected override void OnCreate()
        {
            FSLog.Info("KitchenClientSimulationSystemGroup OnCreate");

            ConfigVar.Init();
            GameWorld.Active = new GameWorld();
            ItemCreateUtilities.Init();
            ClientCharacterUtilities.Init();
            MenuUtilities.Init();
            IconUtilities.Init();
            Application.targetFrameRate     = 60;
            UnityEngine.Time.fixedDeltaTime = GameTick.DefaultGameTick.TickInterval;

            worldSceneEntitiesSystem = World.GetOrCreateSystem <WorldSceneEntitiesSystem>();
            m_systemsToUpdate.Add(worldSceneEntitiesSystem);

            networkSystem = World.GetOrCreateSystem <NetworkClientSystem>();
            m_systemsToUpdate.Add(networkSystem);

            handleTimeSystem = World.GetOrCreateSystem <HandleTimeSystem>();
            m_systemsToUpdate.Add(handleTimeSystem);

            setRenderTimeSystem = World.GetOrCreateSystem <SetRenderTimeSystem>();
            m_systemsToUpdate.Add(setRenderTimeSystem);

            replicateEntitySystemGroup = World.GetOrCreateSystem <ReplicateEntitySystemGroup>();
            m_systemsToUpdate.Add(replicateEntitySystemGroup);


            setPredictTimeSystem = World.GetOrCreateSystem <SetPredictTimeSystem>();
            m_systemsToUpdate.Add(setPredictTimeSystem);

            predictSystem = World.GetOrCreateSystem <PredictSystem>();
            m_systemsToUpdate.Add(predictSystem);

            itemClientSystemGroup = World.GetOrCreateSystem <ItemClientSystemGroup>();
            m_systemsToUpdate.Add(itemClientSystemGroup);


            predictPresentationSystemGroup = World.GetOrCreateSystem <PredictPresentationSystemGroup>();
            m_systemsToUpdate.Add(predictPresentationSystemGroup);

            despawnSystemGroup = World.GetOrCreateSystem <DespawnSystemGroup>();
            m_systemsToUpdate.Add(despawnSystemGroup);
        }