コード例 #1
0
ファイル: AggroUtil.java プロジェクト: destroflyer/amara
 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));
     }
   }
 }
コード例 #2
0
 public static int loadTemplate(String template) {
   Integer entity = cachedEntities.get(template);
   if (entity == null) {
     entity = entityWorld.createEntity();
     EntityTemplate.loadTemplate(entityWorld, entity, template);
     cachedEntities.put(template, entity);
   }
   return entity;
 }
コード例 #3
0
 @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);
     }
   }
 }
コード例 #4
0
 @Override
 public void execute(
     String optionString, EntityWorld entityWorld, Game game, GamePlayer gamePlayer) {
   try {
     String[] parameters = optionString.split(" ");
     if (parameters.length == 2) {
       float initialDuration = Float.parseFloat(parameters[0]);
       float deltaDurationPerTime = Float.parseFloat(parameters[1]);
       if ((initialDuration >= 0) && (deltaDurationPerTime >= 0)) {
         int playerDeathRulesEntity =
             entityWorld
                 .getComponent(game.getMap().getEntity(), PlayerDeathRulesComponent.class)
                 .getRulesEntity();
         entityWorld.setComponent(
             playerDeathRulesEntity,
             new RespawnTimerComponent(initialDuration, deltaDurationPerTime));
       } else {
         setResponseMessage("No negative death timers allowed");
       }
     }
   } catch (NumberFormatException ex) {
   }
 }
コード例 #5
0
 @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);
   }
 }
コード例 #6
0
ファイル: AggroUtil.java プロジェクト: destroflyer/amara
 public static void tryDrawAggro(EntityWorld entityWorld, int entity, int targetEntity) {
   if (!entityWorld.hasComponent(entity, AggroTargetComponent.class)) {
     drawAggro(entityWorld, entity, targetEntity);
   }
 }
コード例 #7
0
 public static EntityWrapper loadTemplateWrapped(String template) {
   return entityWorld.getWrapped(loadTemplate(template));
 }