Example #1
0
        void Start()
        {
            // void can be switched to IEnumerator for support coroutines.

            _world        = new EcsWorld();
            _systems      = new EcsSystems(_world);
            _systemsFixed = new EcsSystems(_world);
            _input        = new ActionMap();
            _input.Enable();

#if UNITY_EDITOR
            Leopotam.Ecs.UnityIntegration.EcsWorldObserver.Create(_world);
            Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(_systems);
            Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(_systemsFixed);
#endif

            _systemsFixed
            .Add(new TankMoveSystem())
            .Inject(_input)
            .Init();

            _systems     //order is important!!
            //init
            .Add(new TankTransformInitSystem())
            .Add(new TankPropertiesInitSystem())
            .Add(new PoolInitSystem())
            .Add(new EnemyInitSystem())
            .Add(new InputEventSystem())

            //run
            .Add(new InputUpdateSystem())
            .Add(new ShootingSystem())
            .Add(new GunSwitchSystem())
            .Add(new CollisionHandleSystem())
            .Add(new EnemySpawnSystem())
            .Add(new DamageSystem())
            .Add(new UiViewSystem())
            .Add(new InputUiSystem())
            .Add(new SoundSystem())
            .Add(new GameStateSystem())


            .OneFrame <CollisionEvent>()
            .OneFrame <DamageEvent>()
            .OneFrame <GunSwitchEvent>()
            .OneFrame <ShootingEvent>()
            .OneFrame <GameStateSwitchEvent>()

            .Inject(_input)
            .Inject(_sceneInfo)
            .InjectUi(_sceneInfo._ui)
            .Init();
        }