static void Boot()
        {
            var world = new World("Example World");

            world.GetOrCreateManager <NavAgentSystem>();
            var query = world.GetOrCreateManager <NavMeshQuerySystem>();

            world.GetOrCreateManager <AnimatedRendererSystem>();
            world.GetOrCreateManager <NavAgentToPositionSyncSystem>();
            world.GetOrCreateManager <RecycleDeadSystem>();
            var targetSystem = world.GetOrCreateManager <SetTargetSystem>();

            spawner = world.GetOrCreateManager <SpawnerSystem>();
            world.GetOrCreateManager <UpdateMatrixSystem>();
            manager = world.GetOrCreateManager <EntityManager>();
            var allWorlds = new World[] { world };

            ScriptBehaviourUpdateOrder.UpdatePlayerLoop(allWorlds);
            World.Active = world;
            Unit         = manager.CreateArchetype(
                typeof(SyncPositionFromNavAgent),
                typeof(Position),
                typeof(TransformMatrix),
                typeof(Unit),
                typeof(Animated),
                typeof(AnimatedState),
                typeof(NavAgent)
                );

            PlayerLoopManager.RegisterDomainUnload(DomainUnloadShutdown, 10000);

            // setup navmesh query
            query.UseCache = false;
            // ArchetypeDeclarationStart - Do not remove
            // ArchetypeDeclarationStop - Do not remove
        }
Example #2
0
 protected override void OnCreate()
 {
     ms_instance = this;
     m_beginCBS  = World.GetOrCreateSystem <BeginSimulationEntityCommandBufferSystem>();
 }
        public void Execute(Entity entity, int index, ref Translation translation)
        {
            float angle = RandomCache.GetAngle();
            float newX  = SpawnerSystem.SpawnerPos.x + Mathf.Sin(angle) * RandomCache.GetCenterDistance();
            float newZ  = SpawnerSystem.SpawnerPos.z + Mathf.Cos(angle) * RandomCache.GetCenterDistance();

            translation.Value = new float3(newX, SpawnerSystem.SpawnerPos.y, newZ);
            CommandBuffer.RemoveComponent <ResetCube>(index, entity);
            uint BlockType = RandomCache.GetCubeType();

            if (BlockType == 1)
            {
                CommandBuffer.AddComponent(index, entity, new MoveUp(RandomCache.GetLifeSpan()));
            }
            else
            {
                CommandBuffer.AddComponent(index, entity, new MoveRandom(RandomCache.GetLifeSpan(), SpawnerSystem.GetRandComponentfloat3()));
            }
        }