Reformatting

This commit is contained in:
Walter Julius Hennecke 2014-03-09 02:04:09 +01:00
parent 21894316f9
commit 33680e8e7a

View file

@ -37,14 +37,12 @@ class CorridorCombatWithRangedWeapon;
//
// Method of Use: Called From State Machine
//--------------------------------------------------------------
class CorridorCombatWithRangedWeapon : public Behavior
{
class CorridorCombatWithRangedWeapon : public Behavior {
public:
//------------------------------------
// States
//------------------------------------
public:
typedef enum
{
typedef enum {
CORRIDORCOMBAT_WRW_FINDNODE,
CORRIDORCOMBAT_WRW_MOVETONODE,
CORRIDORCOMBAT_WRW_BACKPEDAL,
@ -61,10 +59,144 @@ class CorridorCombatWithRangedWeapon : public Behavior
CORRIDORCOMBAT_WRW_FAILED
} corridorCombatStates_t;
//-------------------------------------
// Public Interface
//-------------------------------------
CLASS_PROTOTYPE(CorridorCombatWithRangedWeapon);
CorridorCombatWithRangedWeapon();
~CorridorCombatWithRangedWeapon();
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 SetMovementAnim(const str& movementAnim) { _movementAnim = movementAnim; }
const str& GetMovementAnim() { return _movementAnim; }
void SetTorsoAnim(const str& torsoAnim) { _torsoAnim = torsoAnim; }
const str& GetTorsoAnim() { return _torsoAnim; }
void SetFireAnim(const str& fireAnim) { _fireAnim = fireAnim; }
const str& GetFireAnim() { return _fireAnim; }
void SetPreFireAnim(const str& preFireAnim) { _preFireAnim = preFireAnim; }
const str& GetPreFireAnim() { return _preFireAnim; }
void SetPostFireAnim(const str& postFireAnim) { _postFireAnim = postFireAnim; }
const str& GetPostFireAnim() { return _postFireAnim; }
void SetPostureChangeChance(float chance) { _postureChangeChance = chance; }
float GetPostureChangeChance() { return _postureChangeChance; }
void SetMaxDistance(float maxDistance) { _maxDistance = maxDistance; }
float GetMaxDistance() { return _maxDistance; }
void SetRetreatDistance(float retreatDistance) { _retreatDistance = retreatDistance; }
float GetRetreatDistance() { return _retreatDistance; }
void SetThreatDistance(float threatDistance) { _threatDistance = threatDistance; }
float GetThreatDistance() { return _threatDistance; }
void SetFireTimeMin(float fireTimeMin) { _fireTimeMin = fireTimeMin; }
float GetFireTimeMin() { return _fireTimeMin; }
void SetFireTimeMax(float fireTimeMax) { _fireTimeMax = fireTimeMax; }
float GetFireTimeMax() { return _fireTimeMax; }
void SetPauseTimeMin(float pauseTimeMin) { _pauseTimeMin = pauseTimeMin; }
float GetPauseTimeMin() { return _pauseTimeMin; }
void SetPauseTimeMax(float pauseTimeMax) { _pauseTimeMax = pauseTimeMax; }
float GetPauseTimeMax() { return _pauseTimeMax; }
virtual void Archive(Archiver& arc);
static bool CanExecute(float maxDistance, Actor& self);
protected:
//-------------------------------------
// Internal Functionality
//-------------------------------------
void transitionToState(corridorCombatStates_t state);
void setInternalState(corridorCombatStates_t state, const str &stateName);
void init(Actor &self);
void think();
void updateEnemy();
void setTorsoAnim();
bool checkShouldDuck();
bool checkShouldStand();
bool checkShouldRetreat();
void setupRotate();
BehaviorReturnCode_t evaluateRotate();
void setupStateFindNode();
BehaviorReturnCode_t evaluateStateFindNode();
void failureStateFindNode(const str& failureReason);
void setupStateMoveToNode();
BehaviorReturnCode_t evaluateStateMoveToNode();
void failureStateMoveToNode(const str& failureReason);
void setupStateBackPedal();
BehaviorReturnCode_t evaluateStateBackPedal();
void failureStateBackPedal(const str& failureReason);
void setupStateFindBetterNode();
BehaviorReturnCode_t evaluateStateFindBetterNode();
void failureStateFindBetterNode(const str& failureReason);
void setupStateMoveToBetterNode();
BehaviorReturnCode_t evaluateStateMoveToBetterNode();
void failureStateMoveToBetterNode(const str& failureReason);
void setupStateChangePostureDuck();
BehaviorReturnCode_t evaluateStateChangePostureDuck();
void failureStateChangePostureDuck(const str& failureReason);
void setupStateChangePostureStand();
BehaviorReturnCode_t evaluateStateChangePostureStand();
void failureStateChangePostureStand(const str& failureReason);
void setupStateDucked();
BehaviorReturnCode_t evaluateStateDucked();
void failureStateDucked(const str& failureReason);
void setupStateFireDucked();
BehaviorReturnCode_t evaluateStateFireDucked();
void failureStateFireDucked(const str& failureReason);
void setupStateFirePauseDucked();
BehaviorReturnCode_t evaluateStateFirePauseDucked();
void failureStateFirePauseDucked(const str& failureReason);
void setupStateStanding();
BehaviorReturnCode_t evaluateStateStanding();
void failureStateStanding(const str& failureReason);
void setupStateFireStanding();
BehaviorReturnCode_t evaluateStateFireStanding();
void failureStateFireStanding(const str& failureReason);
void setupStateFirePauseStanding();
BehaviorReturnCode_t evaluateStateFirePauseStanding();
void failureStateFirePauseStanding(const str& failureReason);
void setupStateHoldPosition();
BehaviorReturnCode_t evaluateStateHoldPosition();
void failureStateHoldPosition(const str& failureReason);
private:
//------------------------------------
// Parameters
//------------------------------------
private:
str _movementAnim;
str _torsoAnim;
str _fireAnim;
@ -79,146 +211,9 @@ class CorridorCombatWithRangedWeapon : public Behavior
float _pauseTimeMin;
float _pauseTimeMax;
//-------------------------------------
// Internal Functionality
//-------------------------------------
protected:
void transitionToState ( corridorCombatStates_t state );
void setInternalState ( corridorCombatStates_t state , const str &stateName );
void init ( Actor &self );
void think ();
void updateEnemy ();
void setTorsoAnim ();
bool checkShouldDuck ();
bool checkShouldStand ();
bool checkShouldRetreat ();
void setupRotate();
BehaviorReturnCode_t evaluateRotate();
void setupStateFindNode ();
BehaviorReturnCode_t evaluateStateFindNode ();
void failureStateFindNode ( const str& failureReason );
void setupStateMoveToNode ();
BehaviorReturnCode_t evaluateStateMoveToNode ();
void failureStateMoveToNode ( const str& failureReason );
void setupStateBackPedal ();
BehaviorReturnCode_t evaluateStateBackPedal ();
void failureStateBackPedal ( const str& failureReason );
void setupStateFindBetterNode ();
BehaviorReturnCode_t evaluateStateFindBetterNode ();
void failureStateFindBetterNode ( const str& failureReason );
void setupStateMoveToBetterNode ();
BehaviorReturnCode_t evaluateStateMoveToBetterNode ();
void failureStateMoveToBetterNode ( const str& failureReason );
void setupStateChangePostureDuck ();
BehaviorReturnCode_t evaluateStateChangePostureDuck ();
void failureStateChangePostureDuck ( const str& failureReason );
void setupStateChangePostureStand ();
BehaviorReturnCode_t evaluateStateChangePostureStand ();
void failureStateChangePostureStand ( const str& failureReason );
void setupStateDucked ();
BehaviorReturnCode_t evaluateStateDucked ();
void failureStateDucked ( const str& failureReason );
void setupStateFireDucked ();
BehaviorReturnCode_t evaluateStateFireDucked ();
void failureStateFireDucked ( const str& failureReason );
void setupStateFirePauseDucked ();
BehaviorReturnCode_t evaluateStateFirePauseDucked ();
void failureStateFirePauseDucked ( const str& failureReason );
void setupStateStanding ();
BehaviorReturnCode_t evaluateStateStanding ();
void failureStateStanding ( const str& failureReason );
void setupStateFireStanding ();
BehaviorReturnCode_t evaluateStateFireStanding ();
void failureStateFireStanding ( const str& failureReason );
void setupStateFirePauseStanding ();
BehaviorReturnCode_t evaluateStateFirePauseStanding ();
void failureStateFirePauseStanding ( const str& failureReason );
void setupStateHoldPosition ();
BehaviorReturnCode_t evaluateStateHoldPosition ();
void failureStateHoldPosition ( const str& failureReason );
//-------------------------------------
// Public Interface
//-------------------------------------
public:
CLASS_PROTOTYPE( CorridorCombatWithRangedWeapon );
CorridorCombatWithRangedWeapon();
~CorridorCombatWithRangedWeapon();
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 SetMovementAnim( const str& movementAnim ) { _movementAnim = movementAnim; }
const str& GetMovementAnim() { return _movementAnim; }
void SetTorsoAnim( const str& torsoAnim ) { _torsoAnim = torsoAnim; }
const str& GetTorsoAnim() { return _torsoAnim; }
void SetFireAnim( const str& fireAnim ) { _fireAnim = fireAnim; }
const str& GetFireAnim() { return _fireAnim; }
void SetPreFireAnim( const str& preFireAnim ) { _preFireAnim = preFireAnim; }
const str& GetPreFireAnim() { return _preFireAnim; }
void SetPostFireAnim( const str& postFireAnim ) { _postFireAnim = postFireAnim; }
const str& GetPostFireAnim() { return _postFireAnim; }
void SetPostureChangeChance( float chance ) { _postureChangeChance = chance; }
float GetPostureChangeChance() { return _postureChangeChance; }
void SetMaxDistance( float maxDistance ) { _maxDistance = maxDistance; }
float GetMaxDistance() { return _maxDistance; }
void SetRetreatDistance( float retreatDistance ) { _retreatDistance = retreatDistance; }
float GetRetreatDistance() { return _retreatDistance; }
void SetThreatDistance( float threatDistance ) { _threatDistance = threatDistance; }
float GetThreatDistance() { return _threatDistance; }
void SetFireTimeMin( float fireTimeMin ) { _fireTimeMin = fireTimeMin; }
float GetFireTimeMin() { return _fireTimeMin; }
void SetFireTimeMax( float fireTimeMax ) { _fireTimeMax = fireTimeMax; }
float GetFireTimeMax() { return _fireTimeMax; }
void SetPauseTimeMin( float pauseTimeMin ) { _pauseTimeMin = pauseTimeMin; }
float GetPauseTimeMin() { return _pauseTimeMin; }
void SetPauseTimeMax( float pauseTimeMax ) { _pauseTimeMax = pauseTimeMax; }
float GetPauseTimeMax() { return _pauseTimeMax; }
virtual void Archive ( Archiver &arc );
static bool CanExecute( float maxDistance , Actor &self );
//-------------------------------------
// Components
//-------------------------------------
private:
GotoPoint _gotoPoint;
FireWeapon _fireWeapon;
MoveRandomDirection _moveRandomDir;
@ -228,10 +223,9 @@ class CorridorCombatWithRangedWeapon : public Behavior
//-------------------------------------
// Member Variables
//-------------------------------------
private:
corridorCombatStates_t _state;
HelperNodePtr _node;
Actor *_self;
Actor* _self;
EntityPtr _currentEnemy;
bool _finishedPostureTransition;
float _nextFireTime;
@ -240,53 +234,50 @@ class CorridorCombatWithRangedWeapon : public Behavior
float _enemyUpdateTime;
static const float NODE_RADIUS;
};
};
inline void CorridorCombatWithRangedWeapon::Archive( Archiver &arc )
{
Behavior::Archive ( arc );
inline void CorridorCombatWithRangedWeapon::Archive(Archiver& arc) {
Behavior::Archive(arc);
//
// Archive Parameters
//
arc.ArchiveString ( &_movementAnim );
arc.ArchiveString ( &_torsoAnim );
arc.ArchiveString ( &_fireAnim );
arc.ArchiveString ( &_preFireAnim );
arc.ArchiveString ( &_postFireAnim );
arc.ArchiveFloat ( &_postureChangeChance );
arc.ArchiveFloat ( &_maxDistance );
arc.ArchiveFloat ( &_retreatDistance );
arc.ArchiveFloat ( &_threatDistance );
arc.ArchiveFloat ( &_fireTimeMin );
arc.ArchiveFloat ( &_fireTimeMax );
arc.ArchiveFloat ( &_pauseTimeMin );
arc.ArchiveFloat ( &_pauseTimeMax );
arc.ArchiveString(&_movementAnim);
arc.ArchiveString(&_torsoAnim);
arc.ArchiveString(&_fireAnim);
arc.ArchiveString(&_preFireAnim);
arc.ArchiveString(&_postFireAnim);
arc.ArchiveFloat(&_postureChangeChance);
arc.ArchiveFloat(&_maxDistance);
arc.ArchiveFloat(&_retreatDistance);
arc.ArchiveFloat(&_threatDistance);
arc.ArchiveFloat(&_fireTimeMin);
arc.ArchiveFloat(&_fireTimeMax);
arc.ArchiveFloat(&_pauseTimeMin);
arc.ArchiveFloat(&_pauseTimeMax);
//
// Archive Components
//
arc.ArchiveObject ( &_gotoPoint );
arc.ArchiveObject ( &_fireWeapon );
arc.ArchiveObject ( &_moveRandomDir );
arc.ArchiveObject ( &_rotate );
arc.ArchiveObject(&_gotoPoint);
arc.ArchiveObject(&_fireWeapon);
arc.ArchiveObject(&_moveRandomDir);
arc.ArchiveObject(&_rotate);
//
// Archive Member Variables
//
ArchiveEnum ( _state, corridorCombatStates_t);
arc.ArchiveSafePointer ( &_node );
arc.ArchiveObjectPointer( ( Class ** )&_self );
arc.ArchiveSafePointer ( &_currentEnemy );
arc.ArchiveBool ( &_finishedPostureTransition );
arc.ArchiveFloat ( &_nextFireTime );
arc.ArchiveFloat ( &_nextPauseTime );
arc.ArchiveFloat ( &_holdPositionTime );
arc.ArchiveFloat ( &_enemyUpdateTime );
ArchiveEnum(_state, corridorCombatStates_t);
arc.ArchiveSafePointer(&_node);
arc.ArchiveObjectPointer((Class **)&_self);
arc.ArchiveSafePointer(&_currentEnemy);
arc.ArchiveBool(&_finishedPostureTransition);
arc.ArchiveFloat(&_nextFireTime);
arc.ArchiveFloat(&_nextPauseTime);
arc.ArchiveFloat(&_holdPositionTime);
arc.ArchiveFloat(&_enemyUpdateTime);
}