Ejemplo n.º 1
0
    void Start()
    {
        World    = new EcsWorld();
        _systems = new EcsSystems(World)
                   //InitSystems
                   .Add(new LevelSetupSystem())

                   //RunSystems
                   .Add(new PlaySystem())
                   .Add(new GameStateProcessSystem())
                   .Add(new UpgradeSystem())
                   .Add(new IncomeProcessSystem())
                   .Add(new GameStateProcessSystem())
                   .Add(new GameSaveSystem())

                                              //DestroySystems
                   .Add(new EndGameSystem(0)) //TODO: manage scene idx in convenient readable form

                   .Inject(_currentLevel)
                   .Inject(_root)
                   .Inject(_configuration)
                   .Inject(_game)
                   .Inject(_saveService)

                   .OneFrame <PlayModeEvent>()
                   .OneFrame <IncomeEvent>()
                   .OneFrame <UpgradeCharacterEvent>();


#if UNITY_EDITOR
        Leopotam.Ecs.UnityIntegration.EcsWorldObserver.Create(World);
        Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(_systems);
#endif
        _systems?.Init();
    }
Ejemplo n.º 2
0
    void Start()
    {
        systems.Init();
        systemsPhysics.Init();

        CreateBattleComponent();
    }
Ejemplo n.º 3
0
        private void Start()
        {
            _world   = new EcsWorld();         // Инициализация окружения _world
            _systems = new EcsSystems(_world); // Инициализация систем окружения _systems

            //Добавление систем к инициализации в окружении
            _systems
            .Add(new GameInitSystem())
            .Add(new EnemyInitSystem())
            .Add(new PlayerInputSystem())
            .Add(new MoveSystem())
            .Add(new CameraSystem())
            .Add(new ShotSystem())
            .Add(new BonusInitSystem())

            //Внедрение зависимостей со сцены во все системы
            //Отлов зависимостей внутри систем => ECSFilter<T>, where T [anyAllowed]Component
            .Inject(playerStartPoint)
            .Inject(weaponController)
            .Inject(startButton)
            .Inject(waypoints)
            .Inject(spawnerContainer)

            /*
             * .Inject(levelSpawners)*/;


            //Инициализация систем
            _systems.Init();
        }
Ejemplo n.º 4
0
        void Start()
        {
            // create ecs environment.
            _world = new EcsWorld();

#if UNITY_EDITOR
            Leopotam.Ecs.UnityIntegration.EcsWorldObserver.Create(_world);
#endif
            _systems = new EcsSystems(_world)
                       .Add(new DemoInitSystem())
                       .Add(new InputSystem())
                       .Add(new PlayerMoveSystem())

                       .Add(new PlayerViewCreateSystem())
                       .Add(new PlayerViewUpdatePositionSystem())

                       .Inject(GetComponent <IViewService>())
                       .Inject(GetComponent <IInputService>())

                       .OneFrame <Ecs.Input>()
                       .OneFrame <PositionUpdated>()
            ;
            _systems.Init();

#if UNITY_EDITOR
            Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(_systems);
#endif
        }
Ejemplo n.º 5
0
    public void Init()
    {
        systems = new EcsSystems(world);

        systems
        .Add(new PlayerSpawnSystem())
        .Add(new PlayerTargetSystem())
        .Add(new PlayerMiningSystem())
        .Add(new PlayerMovingSystem())
        .Add(new PlayerStopMiningSystem())
        .Add(new PlayerStopMovingSystem())
        .Add(new SpawnEscapedPlayersSystem())
        .Add(new PlayerExitSystem())
        .Add(new HeadSizeChangingSystem())
        .Add(new PlayerMiningCompleteSystem())
        .Add(new PlayerMovingCompleteSystem())
        .Add(new MinigProgressSystem())
        .Add(new SkinColorChangingSystem())
        .Add(new PlayerRemovingSystem())
        .Add(new EnableNavmeshAgentDelaySystem())
        .Add(new PlayerHudRemovingSystem())
        .Add(new LeaderBoardSystem())
        .Add(new PlayerUsingSystem())
        .Add(new ChangeHatSystem())
        .Add(new SavePlayersSystem())
        .Add(new LoadPlayersSystem())

        .Inject(gameData)
        .Inject(levelData)
        .Inject(runtimeData);

        systems.Init();
    }
Ejemplo n.º 6
0
 private void initEcs(EcsWorld ecsWorld)
 {
     systems = new EcsSystems(ecsWorld);
     systems.Add(new UnitVisualSystem());
     systems.Add(new ItemVisualSystem());
     systems.Add(new DesignationVisualSystem());
     systems.Init();
 }
Ejemplo n.º 7
0
        void Start()
        {
            world   = new EcsWorld();
            systems = new EcsSystems(world);

#if UNITY_EDITOR
            Leopotam.Ecs.UnityIntegration.EcsWorldObserver.Create(world);
            Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(systems);
#endif
            // order is important
            systems.Add(new GameMatchLauncherSystem());
            systems.Add(new AiSystem());

            systems.Add(new OrderingSystem());

            systems.Add(new MovableSystem());
            systems.Add(new TurretSystem());
            systems.Add(new AttackSystem());
            systems.Add(new HarvestingSystem());

            systems.Add(new NavMeshSystem());
            systems.Add(new ProductionSystem());

            systems.Add(new SelectionSystem());

            systems.Add(new SpawnUnitsSystem());
            systems.Add(new ChangeUnitOwnerSystem());
            systems.Add(new SearchEnemySystem());
            systems.Add(new UnitsEffectsSystem());

            systems.Add(new PlayersSystem());
            systems.Add(new CameraSystem());

            systems.Add(new UI.FloatingSystem()); // todo move to UI init system?
            systems.Add(new UI.HealthbarsSystem());
            systems.Add(new UI.GameInfoSystem());

            systems.Add(new ProcessDamageSystem());

            systems.Inject(StartData);
            systems.Inject(Camera.main);
            systems.Inject(UICanvas);

            systems.OneFrame <TakeDamageEvent>();
            systems.OneFrame <ChangeUnitOwnerEvent>();
            systems.OneFrame <MoveOrderEvent>();
            systems.OneFrame <SpawnUnitEvent>();
            systems.OneFrame <ShootEvent>();
            systems.OneFrame <RequestBuyUnitEvent>();

            systems.OneFrame <UI.RemoveHealthbarEvent>();
            systems.OneFrame <UI.AddHealthbarEvent>();
            systems.OneFrame <SpendPlayerResourcesEvent>();
            systems.OneFrame <SpendFieldResourcesEvent>();
            systems.OneFrame <AddPlayerResourcesEvent>();

            systems.Init();
        }
Ejemplo n.º 8
0
    void Awake()
    {
        scoreService.Init();
        Service <ScoreService> .Set(scoreService);



        World              = new EcsWorld();
        systemsUpdate      = new EcsSystems(World);
        systemsFixedUpdate = new EcsSystems(World);
#if UNITY_EDITOR
        Leopotam.Ecs.UnityIntegration.EcsWorldObserver.Create(World);
        Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(systemsUpdate);
        Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(systemsFixedUpdate);
#endif

        //Init Systems:

        //Update Systems:
        systemsUpdate.Add(new ECS.Systems.InputSystem());
        systemsUpdate.Add(new ECS.Systems.DelaySystem());
        systemsUpdate.Add(new ECS.Systems.MovementPlayerSystem());
        systemsUpdate.Add(new ECS.Systems.MovementSystem());
        systemsUpdate.Add(new ECS.Systems.ShootPlayerSystem());
        systemsUpdate.Add(new ECS.Systems.GeneratorSystem());
        systemsUpdate.Add(new ECS.Systems.ShootSystem());
        systemsUpdate.Add(new ECS.Systems.ScoreSystem());
        systemsUpdate.Add(new ECS.Systems.ScoreOutSystem());



        //Events:
        systemsUpdate.Add(new ECS.Systems.Events.CollisionPlayerEvent());
        systemsUpdate.Add(new ECS.Systems.Events.CollisionBulletEvent());
        systemsUpdate.Add(new ECS.Systems.Events.HitEventSystem());
        systemsUpdate.Add(new ECS.Systems.Events.RestartGameEventSystem());
        systemsUpdate.Add(new ECS.Systems.Events.DestroyEntityEventSystem());

        //Events UI:

        // register one-frame components (order is important), for example:
        // .OneFrame<TestComponent1> ()
        // .OneFrame<TestComponent2> ()

        // inject service instances here (order doesn't important), for example:
        // .Inject (new CameraService ())
        // .Inject (new NavMeshSupport ())


        systemsUpdate.Inject(gameData);
        systemsUpdate.Inject(scoreService);
        systemsUpdate.InjectUi(uiEmitter);
        systemsUpdate.Init();

        systemsFixedUpdate.Init();
    }
Ejemplo n.º 9
0
        public void Init()
        {
            _systems = new EcsSystems(World.Value);

            for (int i = 0; i < Systems.Length; i++)
            {
                _systems.Add(Systems[i]);
            }
            _systems.Init();
        }
Ejemplo n.º 10
0
        protected virtual void FinalizeSystems()
        {
            updateSystems.Init();
            fixedUpdateSystems.Init();

                        #if UNITY_EDITOR
            gizmosSystems.Init();
                        #endif

            isRunning = true;
        }
Ejemplo n.º 11
0
        public void Init()
        {
            HeadFeature?.Init(RootSystems);
            MainFeature?.Init(RootSystems);
            TailFeature?.Init(RootSystems);

            _debugger?.Init(RootSystems, World);

            RootSystems.ProcessInjects();
            RootSystems.Init();
        }
Ejemplo n.º 12
0
    private void Start()
    {
        world   = new EcsWorld();
        systems = new EcsSystems(world);

        runtimeData = new RuntimeData();
        levelData.DebugInput.World         = world;
        levelData.TwitchConnectionUI.World = world;
        CreateSystems();

        systems.Init();
    }
Ejemplo n.º 13
0
        private CameraSystemsExecutor(EcsWorld world, MovementCameraSystem movementCameraSystem)
        {
            _systems = new EcsSystems(world, "CameraSystems");

            _systems.Add(movementCameraSystem);

            _systems.Init();

#if UNITY_EDITOR
            Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(_systems);
#endif
        }
Ejemplo n.º 14
0
        // Start is called before the first frame update
        void Start()
        {
            world  = new EcsWorld();
            system = new EcsSystems(world);

            system.Add(new GameInitSystem());
            system.Add(new PlayerInputSystem());
            system.Add(new PlayerMoveSystem());
            //system.Add(new AnimatadCharacterSystem());
            system.Add(new FollowSystem());

            system.Init();
        }
Ejemplo n.º 15
0
        public void Start()
        {
            erosionShader          = Resources.Load <ComputeShader>("ComputeShaders/Erosion");
            heightMapComputeShader = Resources.Load <ComputeShader>("ComputeShaders/HeightMap");
            world = new EcsWorld();

            systems = new EcsSystems(world)
                      .Add(new GenerateHeightMapSystem())
                      .Add(new ErodeSystem())
                      .Add(new ConstructMeshSystem());

            systems.ProcessInjects();
            systems.Init();
        }
Ejemplo n.º 16
0
        private void SetupEcs()
        {
            var world   = new EcsWorld();
            var systems = new EcsSystems(world);

            SetupWorld(world);
            SetupSystems(systems);

            InjectDependencies(systems);

            BeforeInitializeSystems(systems);

            systems.Init();
        }
Ejemplo n.º 17
0
        private static void InitializeAllSystems(EcsWorld world)
        {
            //register all system into world for filter creation
            var ecsSystems = new EcsSystems(world);

            foreach (var system in mainSystems.Systems)
            {
                ecsSystems.Add(system.System);
            }

            ecsSystems.Init();
            //destroy initialized systems
            ecsSystems.Destroy();
        }
        public DefaultSystemsExecutor(EcsWorld world)
        {
            _world   = world;
            _systems = new EcsSystems(_world, "DefaultSystems");

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

            //_systems.Add(defaultSystem);

            _systems.Init();
        }
        public void Initialize()
        {
            Debug.Log("Initialize");
//#if UNITY_EDITOR
//        EcsWorldObserver.Create (_world);
//#endif
            _systems.Init();
            for (var i = 0; i < _count; i++)
            {
                _factory.Create();
            }
//#if UNITY_EDITOR
//        EcsSystemsObserver.Create (_systems);
//#endif
        }
        public PlayerSystemsExecutor(EcsWorld world, CreatePlayerCarSystem createPlayerCarSystem, MovementPlayerSystem movementPlayerSystem,
                                     PCControlPlayerSystem controlPlayerSystem)
        {
            _systems = new EcsSystems(world, "PlayerSystems");

            _systems
            .Add(createPlayerCarSystem)
            .Add(movementPlayerSystem)
            .Add(controlPlayerSystem);

            _systems.Init();

#if UNITY_EDITOR
            Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(_systems);
#endif
        }
Ejemplo n.º 21
0
        public void Start()
        {
            var services = CreateAllSharedState(_options);
            var worldCfg = new EcsWorldConfig()
            {
                ComponentsCount = _options.EntitiesMax,
                EntitiesCount   = _options.EntitiesMax,
            };

            _worlds = new EcsWorlds(services);
            _world  = _worlds.Create(cfg: worldCfg);
            _world
            .Register <Actor>()
            .Register <Bullet>()
            .Register <Deleted>()
            .Register <DesiredVelocity>()
            .Register <Position>()
            .Register <Rotation>()
            .Register <Weapon>()
            ;

            _systems = new EcsSystems();
            _systems
            .Add(new InitSystem())
            .Add(new TimeSystem())
            .Add(new ShootSystem())
            .Add(new BulletSystem())
            .Add(new MoveSystem())
            ;

            AddActorTypeSystemsByTypeCount();

            if (_options.IsRendering)
            {
                _systems
                .Add(new ActorViewUpdateSystem())
                .Add(new BulletViewDeleteSystem())
                .Add(new BulletViewUpdateSystem())
                ;
            }

            _systems.Add(new BulletDeleteSystem());

            _worlds.Init();
            _systems.Init(_worlds);
            _world = null;
        }
Ejemplo n.º 22
0
        void OnEnable()
        {
            _world   = new EcsWorld();
            _systems = new EcsSystems(_world);

            _worldStatusInject     = new WorldStatus();
            _entitiesPresetsInject = new EntitiesPresetsInject(presets);

#if UNITY_EDITOR
            Leopotam.Ecs.UnityIntegration.EcsWorldObserver.Create(_world);
            Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(_systems);
#endif
            _systems
            //.Add(new TestsSystem())
            .Add(new ProjectileSystem())

            .Add(new QueueSystem())
            .Add(new PhaseManagerSystem())
            .Add(new NextTurnSystem())
            .Add(new ZonesSystem())
            .Add(new LevelManagerSystem())
            .Add(new TargetSystem())
            .Add(new InputUserPhaseSystem())
            .Add(new InputNPCPhaseSystem())
            .Add(new ActionPhaseSystem())
            .Add(new ActionMoveSystem())
            .Add(new ActionAttackSystem())
            .Add(new ActionAnimationSystem())
            .Add(new EnvironmentPhaseSystem())
            .Add(new SpellSystem())
            .Add(new ModificationPhaseSystem())
            .Add(new DamageSystem())
            .Add(new AppearanceSystem())
            .Add(new GameOverSystem())
            .Add(new EffectSystem())
            .Add(new UISystem())
            .Add(new CameraSystem());

            _systems
            .Inject(_worldStatusInject)
            .Inject(_entitiesPresetsInject);


            _systems.Init();
        }
Ejemplo n.º 23
0
        void OnEnable()
        {
            _world = new EcsWorld();
#if UNITY_EDITOR
            EcsWorldObserver.Create(_world);
#endif
            _systems = new EcsSystems(_world)
                       .Add(new ObstacleProcessing())
                       .Add(new UserInputProcessing())
                       .Add(new MovementProcessing())
                       .Add(new FoodProcessing())
                       .Add(new DeadProcessing())
                       .Add(new ScoreProcessing());
            _systems.Init();
#if UNITY_EDITOR
            EcsSystemsObserver.Create(_systems);
#endif
        }
        private SpawnerSystemsExecutor(EcsWorld world,
                                       PositionSpawnerRelativelyPlayerSystem positionSpawnerRelativelyPlayerSystem,
                                       ObjectCreationSpawnerSystem objectCreationSpawnerSystem,
                                       ObjectDestructorSystem objectDestructorSystem)
        {
            _systems = new EcsSystems(world, "SpawnerSystems");

            _systems
            .Add(positionSpawnerRelativelyPlayerSystem)
            .Add(objectCreationSpawnerSystem)
            .Add(objectDestructorSystem);

            _systems.Init();

#if UNITY_EDITOR
            Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(_systems);
#endif
        }
Ejemplo n.º 25
0
    private void Start()
    {
        ecsWorld    = new EcsWorld();
        initSystems = new EcsSystems(ecsWorld)
                      .Add(new PlayerInitSystem())
                      .Add(new TubeInitSystem())
                      .Add(new TriggerInitSystem());
        updateSystems = new EcsSystems(ecsWorld)
                        .Add(new PlayerJumpSystem())
                        .Add(new TubeMoveSystem())
                        .Add(new HitSystem())
                        .OneFrame <Hit>();

        initSystems.ProcessInjects();
        updateSystems.ProcessInjects();

        initSystems.Init();
        updateSystems.Init();
    }
Ejemplo n.º 26
0
        private void Start()
        {
            // Bind models to view models
            FindObjectOfType <StaminaViewModel>().Bind(_staminaModel);
            FindObjectOfType <HealthViewModel>().Bind(_healthModel);

#if UNITY_EDITOR
            CreateInspector();
#endif
            // Prepare systems
            PrepareUpdateSystems();
            PrepareFixedUpdateSystems();
            // Merge systems
            _update.ProcessInjects();
            _fixedUpdate.ProcessInjects();
            // Init systems
            _fixedUpdate.Init();
            _update.Init();
        }
Ejemplo n.º 27
0
        public void Init(App app)
        {
            this.app = app;
            _world   = new EcsWorld();
            _systems = new EcsSystems(_world);
            _systems
            // register your systems here, for example:
            // .Add (new TestSystem1 ())
            // .Add (new TestSystem2 ())

            // register one-frame components (order is important), for example:
            // .OneFrame<TestComponent1> ()
            // .OneFrame<TestComponent2> ()

            // inject service instances here (order doesn't important), for example:
            // .Inject (new CameraService ())
            // .Inject (new NavMeshSupport ())
            .Init();
        }
Ejemplo n.º 28
0
    private EcsSystems StartWithSingleSystems(EcsWorld world)
    {
        _ecsSystems = new EcsSystems(world)
                      .Add(new MotionTargetInitSystem()
        {
            prefab = _prefab,
            amount = _amount,
            radius = _radius
        })
                      .Add(new MotionDirectionSystem()
        {
            speedLimits = _speed
        })
                      .Add(new MotionTargetSystem());

        _ecsSystems.Init();

        return(_ecsSystems);
    }
Ejemplo n.º 29
0
        public void Init()
        {
            GL.ClearColor(Color4.LightSkyBlue);
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Texture2D);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);

            world   = new EcsWorld();
            systems = new EcsSystems(world)
                      .Add(new RenderSystem())
                      .Add(new CameraSystem())
                      .Inject(window)
                      .Inject(this);

            systems.Init();

            EcsEntity playerEntity = world.NewEntity();

            playerEntity.Replace(new CameraComponent(new Vector3(0, 5, 5), -90.0f, -45.0f, 60));

            EcsEntity groundEntity = world.NewEntity();

            groundEntity.Replace(new TransformationComponent()
            {
                Position = new Vector3(0, 0, 0),
                Rotation = new Quaternion(0, 0, 0),
                Scale    = new Vector3(1, 1, 1)
            });

            groundEntity.Replace(new RenderComponent()
            {
                geometry = ResourceManager.GetResource <Geometry>("GROUND_GEOMETRY"),
                shader   = ResourceManager.GetResource <Shader>("GROUND_SHADER"),
                diffuse  = ResourceManager.GetResource <Texture>("GROUND_TEXTURE")
            });

            MainMenu                = new MainMenu(window);
            window.Resize          += (e) => MainMenu.Resize(e.Width, e.Height);
            MainMenu.OnButtonClick += HandleMainMenuButton_Click;
        }
Ejemplo n.º 30
0
        protected virtual void FinalizeSystems()
        {
            fixedUpdateSystems.ProcessInjects();
            updateSystems.ProcessInjects();
            lateUpdateSystems.ProcessInjects();

                        #if UNITY_EDITOR
            gizmosSystems.ProcessInjects();
                        #endif

            fixedUpdateSystems.Init();
            updateSystems.Init();
            lateUpdateSystems.Init();

                        #if UNITY_EDITOR
            gizmosSystems.Init();
                        #endif

            isRunning = true;
        }