public void TestAspectOneMultiple() { Aspect aspect = Aspect.One(typeof(TestPowerComponent), typeof(TestPowerComponentPoolable)); EntityWorld entityWorld = new EntityWorld(); Entity entity; entity = entityWorld.CreateEntity(); Assert.IsFalse(aspect.Interests(entity), "Entity without components must NOT be subject to \"Powered by any means\" Aspect"); entity = entityWorld.CreateEntity(); entity.AddComponent(new TestHealthComponent()); Assert.IsFalse(aspect.Interests(entity), "Entity with {TestHealthComponent} must NOT be subject to \"Powered by any means\" Aspect"); entity = entityWorld.CreateEntity(); entity.AddComponent(new TestPowerComponent()); Assert.IsTrue(aspect.Interests(entity), "Entity with {TestPowerComponent} must be subject to \"Powered by any means\" Aspect"); entity = entityWorld.CreateEntity(); entity.AddComponent(new TestPowerComponentPoolable()); Assert.IsTrue(aspect.Interests(entity), "Entity with {TestPowerComponentPoolable} must be subject to \"Powered by any means\" Aspect"); entity = entityWorld.CreateEntity(); entity.AddComponent(new TestHealthComponent()); entity.AddComponent(new TestPowerComponent()); Assert.IsTrue(aspect.Interests(entity), "Entity with {TestHealthComponent, TestPowerComponent} must be subject to \"Powered by any means\" Aspect"); entity = entityWorld.CreateEntity(); entity.AddComponent(new TestHealthComponent()); entity.AddComponent(new TestPowerComponent()); entity.AddComponent(new TestPowerComponentPoolable()); Assert.IsTrue(aspect.Interests(entity), "Entity with {TestHealthComponent, TestPowerComponent, TestPowerComponentPoolable} must be subject to \"Powered by any means\" Aspect"); }
public void IsInterestedInJustOneComponent() { var oneAspect = Aspect .One(typeof(DummyComponent)) .Build(_componentManager); Assert.True(oneAspect.IsInterested(_entityA)); Assert.False(oneAspect.IsInterested(_entityB)); }
public void IsInterestedInEitherOneOfTheComponents() { var eitherOneAspect = Aspect .One(typeof(Transform2), typeof(DummyComponent)) .Build(_componentManager); Assert.True(eitherOneAspect.IsInterested(_entityA)); Assert.True(eitherOneAspect.IsInterested(_entityB)); }
public override void Enchant(Entity enchantment, EntityWorld entityWorld) { foreach (Entity e in entityWorld.EntityManager.GetEntities(Aspect.One(typeof(Damage)))) { if (e.GetComponent <Team>().team == enchantment.GetComponent <Team>().team) { e.GetComponent <Damage>().currentDamage = e.GetComponent <Damage>().damage + 1; } } }
public ViewportRenderSystem(GraphicsDevice graphicsDevice) : base(Aspect.One(typeof(LoadedModelComponent), typeof(PrimitiveComponent)).All(typeof(TransformComponent))) { _graphicsDevice = graphicsDevice; _viewportRenderers = new [] { new ViewportRenderer(512, 512) }; }
public override void Cast(Entity caster, EntityWorld entityWorld) { LOGGER.Debug("FireLance"); foreach (Entity entity in entityWorld.EntityManager.GetEntities(Aspect.One(typeof(Health)))) { LOGGER.Debug(entity.Id); if (entity.GetComponent <Team>().team != caster.GetComponent <Team>().team) { if (Math.Abs(entity.GetComponent <Position>().position.Y - caster.GetComponent <Position>().position.Y) < 64) { entity.GetComponent <Health>().currentHealth -= 2; } } } base.Cast(caster, entityWorld); }
public override void Cast(Entity caster, EntityWorld entityWorld) { base.Cast(caster, entityWorld); foreach (Entity e in entityWorld.EntityManager.GetEntities(Aspect.One(typeof(Enchantment)))) { if (e.GetComponent <Team>().team == caster.GetComponent <Team>().team) { if (e.GetComponent <Enchantment>().enchantmentSlot != 1 || e.GetComponent <Enchantment>().enchantmentSlot != 3) { e.GetComponent <Enchantment>().enchantmentSlot++; } else { e.Delete(); } } } entity = entityWorld.CreateEntityFromTemplate(EnchantmentTemplate.Name); entity.GetComponent <Team>().team = caster.GetComponent <Team>().team; LOGGER.Debug(caster.GetComponent <Team>().team); if (entity.GetComponent <Team>().team == 1) { entity.GetComponent <Enchantment>().enchantmentSlot = 0; } else { entity.GetComponent <Enchantment>().enchantmentSlot = 2; } entity.GetComponent <Enchantment>().spellBookSlot = caster.GetComponent <SpellBook>().currentSpell; entity.GetComponent <Appearance>().Initialize("Images/FireCaster.xml"); }
public override void Cast(Entity caster, EntityWorld entityWorld) { LOGGER.Debug("FireBall"); Entity target; if (caster.Id == 1) { target = entityWorld.EntityManager.ActiveEntities[0]; } else if (caster.Id == 0) { target = entityWorld.EntityManager.ActiveEntities[1]; } else { throw new InvalidOperationException("The caster does not seem to be a player"); } foreach (Entity entity in entityWorld.EntityManager.GetEntities(Aspect.One(typeof(Health)))) { LOGGER.Debug(entity.Id); if (entity.GetComponent <Team>().team == target.GetComponent <Team>().team) { if (Math.Abs(entity.GetComponent <Position>().position.X - caster.GetComponent <Position>().position.X) < Math.Abs(target.GetComponent <Position>().position.X - caster.GetComponent <Position>().position.X)) { target = entity; } } } target.GetComponent <Health>().currentHealth -= 1; base.Cast(caster, entityWorld); }
public PhysicsMouseObjectDetectSystem(Simulation simulation) : base(Aspect.One(typeof(ActivePhysicsComponent), typeof(StaticPhysicsComponent))) { _simulation = simulation; }
public ModelRenderSystem(GraphicsDevice graphicsDevice) : base(Aspect.One(typeof(LoadedModelComponent), typeof(PrimitiveComponent)).All(typeof(TransformComponent))) { _graphicsDevice = graphicsDevice; }
public AiSystem() : base(Aspect.One(typeof(AiComponent))) { _l = new Logger("AiSystem"); }
public TurnSystem(Commander commander) : base(Aspect.One(typeof(TurnComponent))) { _commander = commander; }
public PlayerSystem() : base(Aspect.One(typeof(Player))) { }
public AISystem() : base(Aspect.One(typeof(AI), typeof(Input))) { }
public OverstepSystem() : base(Aspect.One(typeof(Input))) { }
// TODO: Maybe refactor all this mess? public RenderSystem(SpriteBatch spriteBatch) : base(Aspect.One(typeof(SpriteComponent), typeof(SpriteFontComponent))) { _spriteBatch = spriteBatch; }
public RenderSystem(Scene scene) : base(Aspect.One(typeof(Renderer))) { _scene = scene; }
public ActionSystem() : base(Aspect.One(typeof(ActionQueueComponent))) { _l = new Logger("ActionSystem"); }
public TurnSystem() : base(Aspect.One(typeof(TurnComponent))) { _l = new Logger("TurnSystem"); }
// TODO: Maybe refactor all this mess? public RenderSystem(SpriteBatch spriteBatch, GameContent content) : base(Aspect.One(typeof(SpriteComponent), typeof(SpriteFontComponent))) { _spriteBatch = spriteBatch; _content = content; }
public ABattleSystem() : base(Aspect.One(typeof(BattleComponent))) { _l = new Logger("BattleSystem"); }
public LightingRenderSystem(GraphicsDevice graphicsDevice) : base(Aspect.One(typeof(DirectionalLightComponent), typeof(PointLightComponent))) { _graphicsDevice = graphicsDevice; }
public PickupSystem() : base(Aspect.One(typeof(Input), typeof(Pickupable))) { }
public AiSystem() : base(Aspect.One(typeof(AiComponent))) { }
public PlayerControlSystem() : base(Aspect.One(typeof(PlayerComponent))) { }
public LifeTimeReductionSystem() : base(Aspect.One(typeof(LifeTimeComponent))) { }
/// <summary>Initializes a new instance of the <see cref="TestNormalEntityProcessingSystem2" /> class.</summary> public TestNormalEntityProcessingSystem2() : base(Aspect.One(typeof(TestPowerComponent), typeof(TestHealthComponent))) { }
public TextureRenderingSystem(SpriteBatch spriteBatch, OrthographicCamera camera) : base(Aspect.One(typeof(TextureComponent))) { _spriteBatch = spriteBatch; _camera = camera; }