This commit is contained in:
Walter Julius Hennecke 2014-03-09 22:53:58 +01:00
parent b212dbff25
commit e03763d963

View file

@ -40,14 +40,12 @@ class StationaryFireCombatEX;
//
// Method of Use: Called From State Machine
//--------------------------------------------------------------
class StationaryFireCombatEX : public Behavior
{
class StationaryFireCombatEX : public Behavior {
public:
//------------------------------------
// States
//------------------------------------
public:
typedef enum
{
typedef enum {
STATIONARY_FIRE_AIM,
STATIONARY_FIRE_PRE_FIRE,
STATIONARY_FIRE_ATTACK,
@ -56,10 +54,65 @@ class StationaryFireCombatEX : public Behavior
STATIONARY_FIRE_FAILED
} StationaryFireStates_t;
//-------------------------------------
// Public Interface
//-------------------------------------
CLASS_PROTOTYPE(StationaryFireCombatEX);
StationaryFireCombatEX();
~StationaryFireCombatEX();
void SetArgs(Event* ev);
void AnimDone(Event* ev);
void Begin(Actor& self);
BehaviorReturnCode_t Evaluate(Actor& self);
void End(Actor& self);
// Accessors
void SetAimAnim(const str& anim) { _aimAnim = anim; }
void SetFireAnim(const str& anim) { _fireAnim = anim; }
void SetPreFireAnim(const str& anim) { _preFireAnim = anim; }
void SetPostFireAnim(const str& anim) { _postFireAnim = anim; }
void SetStance(const str& anim) { _stance = anim; }
void SetAimTimeMin(float minTime) { _aimTimeMin = minTime; }
void SetAimTimeMax(float maxTime) { _aimTimeMax = maxTime; }
void SetFireTimeMin(float minTime) { _fireTimeMin = minTime; }
void SetFireTimeMax(float maxTime) { _fireTimeMax = maxTime; }
virtual void Archive(Archiver& arc);
protected:
//-------------------------------------
// Internal Functionality
//-------------------------------------
void transitionToState(StationaryFireStates_t state);
void setInternalState(StationaryFireStates_t state, const str& stateName);
void init(Actor& self);
void think();
void updateEnemy();
void faceEnemy();
void setupStateAim();
BehaviorReturnCode_t evaluateStateAim();
void failureStateAim(const str& failureReason);
void setupStatePreFire();
BehaviorReturnCode_t evaluateStatePreFire();
void failureStatePreFire(const str& failureReason);
void setupStateAttack();
BehaviorReturnCode_t evaluateStateAttack();
void failureStateAttack(const str& failureReason);
void setupStatePostFire();
BehaviorReturnCode_t evaluateStatePostFire();
void failureStatePostFire(const str& failureReason);
private:
//------------------------------------
// Parameters
//------------------------------------
private:
str _stance;
float _aimTimeMin;
float _aimTimeMax;
@ -67,80 +120,15 @@ class StationaryFireCombatEX : public Behavior
float _fireTimeMax;
bool _forceAttack;
//-------------------------------------
// Internal Functionality
//-------------------------------------
protected:
void transitionToState ( StationaryFireStates_t state );
void setInternalState ( StationaryFireStates_t state , const str &stateName );
void init ( Actor &self );
void think ();
void updateEnemy ();
void faceEnemy ();
void setupStateAim ();
BehaviorReturnCode_t evaluateStateAim ();
void failureStateAim ( const str& failureReason );
void setupStatePreFire ();
BehaviorReturnCode_t evaluateStatePreFire ();
void failureStatePreFire ( const str& failureReason );
void setupStateAttack ();
BehaviorReturnCode_t evaluateStateAttack ();
void failureStateAttack ( const str& failureReason );
void setupStatePostFire ();
BehaviorReturnCode_t evaluateStatePostFire ();
void failureStatePostFire ( const str& failureReason );
//-------------------------------------
// Public Interface
//-------------------------------------
public:
CLASS_PROTOTYPE( StationaryFireCombatEX );
StationaryFireCombatEX();
~StationaryFireCombatEX();
void SetArgs ( Event *ev );
void AnimDone ( Event *ev );
void Begin ( Actor &self );
BehaviorReturnCode_t Evaluate ( Actor &self );
void End ( Actor &self );
// Accessors
void SetAimAnim ( const str &anim ) { _aimAnim = anim; }
void SetFireAnim ( const str &anim ) { _fireAnim = anim; }
void SetPreFireAnim ( const str &anim ) { _preFireAnim = anim; }
void SetPostFireAnim ( const str &anim ) { _postFireAnim = anim; }
void SetStance ( const str &anim ) { _stance = anim; }
void SetAimTimeMin ( float minTime ) { _aimTimeMin = minTime; }
void SetAimTimeMax ( float maxTime ) { _aimTimeMax = maxTime; }
void SetFireTimeMin ( float minTime ) { _fireTimeMin = minTime; }
void SetFireTimeMax ( float maxTime ) { _fireTimeMax = maxTime; }
virtual void Archive ( Archiver &arc );
//-------------------------------------
// Components
//-------------------------------------
private:
FireWeapon _fireWeapon;
RotateToEntity _rotateToEntity;
//-------------------------------------
// Member Variables
//-------------------------------------
private:
StationaryFireStates_t _state;
float _endFireTime;
float _endAimTime;
@ -152,46 +140,43 @@ class StationaryFireCombatEX : public Behavior
str _fireAnim;
str _postFireAnim;
Actor *_self;
Actor* _self;
};
};
inline void StationaryFireCombatEX::Archive( Archiver &arc )
{
Behavior::Archive ( arc );
inline void StationaryFireCombatEX::Archive(Archiver& arc) {
Behavior::Archive(arc);
//
// Archive Parameters
//
arc.ArchiveString ( &_stance );
arc.ArchiveFloat ( &_aimTimeMin );
arc.ArchiveFloat ( &_aimTimeMax );
arc.ArchiveFloat ( &_fireTimeMin );
arc.ArchiveFloat ( &_fireTimeMax );
arc.ArchiveBool ( &_forceAttack );
arc.ArchiveString(&_stance);
arc.ArchiveFloat(&_aimTimeMin);
arc.ArchiveFloat(&_aimTimeMax);
arc.ArchiveFloat(&_fireTimeMin);
arc.ArchiveFloat(&_fireTimeMax);
arc.ArchiveBool(&_forceAttack);
//
// Archive Components
//
arc.ArchiveObject ( &_fireWeapon );
arc.ArchiveObject ( &_rotateToEntity );
arc.ArchiveObject(&_fireWeapon);
arc.ArchiveObject(&_rotateToEntity);
//
// Archive Member Variables
//
ArchiveEnum ( _state, StationaryFireStates_t );
arc.ArchiveFloat ( &_endFireTime );
arc.ArchiveFloat ( &_endAimTime );
arc.ArchiveSafePointer ( &_currentEnemy );
arc.ArchiveBool ( &_animDone );
arc.ArchiveBool ( &_canAttack );
arc.ArchiveString ( &_aimAnim );
arc.ArchiveString ( &_preFireAnim );
arc.ArchiveString ( &_fireAnim );
arc.ArchiveString ( &_postFireAnim );
ArchiveEnum(_state, StationaryFireStates_t);
arc.ArchiveFloat(&_endFireTime);
arc.ArchiveFloat(&_endAimTime);
arc.ArchiveSafePointer(&_currentEnemy);
arc.ArchiveBool(&_animDone);
arc.ArchiveBool(&_canAttack);
arc.ArchiveString(&_aimAnim);
arc.ArchiveString(&_preFireAnim);
arc.ArchiveString(&_fireAnim);
arc.ArchiveString(&_postFireAnim);
arc.ArchiveObjectPointer( ( Class ** )&_self );
arc.ArchiveObjectPointer((Class **)&_self);
}