예제 #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();
        }
예제 #2
0
        protected override void OnUpdate()
        {
            var entity   = GetSingletonEntity <SpawnGameArray>();
            var requests = EntityManager.GetBuffer <SpawnGameRequest>(entity);

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

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

            requests.Clear();

            foreach (var spawnGame in array)
            {
                GameCreateUtilities.CreateGame(EntityManager);
            }

            array.Dispose();
        }
예제 #3
0
 public override Entity Create(EntityManager entityManager, BundledResourceManager resourceManager,
                               GameWorld world, ushort type)
 {
     return(GameCreateUtilities.CreateMenuItem(entityManager));
 }