BWAPI
|
00001 #pragma once 00002 #include "../../../Common.h" 00003 #include "../../../PersistentUnitGroup.h" 00004 #include "IBehaviorState.h" 00005 #include <BWAPI.h> 00006 00007 class ArbitratorUnitData; 00008 00012 class LowLevelAction 00013 { 00014 public: 00019 LowLevelAction(IBehaviorState& state) 00020 : m_state(state) 00021 { 00022 } 00023 00024 virtual ~LowLevelAction() {} 00025 00029 virtual std::string getDescription() const = 0; 00030 00036 virtual bool execute(BWAPI::Unit* unit) const = 0; 00037 00043 bool execute(const PersistentUnitGroup* group) const 00044 { 00045 bool result = true; 00046 for (PersistentUnitGroup::const_iterator it = group->begin(); 00047 it != group->end(); 00048 ++it) 00049 { 00050 result = execute(*it) && result; 00051 } 00052 return result; 00053 } 00054 00055 // 00056 // At the moment an action is considered terminated when the issuing behavior changes state. 00057 // This could be implemented differently, i.e. each action keeps a list of subscribers 00058 // and each behavior state is responsible for terminating its actions. 00059 // 00060 00061 typedef IBehaviorState::OnStateExit OnActionEnded; 00062 OnActionEnded& getActionEndedEvent() const { return m_state.getStateExitEvent(); } 00063 00064 protected: 00068 IBehaviorState& m_state; 00069 };