当前位置: 首页>>代码示例>>C#>>正文


C# EntityWorld.InitializeAll方法代码示例

本文整理汇总了C#中Artemis.EntityWorld.InitializeAll方法的典型用法代码示例。如果您正苦于以下问题:C# EntityWorld.InitializeAll方法的具体用法?C# EntityWorld.InitializeAll怎么用?C# EntityWorld.InitializeAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Artemis.EntityWorld的用法示例。


在下文中一共展示了EntityWorld.InitializeAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AttributesTestsMethod

        public void AttributesTestsMethod()
        {
            EntityWorld world = new EntityWorld();
            world.PoolCleanupDelay = 1;
            world.InitializeAll();

            Debug.Assert(world.SystemManager.Systems.Size == 2);

            Entity et = world.CreateEntity();
            var power = et.AddComponentFromPool<Power2>();
            power.POWER = 100;
            et.Refresh();

            Entity et1 = world.CreateEntityFromTemplate("teste");
            Debug.Assert(et1 != null);

            {
                world.Update(0, ExecutionType.UpdateSynchronous);
            }

            et.RemoveComponent<Power2>();
            et.Refresh();

            {
                world.Update(0, ExecutionType.UpdateSynchronous);
            }

            et.AddComponentFromPool<Power2>();
            et.GetComponent<Power2>().POWER = 100;
            et.Refresh();

            world.Update(0, ExecutionType.UpdateSynchronous);
        }
开发者ID:dackjaniels2001,项目名称:artemis_CSharp,代码行数:33,代码来源:GeneralTest.cs

示例2: Start

 void Start()
 {
     world = new EntityWorld (false, true, true);
     world.InitializeAll (true);
     Entity e = world.CreateEntityFromTemplate ("Ship");
     GameObject obj = new GameObject("Ship");
     PhysicsRelay relay = obj.AddComponent<PhysicsRelay>();
     relay.SetEntity (e);
 }
开发者ID:coryleeio,项目名称:SPClient,代码行数:9,代码来源:ECSTest.cs

示例3: Initialize

        public void Initialize()
        {
            _networkAgent = new NetworkAgent(AgentRole.Server, "Umbra");
            _networkAgent.OnPlayerConnect += OnPlayerConnect;
            _networkAgent.OnPlayerDisconnect += OnPlayerDisconnect;

            EntitySystem.BlackBoard.SetEntry("NetworkAgent", _networkAgent);

            _entityWorld = new EntityWorld();
            _entityWorld.InitializeAll(new[] { GetType().Assembly });

            CrawEntityManager.Instance.Initialize(_entityWorld, new ServerEntityFactory(_entityWorld));
        }
开发者ID:jtuttle,项目名称:umbra-client,代码行数:13,代码来源:UmbraGameServer.cs

示例4: Initialize

        protected override void Initialize()
        {
            ConvertUnits.SetDisplayUnitToSimUnitRatio(16f);

            spriteBatch = new SpriteBatch(GraphicsDevice);
            entityWorld = new EntityWorld();

            EntitySystem.BlackBoard.SetEntry("ContentManager", this.Content);
            EntitySystem.BlackBoard.SetEntry("GraphicsDevice", this.GraphicsDevice);
            EntitySystem.BlackBoard.SetEntry("SpriteBatch", this.spriteBatch);

            entityWorld.InitializeAll(true);

            base.Initialize();
        }
开发者ID:AnotherProgrammingGroup,项目名称:Project-CS,代码行数:15,代码来源:SpaceZeldaGame.cs

示例5: DummyTests

        public void DummyTests()
        {
            EntityWorld world = new EntityWorld();
            SystemManager systemManager = world.SystemManager;
            DummyCommunicationSystem DummyCommunicationSystem = new DummyCommunicationSystem();
            systemManager.SetSystem(DummyCommunicationSystem, ExecutionType.UpdateSynchronous);
            world.InitializeAll(false);

            for (int i = 0; i < 100; i++)
            {
                Entity et = world.CreateEntity();
                et.AddComponent(new Health());
                et.GetComponent<Health>().HP += 100;
                et.Group = "teste";
                et.Refresh();
            }

            {
                Entity et = world.CreateEntity();
                et.Tag = "tag";
                et.AddComponent(new Health());
                et.GetComponent<Health>().HP += 100;
                et.Refresh();
            }

            {
                DateTime dt = DateTime.Now;
                world.Update(0);
                Console.WriteLine((DateTime.Now - dt).TotalMilliseconds);
            }

            Debug.Assert(world.TagManager.GetEntity("tag") != null);
            Debug.Assert(world.GroupManager.GetEntities("teste").Size == 100);
            Debug.Assert(world.EntityManager.ActiveEntitiesCount == 101);
            Debug.Assert(world.SystemManager.Systems.Size == 1);
        }
开发者ID:dackjaniels2001,项目名称:artemis_CSharp,代码行数:36,代码来源:GeneralTest.cs

示例6: Initialize

        protected override void Initialize()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            _netAgent = new NetworkAgent(AgentRole.Client, "Umbra");

            EntitySystem.BlackBoard.SetEntry("Game", this);
            EntitySystem.BlackBoard.SetEntry("ContentManager", Content);
            EntitySystem.BlackBoard.SetEntry("SpriteBatch", spriteBatch);
            EntitySystem.BlackBoard.SetEntry("GraphicsDevice", GraphicsDevice);
            EntitySystem.BlackBoard.SetEntry("ContentManager", Content);
            EntitySystem.BlackBoard.SetEntry("NetworkAgent", _netAgent);

            _entityWorld = new EntityWorld();

            // create camera
            Vector3 camPosition = new Vector3(0, 10, 5);
            Matrix camRotation = Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(-65.0f));
            float aspectRatio = (float)GraphicsDevice.Viewport.Width / GraphicsDevice.Viewport.Height;

            CameraComponent cameraComponent = new CameraComponent(camPosition, camRotation, aspectRatio);

            Entity cameraEntity = _entityWorld.CreateEntity();
            cameraEntity.AddComponent(cameraComponent);

            EntitySystem.BlackBoard.SetEntry("Camera", cameraComponent);

            //// TEMP ////
            Map map = new Map(100, 100);
            Entity mapEntity = _entityWorld.CreateEntity();
            mapEntity.AddComponent(new TileMapComponent(map));

            EntitySystem.BlackBoard.SetEntry("Map", map);
            //// TEMP ////

            _entityWorld.InitializeAll(new[] { GetType().Assembly });

            CrawEntityManager.Instance.Initialize(_entityWorld, new ClientEntityFactory(_entityWorld));

            _netAgent.Connect("127.0.0.1");

            base.Initialize();
        }
开发者ID:jtuttle,项目名称:umbra-client,代码行数:43,代码来源:UmbraGameClient.cs

示例7: TestAttributes

        public void TestAttributes()
        {
            Debug.WriteLine("Initialize EntityWorld: ");
            EntityWorld entityWorld = new EntityWorld { PoolCleanupDelay = 1 };
            #if (!FULLDOTNET && !METRO) || CLIENTPROFILE
            entityWorld.InitializeAll(global::System.Reflection.Assembly.GetExecutingAssembly());
            #else
            entityWorld.InitializeAll(true);
            #endif
            Debug.WriteLine("OK");

            const int ExpectedNumberOfSystems = 2;
            int actualNumberOfSystems = entityWorld.SystemManager.Systems.Count;
            Assert.AreEqual(ExpectedNumberOfSystems, actualNumberOfSystems, "Number of initial systems does not fit.");
            Debug.WriteLine("Number of Systems: {0} OK", actualNumberOfSystems);

            Debug.WriteLine("Build up entity with component from pool manually: ");
            Entity entityWithPooledComponent = TestEntityFactory.CreateTestPowerEntityWithPooledComponent(entityWorld);
            Debug.WriteLine("OK");

            Debug.WriteLine("Build up entity from template: ");
            Entity entityFromTemplate = entityWorld.CreateEntityFromTemplate("test");
            Assert.IsNotNull(entityFromTemplate, "Entity from test template is null.");
            Debug.WriteLine("OK");

            entityWorld.Update();
            entityWorld.Draw();

            Debug.WriteLine("Remove component from entity: ");
            entityWithPooledComponent.RemoveComponent<TestPowerComponentPoolable>();

            entityWorld.Update();
            entityWorld.Draw();

            Assert.IsFalse(entityWithPooledComponent.HasComponent<TestPowerComponentPoolable>(), "Entity has still deleted component.");
            Debug.WriteLine("OK");

            Debug.WriteLine("Add component to entity: ");
            entityWithPooledComponent.AddComponentFromPool<TestPowerComponentPoolable>();
            entityWithPooledComponent.GetComponent<TestPowerComponentPoolable>().Power = 100;

            entityWorld.Update();
            entityWorld.Draw();

            Assert.IsTrue(entityWithPooledComponent.HasComponent<TestPowerComponentPoolable>(), "Could not add component to entity.");
            Debug.WriteLine("OK");
        }
开发者ID:GrafSeismo,项目名称:artemis_CSharp,代码行数:47,代码来源:TestGeneral.cs

示例8: Initialize

        internal void Initialize(D3D11Host host)
        {
            Services = new GameServiceContainer();

            ServiceLocator.Initialize(Services);

            Artemis.System.EntitySystem.BlackBoard.SetEntry("GraphicsDevice", host.GraphicsDevice);
            Artemis.System.EntitySystem.BlackBoard.SetEntry("ServiceProvider", Services);

            Services.AddService<IGraphicsDeviceService>(host);
            Services.AddService(host.GraphicsDevice);

            _mouse = new MouseService(host);
            Services.AddService<IMouseService>(_mouse);
            _mouse.ButtonDown += OnMouseButtonDown;
            _keyboard = new KeyboardService(host);
            Services.AddService<IKeyboardService>(_keyboard);
            _timer = new TimerService();
            Services.AddService<ITimerService>(_timer);
            Services.AddService(new FastSpriteBatch(host.GraphicsDevice));

            _timer.LastFrameUpdateTime = _gameTime;
            _timer.LastFrameRenderTime = _gameTime;

            SpriteBatch = new SpriteBatch(host.GraphicsDevice);
            Services.AddService(SpriteBatch);

            Content = new ContentManager(Services);
            Content.RootDirectory = Environment.CurrentDirectory;

            SpriteManager = new SpriteManagerService(Content);
            Services.AddService<ISpriteManagerService>(SpriteManager);

            SpriteManager.LoadSpriteSheet("Textures/Hulls.json");

            Host = host;
            World = new EntityWorld(false, false, false);
            int drawDepth = 0;
            World.CreateComponentPool<Transform>(200, 200);
            World.SystemManager.SetSystem(new GridRendererSystem(), Artemis.Manager.GameLoopType.Draw, drawDepth++);
            World.InitializeAll();
            World.CreateCamera(Constants.ActiveCameraTag, Host.GraphicsDevice);
            Emitter = new ParticleEmitterComponent();
        }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:44,代码来源:ParticleEditorViewModel.cs

示例9: Initialize

        protected override void Initialize()
        {
            // make root world and build to it
            RootWorld = new EntityWorld();
            RootWorld.InitializeAll(true);
            TTFactory.BuildTo(RootWorld);

            // make root screen and build to it
            RootScreen = new ScreenComp(false, 0, 0);
            TTFactory.BuildTo(RootScreen);

            // make the MainChannel and build to it
            MainChannel = TTFactory.CreateChannel(Color.CornflowerBlue);
            MainChannelScreen = MainChannel.GetComponent<WorldComp>().Screen;
            TTFactory.BuildTo(MainChannel);

            // the TTMusicEngine
            if (IsAudio)
            {
                AudioEngine = MusicEngine.GetInstance();
                AudioEngine.AudioPath = "Content";
                if (!AudioEngine.Initialize())
                    throw new Exception(AudioEngine.StatusMsg);
            }

            base.Initialize();
        }
开发者ID:IndiegameGarden,项目名称:TTengine,代码行数:27,代码来源:TTGame.cs

示例10: TestSimpleSystem

        public void TestSimpleSystem()
        {
            Debug.WriteLine("Initialize EntityWorld: ");
            EntityWorld entityWorld = new EntityWorld();
            entityWorld.SystemManager.SetSystem(new TestNormalEntityProcessingSystem1(), GameLoopType.Update);
            entityWorld.InitializeAll();
            Debug.WriteLine("OK");

            Entity entity1 = TestEntityFactory.CreateTestHealthEntity(entityWorld);
            Assert.IsNotNull(entity1);

            Entity entity2 = TestEntityFactory.CreateTestPowerEntity(entityWorld);
            Assert.IsNotNull(entity2);

            Stopwatch stopwatch = Stopwatch.StartNew();
            entityWorld.Update();
            entityWorld.Draw();
            stopwatch.Stop();
            #if DEBUG
            Debug.WriteLine("Processed update and draw with duration {0} for {1} elements", FastDateTime.ToString(stopwatch.Elapsed), entityWorld.EntityManager.EntitiesRequestedCount);
            #else
            Debug.WriteLine("Processed update and draw with duration {0} for {1} elements", FastDateTime.ToString(stopwatch.Elapsed), entityWorld.EntityManager.ActiveEntities.Count);
            #endif
            const float Expected1 = 90.0f;
            Assert.AreEqual(Expected1, entity1.GetComponent<TestHealthComponent>().Points);

            const float Expected2 = 100.0f;
            Assert.AreEqual(Expected2, entity2.GetComponent<TestHealthComponent>().Points);
            Assert.AreEqual(Expected2, entity2.GetComponent<TestPowerComponent>().Power);
        }
开发者ID:GrafSeismo,项目名称:artemis_CSharp,代码行数:30,代码来源:TestGeneral.cs

示例11: TestSystemCommunication

        public void TestSystemCommunication()
        {
            Debug.WriteLine("Initialize EntityWorld: ");
            EntitySystem.BlackBoard.SetEntry("Damage", 5);
            EntityWorld entityWorld = new EntityWorld();
            entityWorld.SystemManager.SetSystem(new TestCommunicationSystem(), GameLoopType.Update);
            entityWorld.InitializeAll();
            Debug.WriteLine("OK");

            Debug.WriteLine("Fill EntityWorld with " + Load + " entities: ");
            List<Entity> entities = new List<Entity>();
            for (int index = Load; index >= 0; --index)
            {
                Entity entity = TestEntityFactory.CreateTestHealthEntity(entityWorld);
                entities.Add(entity);
            }

            Debug.WriteLine("OK");

            Stopwatch stopwatch = Stopwatch.StartNew();
            entityWorld.Update();
            entityWorld.Draw();
            stopwatch.Stop();
            Debug.WriteLine("Update 1 duration: {0}", FastDateTime.ToString(stopwatch.Elapsed));

            EntitySystem.BlackBoard.SetEntry("Damage", 10);

            stopwatch.Restart();
            entityWorld.Update();
            entityWorld.Draw();
            stopwatch.Stop();
            Debug.WriteLine("Update 2 duration: {0}", FastDateTime.ToString(stopwatch.Elapsed));

            Debug.WriteLine("Test entities: ");
            const float Expected = 85.0f;
            foreach (Entity item in entities)
            {
                Assert.AreEqual(Expected, item.GetComponent<TestHealthComponent>().Points);
            }

            Debug.WriteLine("OK");
            EntitySystem.BlackBoard.RemoveEntry("Damage");
        }
开发者ID:GrafSeismo,项目名称:artemis_CSharp,代码行数:43,代码来源:TestGeneral.cs

示例12: SecondMostSimpleSystemEverTest

        public void SecondMostSimpleSystemEverTest()
        {
            EntityWorld world = new EntityWorld();
            world.InitializeAll(true);

            Entity et = world.CreateEntity();
            et.AddComponent(new Health());
            et.GetComponent<Health>().HP = 100;
            et.Refresh();

            Entity et1 = world.CreateEntity();
            et1.AddComponent(new Power());
            et1.GetComponent<Power>().POWER = 100;
            et1.Refresh();

            {
                world.Update(0);
            }

            ///two systems runnning
            ///each remove 10 HP
            Debug.Assert(et.GetComponent<Health>().HP == 80);
            Debug.Assert(et1.GetComponent<Power>().POWER == 90);
        }
开发者ID:dackjaniels2001,项目名称:artemis_CSharp,代码行数:24,代码来源:GeneralTest.cs

示例13: TestMultipleSystems

        public void TestMultipleSystems()
        {
            Debug.WriteLine("Initialize EntityWorld: ");
            HealthBag.Clear();
            ComponentPool.Clear();

            HealthBag.Add(new TestHealthComponent());
            HealthBag.Add(new TestHealthComponent());
            ComponentPool.Add(typeof(TestHealthComponent), HealthBag);

            EntityWorld entityWorld = new EntityWorld();
            entityWorld.EntityManager.RemovedComponentEvent += RemovedComponent;
            entityWorld.EntityManager.RemovedEntityEvent += RemovedEntity;
            entityWorld.SystemManager.SetSystem(new TestRenderHealthBarSingleSystem(), GameLoopType.Update);
            entityWorld.SystemManager.SetSystem(new TestEntityProcessingSystem1(), GameLoopType.Update);
            entityWorld.SystemManager.SetSystem(new TestEntityProcessingSystem2(), GameLoopType.Update);
            entityWorld.SystemManager.SetSystem(new TestEntityProcessingSystem3(), GameLoopType.Update);
            entityWorld.InitializeAll();
            Debug.WriteLine("OK");

            Debug.WriteLine("Fill EntityWorld with " + Load + " entities: ");
            List<Entity> entities = new List<Entity>();
            for (int index = Load - 1; index >= 0; --index)
            {
                Entity entity = TestEntityFactory.CreateTestHealthEntity(entityWorld);
                entities.Add(entity);
            }

            Debug.WriteLine("OK");

            const int Passes = 3;
            Stopwatch stopwatch = Stopwatch.StartNew();
            for (int index = 0; index < Passes; ++index)
            {
                entityWorld.Update();
                entityWorld.Draw();
            }

            stopwatch.Stop();
            Debug.WriteLine("Update (" + Passes + " passes) duration: {0}", FastDateTime.ToString(stopwatch.Elapsed));

            /*
            int df = 0;
            foreach (Entity entity in entities)
            {
                if (Math.Abs(entity.GetComponent<TestHealthComponent>().Points - 90) < float.Epsilon)
                {
                    df++;
                }
                else
                {
                    Debug.WriteLine("Error " + df);
                }
            }
            */
        }
开发者ID:GrafSeismo,项目名称:artemis_CSharp,代码行数:56,代码来源:TestGeneral.cs

示例14: Initialize

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font = Content.Load<SpriteFont>("myFont");

            world = new EntityWorld();

            EntitySystem.BlackBoard.SetEntry<ContentManager>("ContentManager", Content);
            EntitySystem.BlackBoard.SetEntry<GraphicsDevice>("GraphicsDevice", GraphicsDevice);
            EntitySystem.BlackBoard.SetEntry<SpriteBatch>("SpriteBatch", spriteBatch);
            EntitySystem.BlackBoard.SetEntry<SpriteFont>("SpriteFont", font);
            EntitySystem.BlackBoard.SetEntry<int>("EnemyInterval", 500);

            world.InitializeAll();

            InitPlayerShip();
            InitEnemyShips();

            base.Initialize();
        }
开发者ID:dackjaniels2001,项目名称:starwarrior_CSharp,代码行数:27,代码来源:Game1.cs

示例15: QueueSystemTeste

        public void QueueSystemTeste()
        {
            EntityWorld world = new EntityWorld();
            SystemManager systemManager = world.SystemManager;
            QueueSystemTest QueueSystemTest = new ArtemisTest.QueueSystemTest();
            QueueSystemTest QueueSystemTest2 = new ArtemisTest.QueueSystemTest();
            systemManager.SetSystem(QueueSystemTest, ExecutionType.UpdateAsynchronous);
            systemManager.SetSystem(QueueSystemTest2, ExecutionType.UpdateAsynchronous);

            QueueSystemTest2 QueueSystemTestteste = new ArtemisTest.QueueSystemTest2();
            systemManager.SetSystem(QueueSystemTestteste, ExecutionType.UpdateAsynchronous);

            world.InitializeAll(false);

            QueueSystemTest.SetQueueProcessingLimit(20, QueueSystemTest.Id);
            Debug.Assert(QueueSystemTest.GetQueueProcessingLimit(QueueSystemTest.Id) == QueueSystemTest.GetQueueProcessingLimit(QueueSystemTest2.Id));

            Debug.Assert(QueueSystemTest.GetQueueProcessingLimit(QueueSystemTestteste.Id) != QueueSystemTest.GetQueueProcessingLimit(QueueSystemTest2.Id));

            QueueSystemTest.SetQueueProcessingLimit(1000, QueueSystemTest.Id);
            QueueSystemTest.SetQueueProcessingLimit(2000, QueueSystemTestteste.Id);

            List<Entity> l = new List<Entity>();
            for (int i = 0; i < 1000000; i++)
            {
                Entity et = world.CreateEntity();
                et.AddComponent(new Health());
                et.GetComponent<Health>().HP = 100;
                QueueSystemTest.AddToQueue(et, QueueSystemTest.Id);
                l.Add(et);
            }

            List<Entity> l2 = new List<Entity>();
            for (int i = 0; i < 1000000; i++)
            {
                Entity et = world.CreateEntity();
                et.AddComponent(new Health());
                et.GetComponent<Health>().HP = 100;
                QueueSystemTest.AddToQueue(et, QueueSystemTestteste.Id);
                l2.Add(et);
            }

            Console.WriteLine("Start");
            while (QueueSystemTest.QueueCount(QueueSystemTest.Id) > 0 || QueueSystemTest.QueueCount(QueueSystemTestteste.Id) > 0)
            {
                DateTime dt = DateTime.Now;
                world.Update(0, ExecutionType.UpdateAsynchronous);
                Console.WriteLine("Count: " + QueueSystemTest.QueueCount(QueueSystemTest.Id));
                Console.WriteLine("Time: " + (DateTime.Now - dt).TotalMilliseconds);

            }
            Console.WriteLine("End");

            foreach (var item in l)
            {
                Debug.Assert(item.GetComponent<Health>().HP == 90);
            }
            foreach (var item in l2)
            {
                Debug.Assert(item.GetComponent<Health>().HP == 80);
            }
        }
开发者ID:dackjaniels2001,项目名称:artemis_CSharp,代码行数:62,代码来源:GeneralTest.cs


注:本文中的Artemis.EntityWorld.InitializeAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。