BWAPI
SPAR/AIModule/SparAIModule/DecisionMaking/Layer1Reactive/FSM/Conditions/IsAttacking.h
Go to the documentation of this file.
00001 #pragma once
00002 #include "../../../../Utils/FSM/Condition.h"
00003 
00007 class IsAttacking : public Condition
00008 {
00009 public:
00010   IsAttacking(BWAPI::Unit* unit): m_unit(unit) {}
00011   bool evaluate() const
00012   {
00013     BWAPI::Unit* target = m_unit->getOrderTarget();
00014     return target != NULL && target->getPlayer()->isEnemy(BWAPI::Broodwar->self());
00015   }
00016 private:
00017   BWAPI::Unit* m_unit;
00018 };
00019 
00023 class GroupIsAttacking : public Condition
00024 {
00025 public:
00026   GroupIsAttacking(const PersistentUnitGroup* group): m_group(group) {}
00027   bool evaluate() const
00028   {
00029     for(PersistentUnitGroup::const_iterator it=m_group->begin(); it != m_group->end(); ++it)
00030     {
00031       BWAPI::Unit* target = (*it)->getOrderTarget();
00032       if(target != NULL && target->getPlayer()->isEnemy(BWAPI::Broodwar->self()))
00033         return true;
00034     }
00035     return false;
00036   }
00037 private:
00038   const PersistentUnitGroup* m_group;
00039 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines