Ejemplo n.º 1
0
void Virus::updateAI() {
  if (!data) {
    return;
  }

  if (!attackCooldown) {
    DamageInfo damage = virusData->getDamageInfo();

    VirusFilter targetFilter;
    targetFilter.setOwnerFaction(owner);
    targetFilter.setPosition(position);
    std::vector<Virus *> *targets = targetFilter.filter(data->nearbyEntities,
							damage.getRange());
    
    if (targets->size() > 0) {
      Entity *antibody = new Antibody(damage, position, (*targets)[0], frame);
      
      map->addEntity(antibody);
      
      attackCooldown = damage.getDamageCooldown();
    }

    delete targets;
  }

  if (state == VIRUSSTATE_IDLE) {
    executeCurrentCommand();
  }

  if (currentPath.empty()) {
    state = VIRUSSTATE_IDLE;
  } else {
    state = VIRUSSTATE_MOVING;
  }
}