public void Setup() { _defaultWorld = new DefaultWorld(EntityCount); _defaultEntitySet = _defaultWorld.GetEntities().With <DefaultComponent>().AsSet(); _defaultRunner = new DefaultParallelRunner(Environment.ProcessorCount); _defaultSystem = new DefaultEcsSystem(_defaultWorld); _defaultMultiSystem = new DefaultEcsSystem(_defaultWorld, _defaultRunner); _defaultEntityComponentSystem = new DefaultEcsEntityComponentSystem(_defaultWorld); _defaultMultiEntityComponentSystem = new DefaultEcsEntityComponentSystem(_defaultWorld, _defaultRunner); _defaultComponentSystem = new DefaultEcsComponentSystem(_defaultWorld); _defaultComponentMultiSystem = new DefaultEcsComponentSystem(_defaultWorld, _defaultRunner); _entitasWorld = new Context <EntitasEntity>(1, () => new EntitasEntity()); _entitasSystem = new EntitasSystem(_entitasWorld); _entitasMultiSystem = new EntitasSystem(_entitasWorld, Environment.ProcessorCount); _monoWorld = new WorldBuilder().AddSystem(new MonoSystem()).Build(); _time = new GameTime(); for (int i = 0; i < EntityCount; ++i) { DefaultEntity defaultEntity = _defaultWorld.CreateEntity(); defaultEntity.Set <DefaultComponent>(); EntitasEntity entitasEntity = _entitasWorld.CreateEntity(); entitasEntity.AddComponent(0, new EntitasComponent()); MonoEntity monoEntity = _monoWorld.CreateEntity(); monoEntity.Attach(new MonoComponent()); } }
public override void Update(GameTime gameTime) { if (ElapsedTime == FireSpawnInterval) { foreach (int entityID in ActiveEntities) { MonoGame.Extended.Entities.Entity placeholder = Game1._world.GetEntity(entityID); ECSComponents.StatusComponent capturedStatus = placeholder.Get <ECSComponents.StatusComponent>(); // get the status component of the entity if (capturedStatus.Type == Game1.EntityType.Lightning) // if the entity is a Lightining Disaster { // call SpawnFire Here ECSComponents.PositionComponent capturedPosition = placeholder.Get <ECSComponents.PositionComponent>(); int spawnX = (int)capturedPosition.XCoor; int spawnY = (int)capturedPosition.YCoor; SpawnFire(spawnX, spawnY); } else if (capturedStatus.Type == Game1.EntityType.Fire) // this is where Propagate will be called { Propagate(entityID); } } ElapsedTime = 0; return; } else { ElapsedTime++; return; } }
public void Setup() { _defaultWorld = new DefaultWorld(EntityCount); _defaultEntitySet = _defaultWorld.GetEntities().With <DefaultComponent>().AsSet(); _defaultRunner = new DefaultParallelRunner(Environment.ProcessorCount); _defaultSystem = new DefaultEcsSystem(_defaultWorld); _defaultMultiSystem = new DefaultEcsSystem(_defaultWorld, _defaultRunner); _defaultEntityComponentSystem = new DefaultEcsEntityComponentSystem(_defaultWorld); _defaultMultiEntityComponentSystem = new DefaultEcsEntityComponentSystem(_defaultWorld, _defaultRunner); _defaultComponentSystem = new DefaultEcsComponentSystem(_defaultWorld); _defaultComponentMultiSystem = new DefaultEcsComponentSystem(_defaultWorld, _defaultRunner); _defaultGeneratorSystem = new DefaultEcsGeneratorSystem(_defaultWorld); _defaultGeneratorMultiSystem = new DefaultEcsGeneratorSystem(_defaultWorld, _defaultRunner); _entitasWorld = new Context <EntitasEntity>(1, () => new EntitasEntity()); _entitasSystem = new EntitasSystem(_entitasWorld); _entitasMultiSystem = new EntitasSystem(_entitasWorld, Environment.ProcessorCount); _monoWorld = new WorldBuilder().AddSystem(new MonoSystem()).Build(); _time = new GameTime(); _leoWorld = new LeoWorld(); _leoSystem = new LeoSystem(); _leoSystems = new LeoSystems(_leoWorld).Add(_leoSystem); _leoSystems.ProcessInjects().Init(); SimpleEntitiesSubmissionScheduler sveltoScheduler = new SimpleEntitiesSubmissionScheduler(); _sveltoWorld = new EnginesRoot(sveltoScheduler); _sveltoSystem = new SveltoSystem(); _sveltoWorld.AddEngine(_sveltoSystem); IEntityFactory sveltoFactory = _sveltoWorld.GenerateEntityFactory(); for (int i = 0; i < EntityCount; ++i) { DefaultEntity defaultEntity = _defaultWorld.CreateEntity(); defaultEntity.Set <DefaultComponent>(); EntitasEntity entitasEntity = _entitasWorld.CreateEntity(); entitasEntity.AddComponent(0, new EntitasComponent()); MonoEntity monoEntity = _monoWorld.CreateEntity(); monoEntity.Attach(new MonoComponent()); LeoEntity leoEntity = _leoWorld.NewEntity(); leoEntity.Get <LeoComponent>(); sveltoFactory.BuildEntity <SveltoEntity>((uint)i, _sveltoGroup); } sveltoScheduler.SubmitEntities(); }