public static void drawAggro(EntityWorld entityWorld, int entity, int targetEntity) { if (entityWorld.hasAllComponents(entity, AutoAttackComponent.class, IsAliveComponent.class)) { if (entityWorld.hasComponent(entity, AttackMoveComponent.class) || (!entityWorld.hasComponent(entity, MovementComponent.class))) { entityWorld.setComponent(entity, new AggroTargetComponent(targetEntity)); } } }
@Override public void update(EntityWorld entityWorld, float deltaSeconds) { ComponentMapObserver observer = entityWorld.requestObserver(this, TriggeredEffectComponent.class); for (int entity : observer.getRemoved().getEntitiesWithAll(TriggeredEffectComponent.class)) { int effectEntity = observer .getRemoved() .getComponent(entity, TriggeredEffectComponent.class) .getEffectEntity(); CleanupUtil.tryCleanupEntity(entityWorld, effectEntity); } for (int effectTriggerEntity : entityWorld.getEntitiesWithAll(TriggerSourceComponent.class)) { int sourceEntity = entityWorld .getComponent(effectTriggerEntity, TriggerSourceComponent.class) .getSourceEntity(); if (!entityWorld.hasEntity(sourceEntity)) { int effectEntity = entityWorld .getComponent(effectTriggerEntity, TriggeredEffectComponent.class) .getEffectEntity(); CleanupUtil.tryCleanupEntity(entityWorld, effectEntity); entityWorld.removeEntity(effectTriggerEntity); } } }
@Override public void update(EntityWorld entityWorld, float deltaSeconds) { ComponentMapObserver observer = entityWorld.requestObserver( this, AreaBuffComponent.class, AreaBuffTargetRulesComponent.class); for (int entity : observer.getRemoved().getEntitiesWithAll(AreaBuffComponent.class)) { int buffEntity = observer.getRemoved().getComponent(entity, AreaBuffComponent.class).getBuffEntity(); CleanupUtil.tryCleanupEntity(entityWorld, buffEntity); } for (int entity : observer.getRemoved().getEntitiesWithAll(AreaBuffTargetRulesComponent.class)) { int targetRulesEntity = observer .getRemoved() .getComponent(entity, AreaBuffTargetRulesComponent.class) .getTargetRulesEntity(); CleanupUtil.tryCleanupEntity(entityWorld, targetRulesEntity); } }
public static void tryDrawAggro(EntityWorld entityWorld, int entity, int targetEntity) { if (!entityWorld.hasComponent(entity, AggroTargetComponent.class)) { drawAggro(entityWorld, entity, targetEntity); } }