This commit is contained in:
Walter Julius Hennecke 2014-03-09 22:44:04 +01:00
parent a24940bed2
commit b9f90d4305
1 changed files with 151 additions and 161 deletions

View File

@ -38,14 +38,12 @@ class SelectBestWeapon;
// //
// Method of Use: Called From State Machine // Method of Use: Called From State Machine
//-------------------------------------------------------------- //--------------------------------------------------------------
class SelectBestWeapon : public Behavior class SelectBestWeapon : public Behavior {
{ public:
//------------------------------------ //------------------------------------
// States // States
//------------------------------------ //------------------------------------
public: typedef enum {
typedef enum
{
SBW_SELECT_WEAPON, SBW_SELECT_WEAPON,
SBW_PUT_AWAY_CURRENT_WEAPON, SBW_PUT_AWAY_CURRENT_WEAPON,
SBW_PULL_OUT_NEW_WEAPON, SBW_PULL_OUT_NEW_WEAPON,
@ -54,16 +52,31 @@ class SelectBestWeapon : public Behavior
SBW_FAILED SBW_FAILED
} selectBestWeaponStates_t; } selectBestWeaponStates_t;
//------------------------------------ //-------------------------------------
// Parameters // Public Interface
//------------------------------------ //-------------------------------------
private: CLASS_PROTOTYPE(SelectBestWeapon);
EntityPtr _currentEnemy;
SelectBestWeapon();
~SelectBestWeapon();
void SetArgs(Event* ev);
void AnimDone(Event* ev);
void PostureDone(Event* ev);
void Begin(Actor& self);
BehaviorReturnCode_t Evaluate(Actor& self);
void End(Actor& self);
void SetCurrentEnemy(Entity* enemy);
static bool CanExecute(Actor& self);
virtual void Archive(Archiver& arc);
protected:
//------------------------------------- //-------------------------------------
// Internal Functionality // Internal Functionality
//------------------------------------- //-------------------------------------
protected:
void transitionToState(selectBestWeaponStates_t state); void transitionToState(selectBestWeaponStates_t state);
void setInternalState(selectBestWeaponStates_t state, const str& stateName); void setInternalState(selectBestWeaponStates_t state, const str& stateName);
void init(Actor& self); void init(Actor& self);
@ -85,40 +98,19 @@ class SelectBestWeapon : public Behavior
BehaviorReturnCode_t evaluateStateReadyNewWeapon(); BehaviorReturnCode_t evaluateStateReadyNewWeapon();
void failureStateReadyNewWeapon(const str& failureReason); void failureStateReadyNewWeapon(const str& failureReason);
//------------------------------------- private:
// Public Interface //------------------------------------
//------------------------------------- // Parameters
public: //------------------------------------
CLASS_PROTOTYPE( SelectBestWeapon ); EntityPtr _currentEnemy;
SelectBestWeapon();
~SelectBestWeapon();
void SetArgs ( Event *ev );
void AnimDone ( Event *ev );
void PostureDone ( Event *ev );
void Begin ( Actor &self );
BehaviorReturnCode_t Evaluate ( Actor &self );
void End ( Actor &self );
void SetCurrentEnemy ( Entity* enemy );
static bool CanExecute( Actor &self );
virtual void Archive ( Archiver &arc );
//------------------------------------- //-------------------------------------
// Components // Components
//------------------------------------- //-------------------------------------
private:
//------------------------------------- //-------------------------------------
// Member Variables // Member Variables
//------------------------------------- //-------------------------------------
private:
selectBestWeaponStates_t _state; selectBestWeaponStates_t _state;
Actor* _self; Actor* _self;
WeaponPtr _bestWeapon; WeaponPtr _bestWeapon;
@ -128,13 +120,11 @@ class SelectBestWeapon : public Behavior
}; };
inline void SelectBestWeapon::SetCurrentEnemy( Entity *enemy ) inline void SelectBestWeapon::SetCurrentEnemy(Entity* enemy) {
{
_currentEnemy = enemy; _currentEnemy = enemy;
} }
inline void SelectBestWeapon::Archive( Archiver &arc ) inline void SelectBestWeapon::Archive(Archiver& arc) {
{
Behavior::Archive(arc); Behavior::Archive(arc);
// //