Initialize() public method

public Initialize ( ) : void
return void
Exemplo n.º 1
0
 void Start() {
     _pool = new Pool(ComponentIds.TotalComponents, 0, new PoolMetaData("Systems Pool", ComponentIds.componentNames));
     new PoolObserver(_pool, ComponentIds.componentTypes);
     _systems = createNestedSystems();
     _systems.Initialize();
     _pool.CreateEntity().AddMyString("");
 }
Exemplo n.º 2
0
 void Start() {
     _pool = new Pool(ComponentIds.TotalComponents);
     new PoolObserver(_pool, ComponentIds.componentNames, ComponentIds.componentTypes, "Systems Pool");
     _systems = createSystems();
     _systems.Initialize();
     _pool.CreateEntity().AddMyString("");
 }
Exemplo n.º 3
0
    void Start()
    {
        Random.seed = 42;

        _systems = createSystems(Pools.pool);
        _systems.Initialize();
    }
Exemplo n.º 4
0
        void Awake()
        {
            _systems = CreateSystems(Pools.pool);
            _systems.Initialize();

            CreateGame();
            
           
        }
    void Start()
    {
        if (useSeed)
        {
            Random.seed = randomSeed;
        }

        Debug.Log("Starting GameController using seed " + Random.seed);
        systems = CreateSystems(Pools.pool);
        systems.Initialize();
    }
Exemplo n.º 6
0
    private void Start()
    {
        _contexts = Contexts.sharedInstance;
        _systems  = CreateSystems(_contexts);
        _systems.Initialize();
        GameEntity mover = _contexts.game.CreateEntity();

        mover.isMover = true;
        mover.AddPosition(Vector2.zero);
        mover.AddDirection(Random.Range(0, 360));
        mover.AddSprite("Bee");
        mover.AddColour(0);
    }
Exemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        //first init system (important, because I want systems to exist before any entities are created):
        _systems = new RootSystem(Contexts.sharedInstance);
        _systems.Initialize();

        HexGridBehaviour grid   = GameObject.FindObjectOfType <HexGridBehaviour>();
        GameContext      game   = Contexts.sharedInstance.game;
        Presets          preset = new Presets(game, grid);

        TurnGridToEntities(game, grid);
        FindEntitiesInUnity(game, preset);
        SetupPlayers(game, preset, grid);
    }
Exemplo n.º 8
0
        void Update()
        {
            if (PhotonNetwork.isMasterClient)
            {
                if (!_serverSystemsInitialized)
                {
                    _serverSystemsInitialized = true;
                    _serverSystems.Initialize();
                }
                _serverSystems.Execute();
                _serverSystems.Cleanup();
            }


            _systems.Execute();
            _systems.Cleanup();
        }
Exemplo n.º 9
0
        public override void OnEnter()
        {
            base.OnEnter();
            InitService service = _ctx.QueryService <InitService>(InitService.Name);

            service.SMActor.LoadScene("World");

            _systems.Initialize();

            // udp sync
            Modules.BattleScene m = _ctx.U.GetModule <Modules.BattleScene>();
            long   session        = m.Session;
            string host           = m.UdpHost;
            int    port           = (int)m.UdpPort;

            _ctx.UdpAuth(session, host, port);
        }
Exemplo n.º 10
0
        internal void Begin()
        {
            //
            // mmGame calls Begin() before a new scene window is created
            //
            SceneColliderDatabase.Initialize();

            //
            // Allow Entitas to init systems, auto collect matched systems, no manual Systems.Add(ISystem) required
            //
            EntitySystems = new Entitas.Feature(null);                           //game entities
            EntitySystems.Initialize();

            //SceneSystems = new Entitas.Feature(null);               //scene UI entities
            //SceneSystems.Initialize();
            OnStart();
        }
Exemplo n.º 11
0
        private void SetupSystems()
        {
            //a feature is a group of systems
            _pausableUpdateSystems = new Feature();

            _pausableUpdateSystems.Add(_pool.CreateSystem <StartNextRoundSystem> ());
            _pausableUpdateSystems.Add(_pool.CreateSystem <VelocitySystem> ());
            _pausableUpdateSystems.Add(_pool.CreateSystem <AcceptInputSystem> ());
            _pausableUpdateSystems.Add(_pool.CreateSystem <AISystem> ());
            _pausableUpdateSystems.Add(_pool.CreateSystem <GoalSystem> ());
            _pausableUpdateSystems.Add(_pool.CreateSystem <DestroySystem> ());

            //	'Collision' as NOT physics based - as an example
            _pausableUpdateSystems.Add(_pool.CreateSystem <BoundsBounceSystem> ());
            _pausableUpdateSystems.Add(_pool.CreateSystem <BoundsConstrainSystem> ());
            _pausableUpdateSystems.Initialize();
            _pausableUpdateSystems.ActivateReactiveSystems();


            _pausableFixedUpdateSystems = new Feature();
            //  'Collision as Physics based - as an example.
            _pausableFixedUpdateSystems.Add(_pool.CreateSystem <CollisionSystem> ());
            _pausableFixedUpdateSystems.Initialize();
            _pausableFixedUpdateSystems.ActivateReactiveSystems();


            //for demo only, an example of an unpausable system
            _unpausableUpdateSystems = new Feature();
            _unpausableUpdateSystems.Add(_pool.CreateSystem <TimeSystem> ());
            _unpausableUpdateSystems.Initialize();
            _unpausableUpdateSystems.ActivateReactiveSystems();

            // This is custom and optional. I use it to store the systems in case I need them again.
            // This is the only place I put a component directly on a _pool. It is supported.
            // I'm not sure this is useful, but I saw something similar in Entitas presentation slides - srivello
            _pool.SetEntitas
            (
                _pausableUpdateSystems,
                _unpausableUpdateSystems,
                _pausableUpdateSystems
            );
            //Debug.Log("pausableUpdateSystems: " + Pools.pool.entitas.pausableUpdateSystems);
        }
Exemplo n.º 12
0
        private void SetupSystems()
        {
            //a feature is a group of systems
            _unpausableUpdateSystems = new Feature();
            _unpausableUpdateSystems.Add(_pool.CreateSystem <VelocitySystem> ());
            _unpausableUpdateSystems.Add(_pool.CreateSystem <AcceptInputSystem> ());
            _unpausableUpdateSystems.Add(_pool.CreateSystem <DestroySystem> ());

            _unpausableUpdateSystems.Initialize();
            _unpausableUpdateSystems.ActivateReactiveSystems();

            // I'm not sure this is useful, but I saw something similar in Entitas presentation slides - srivello
            _pool.SetEntitas
            (
                null,
                _unpausableUpdateSystems,
                null
            );
            //Debug.Log("pausableUpdateSystems: " + Pools.pool.entitas.unpausableUpdateSystems);
        }
Exemplo n.º 13
0
    private void Awake()
    {
        services = new Services.Services
        {
            Time = new UnityTimeService(),
            CollidingViewRegister = new UnityCollidingViewRegister(),
            InputService          = new StandaloneInputService(),
        };

        systems = new MazeFeature
                  (
            Contexts.sharedInstance.game,
            Contexts.sharedInstance.meta,
            Contexts.sharedInstance.input,
            services,
            Prefabs
                  );

        systems.Initialize();
    }
    void Start()
    {
        _contexts = new Contexts();
        _contexts.visualDebugging = new Context(
            VisualDebuggingComponentIds.TotalComponents, 0,
            new ContextInfo(
                "Systems Context",
                VisualDebuggingComponentIds.componentNames,
                VisualDebuggingComponentIds.componentTypes
            )
        );

        #if(!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)
        new ContextObserver(_contexts.visualDebugging);
        #endif

        _systems = createNestedSystems();

        //// Test call
        _systems.Initialize();
        _systems.Execute();
        _systems.Cleanup();
        _systems.TearDown();

        _contexts.visualDebugging.CreateEntity().AddMyString("");
    }
Exemplo n.º 15
0
 void Start()
 {
     _systems.Initialize();
 }
Exemplo n.º 16
0
    void when_systems()
    {
        Pool pool = null;
        before = () => {
            pool = new Pool(10);
        };

        context["fixtures"] = () => {
            it["initializes InitializeSystemSpy"] = () => {
                var initializeSystem = new InitializeSystemSpy();
                initializeSystem.initialized.should_be_false();
                initializeSystem.Initialize();
                initializeSystem.initialized.should_be_true();
            };

            it["executes ExecuteSystemSpy"] = () => {
                var initializeSystem = new ExecuteSystemSpy();
                initializeSystem.executed.should_be_false();
                initializeSystem.Execute();
                initializeSystem.executed.should_be_true();
            };

            it["initializes and executes InitializeExecuteSystemSpy"] = () => {
                var initializeSystem = new InitializeExecuteSystemSpy();
                initializeSystem.initialized.should_be_false();
                initializeSystem.executed.should_be_false();
                initializeSystem.Initialize();
                initializeSystem.Execute();
                initializeSystem.initialized.should_be_true();
                initializeSystem.executed.should_be_true();
            };

            it["executes ReactiveSystemSpy"] = () => {
                var system = createReactiveSystem(pool);
                var spy = (ReactiveSubSystemSpy)system.subsystem;
                spy.didExecute.should_be(0);
                spy.initialized.should_be_false();
                system.Execute();
                spy.didExecute.should_be(1);
                spy.initialized.should_be_false();
            };
        };

        context["systems"] = () => {
            Systems systems = null;
            before = () => {
                systems = new Systems();
            };

            it["returns systems when adding system"] = () => {
                systems.Add(new InitializeSystemSpy()).should_be_same(systems);
            };

            it["initializes IInitializeSystem"] = () => {
                var system = new InitializeSystemSpy();
                systems.Add(system);
                systems.Initialize();
                system.initialized.should_be_true();
            };

            it["executes IExecuteSystem"] = () => {
                var system = new ExecuteSystemSpy();
                systems.Add(system);
                systems.Execute();
                system.executed.should_be_true();
            };

            it["initializes and executes IInitializeSystem, IExecuteSystem"] = () => {
                var system = new InitializeExecuteSystemSpy();
                systems.Add(system);
                systems.Initialize();
                systems.Execute();
                system.initialized.should_be_true();
                system.executed.should_be_true();
            };

            it["initializes and executes ReactiveSystem"] = () => {
                var system = createReactiveSystem(pool);

                systems.Add(system);
                systems.Initialize();
                systems.Execute();
                systems.Execute();

                var spy = (ReactiveSubSystemSpy)system.subsystem;
                spy.didExecute.should_be(1);
                spy.initialized.should_be_true();
            };

            it["clears reactive systems"] = () => {
                var system = createReactiveSystem(pool);

                systems.Add(system);
                systems.Initialize();
                systems.ClearReactiveSystems();
                systems.Execute();

                var spy = (ReactiveSubSystemSpy)system.subsystem;
                spy.didExecute.should_be(0);
                spy.initialized.should_be_true();
            };

            it["clears reactive systems recursively"] = () => {
                var system = createReactiveSystem(pool);
                systems.Add(system);
                var parentSystems = new Systems();
                parentSystems.Add(systems);

                parentSystems.Initialize();
                parentSystems.ClearReactiveSystems();
                parentSystems.Execute();

                var spy = (ReactiveSubSystemSpy)system.subsystem;
                spy.didExecute.should_be(0);
                spy.initialized.should_be_true();
            };

            it["deactivates reactive systems"] = () => {
                var system = createReactiveSystem(pool);

                systems.Add(system);
                systems.Initialize();
                systems.DeactivateReactiveSystems();
                systems.Execute();

                var spy = (ReactiveSubSystemSpy)system.subsystem;
                spy.didExecute.should_be(0);
                spy.initialized.should_be_true();
            };

            it["deactivates reactive systems recursively"] = () => {
                var system = createReactiveSystem(pool);
                systems.Add(system);
                var parentSystems = new Systems();
                parentSystems.Add(systems);

                parentSystems.Initialize();
                parentSystems.DeactivateReactiveSystems();
                parentSystems.Execute();

                var spy = (ReactiveSubSystemSpy)system.subsystem;
                spy.didExecute.should_be(0);
                spy.initialized.should_be_true();
            };

            it["activates reactive systems"] = () => {
                var system = createReactiveSystem(pool);

                systems.Add(system);
                systems.Initialize();
                systems.DeactivateReactiveSystems();
                systems.ActivateReactiveSystems();
                systems.Execute();

                var spy = (ReactiveSubSystemSpy)system.subsystem;
                spy.didExecute.should_be(0);
                spy.initialized.should_be_true();

                pool.CreateEntity().AddComponentA();
                systems.Execute();
                spy.didExecute.should_be(1);
            };

            it["activates reactive systems recursively"] = () => {
                var system = createReactiveSystem(pool);
                systems.Add(system);
                var parentSystems = new Systems();
                parentSystems.Add(systems);

                parentSystems.Initialize();
                parentSystems.DeactivateReactiveSystems();
                parentSystems.ActivateReactiveSystems();
                parentSystems.Execute();

                var spy = (ReactiveSubSystemSpy)system.subsystem;
                spy.didExecute.should_be(0);
                spy.initialized.should_be_true();

                pool.CreateEntity().AddComponentA();
                systems.Execute();
                spy.didExecute.should_be(1);
            };
        };
    }
 void Start()
 {
     _pool = new Pool(VisualDebuggingComponentIds.TotalComponents, 0, new PoolMetaData("Systems Pool", VisualDebuggingComponentIds.componentNames, VisualDebuggingComponentIds.componentTypes));
     #if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)
     new PoolObserver(_pool);
     #endif
     _systems = createNestedSystems();
     _systems.Initialize();
     _pool.CreateEntity().AddMyString("");
 }
Exemplo n.º 18
0
 void Start()
 {
     systems = createSystems(Pools.pool);
     systems.Initialize();
 }
Exemplo n.º 19
0
 void Awake()
 {
     _systems = CreateSystems();
     _systems.Initialize();
 }
Exemplo n.º 20
0
    void when_systems()
    {
        Contexts contexts = null;

        before = () => {
            contexts = new Contexts { test = new Context(10) };
        };

        context["fixtures"] = () => {

            it["initializes InitializeSystemSpy"] = () => {
                var system = new InitializeSystemSpy();
                system.didInitialize.should_be(0);
                system.Initialize();
                system.didInitialize.should_be(1);
            };

            it["executes ExecuteSystemSpy"] = () => {
                var system = new ExecuteSystemSpy();
                system.didExecute.should_be(0);
                system.Execute();
                system.didExecute.should_be(1);
            };

            it["cleans up CleanupSystemSpy"] = () => {
                var system = new CleanupSystemSpy();
                system.didCleanup.should_be(0);
                system.Cleanup();
                system.didCleanup.should_be(1);
            };

            it["tears down TearDownSystemSpy"] = () => {
                var system = new TearDownSystemSpy();
                system.didTearDown.should_be(0);
                system.TearDown();
                system.didTearDown.should_be(1);
            };

            it["initializes, executes, cleans up and tears down system"] = () => {
                var system = new ReactiveSystemSpy(contexts.test.CreateCollector(Matcher.AllOf(CID.ComponentA)));
                contexts.test.CreateEntity().AddComponentA();

                system.didInitialize.should_be(0);
                system.Initialize();
                system.didInitialize.should_be(1);

                system.didExecute.should_be(0);
                system.Execute();
                system.didExecute.should_be(1);

                system.didCleanup.should_be(0);
                system.Cleanup();
                system.didCleanup.should_be(1);

                system.didTearDown.should_be(0);
                system.TearDown();
                system.didTearDown.should_be(1);
            };

            it["executes ReactiveSystemSpy"] = () => {
                var system = createReactiveSystem(contexts);

                system.Execute();

                system.entities.Length.should_be(1);
            };
        };

        context["systems"] = () => {

            Systems systems = null;

            before = () => {
                systems = new Systems();
            };

            it["returns systems when adding system"] = () => {
                systems.Add(new InitializeSystemSpy()).should_be_same(systems);
            };

            it["initializes IInitializeSystem"] = () => {
                var system = new InitializeSystemSpy();
                systems.Add(system);
                systems.Initialize();
                system.didInitialize.should_be(1);
            };

            it["executes IExecuteSystem"] = () => {
                var system = new ExecuteSystemSpy();
                systems.Add(system);
                systems.Execute();
                system.didExecute.should_be(1);
            };

            it["wraps IReactiveSystem in a ReactiveSystem"] = () => {
                var system = new ReactiveSystemSpy(contexts.test.CreateCollector(Matcher.AllOf(CID.ComponentA)));
                systems.Add(system);
                contexts.test.CreateEntity().AddComponentA();
                systems.Execute();
                system.didExecute.should_be(1);
            };

            it["adds ReactiveSystem"] = () => {
                var system = new ReactiveSystemSpy(contexts.test.CreateCollector(Matcher.AllOf(CID.ComponentA)));
                systems.Add(system);
                contexts.test.CreateEntity().AddComponentA();
                systems.Execute();
                system.didExecute.should_be(1);
            };

            it["cleans up ICleanupSystem"] = () => {
                var system = new CleanupSystemSpy();
                systems.Add(system);
                systems.Cleanup();
                system.didCleanup.should_be(1);
            };

            it["initializes, executes, cleans up and tears down InitializeExecuteCleanupTearDownSystemSpy"] = () => {
                var system = new ReactiveSystemSpy(contexts.test.CreateCollector(Matcher.AllOf(CID.ComponentA)));
                contexts.test.CreateEntity().AddComponentA();

                systems.Add(system);

                system.didInitialize.should_be(0);
                systems.Initialize();
                system.didInitialize.should_be(1);

                system.didExecute.should_be(0);
                systems.Execute();
                system.didExecute.should_be(1);

                system.didCleanup.should_be(0);
                systems.Cleanup();
                system.didCleanup.should_be(1);

                system.didTearDown.should_be(0);
                systems.TearDown();
                system.didTearDown.should_be(1);
            };

            it["initializes, executes, cleans up and tears down ReactiveSystem"] = () => {
                var system = createReactiveSystem(contexts);

                systems.Add(system);

                system.didInitialize.should_be(0);
                systems.Initialize();
                system.didInitialize.should_be(1);

                system.didExecute.should_be(0);
                systems.Execute();
                systems.Execute();
                system.didExecute.should_be(1);

                system.didCleanup.should_be(0);
                systems.Cleanup();
                system.didCleanup.should_be(1);

                system.didTearDown.should_be(0);
                systems.TearDown();
                system.didTearDown.should_be(1);
            };

            it["initializes, executes, cleans up and tears down systems recursively"] = () => {
                var system = createReactiveSystem(contexts);

                systems.Add(system);

                var parentSystems = new Systems();
                parentSystems.Add(systems);

                system.didInitialize.should_be(0);
                parentSystems.Initialize();
                system.didInitialize.should_be(1);

                system.didExecute.should_be(0);
                parentSystems.Execute();
                parentSystems.Execute();
                system.didExecute.should_be(1);

                system.didCleanup.should_be(0);
                parentSystems.Cleanup();
                system.didCleanup.should_be(1);

                system.didTearDown.should_be(0);
                parentSystems.TearDown();
                system.didTearDown.should_be(1);
            };

            it["clears reactive systems"] = () => {
                var system = createReactiveSystem(contexts);

                systems.Add(system);

                systems.Initialize();
                system.didInitialize.should_be(1);

                systems.ClearReactiveSystems();
                systems.Execute();
                system.didExecute.should_be(0);
            };

            it["clears reactive systems recursively"] = () => {
                var system = createReactiveSystem(contexts);
                systems.Add(system);

                var parentSystems = new Systems();
                parentSystems.Add(systems);

                parentSystems.Initialize();
                system.didInitialize.should_be(1);

                parentSystems.ClearReactiveSystems();
                parentSystems.Execute();
                system.didExecute.should_be(0);
            };

            it["deactivates reactive systems"] = () => {
                var system = createReactiveSystem(contexts);

                systems.Add(system);

                systems.Initialize();
                system.didInitialize.should_be(1);

                systems.DeactivateReactiveSystems();
                systems.Execute();
                system.didExecute.should_be(0);
            };

            it["deactivates reactive systems recursively"] = () => {
                var system = createReactiveSystem(contexts);
                systems.Add(system);

                var parentSystems = new Systems();
                parentSystems.Add(systems);

                parentSystems.Initialize();
                system.didInitialize.should_be(1);

                parentSystems.DeactivateReactiveSystems();
                parentSystems.Execute();
                system.didExecute.should_be(0);
            };

            it["activates reactive systems"] = () => {
                var system = createReactiveSystem(contexts);

                systems.Add(system);

                systems.Initialize();
                system.didInitialize.should_be(1);

                systems.DeactivateReactiveSystems();
                systems.ActivateReactiveSystems();
                systems.Execute();
                system.didExecute.should_be(0);

                contexts.test.CreateEntity().AddComponentA();
                systems.Execute();

                system.didExecute.should_be(1);
            };

            it["activates reactive systems recursively"] = () => {
                var system = createReactiveSystem(contexts);
                systems.Add(system);

                var parentSystems = new Systems();
                parentSystems.Add(systems);

                parentSystems.Initialize();
                system.didInitialize.should_be(1);

                parentSystems.DeactivateReactiveSystems();
                parentSystems.ActivateReactiveSystems();
                parentSystems.Execute();
                system.didExecute.should_be(0);

                contexts.test.CreateEntity().AddComponentA();
                systems.Execute();

                system.didExecute.should_be(1);
            };
        };
    }
Exemplo n.º 21
0
 private void Start()
 {
     Random.seed = 42;
     systems = ActiveSystems.GetSystems(Pools.pool);
     systems.Initialize();
 }