@Override
  public void activateAction(Agent agent, WorldState state) {
    int count = Game.getInstance().self().completedUnitCount(UnitType.TERRAN_BARRACKS);
    WorkingMemoryFact[] needFacts =
        agent.getWorkingMemory().getFacts(StarMemoryFactType.NEED_TYPE, null);
    if (needFacts.length > 0) {
      for (WorkingMemoryFact fact : needFacts) {
        StarMemoryFact starFact = (StarMemoryFact) fact;
        if (starFact.needType.equals(UnitType.TERRAN_FIREBAT)) {
          if (starFact.needTypeCount > 0) {
            count = starFact.needTypeCount;
          } else {
            Logger.Debug("TrainFirebat:\tNeed Firebat without count!\n", 1);
            // count = Game.getInstance().self().completedUnitCount(UnitType.TERRAN_BARRACKS);
          }
        }
      }
    }

    StarBlackboard bb = (StarBlackboard) ((StarPlanner) agent).getBlackBoard();
    order = bb.addToTrainingQueue(UnitUtils.Type.TERRAN_FIREBAT, count);
    order = bb.addToTrainingQueue(UnitUtils.Type.TERRAN_FIREBAT, count);
    order = bb.addToTrainingQueue(UnitUtils.Type.TERRAN_MEDIC, count);
  }
 @Override
 public void deactivateAction(Agent agent) {
   if (!order.status.equals(OrderStatus.Ended))
     ((StarBlackboard) agent.getBlackBoard()).trainingQueue.remove(order);
 }