This commit is contained in:
Walter Julius Hennecke 2014-03-09 22:23:28 +01:00
parent 7b73980dc2
commit 66f262fd5f

View file

@ -40,14 +40,12 @@ class HealGroupMember;
//
// Method of Use: Called From State Machine
//--------------------------------------------------------------
class HealGroupMember : public Behavior
{
class HealGroupMember : public Behavior {
public:
//------------------------------------
// States
//------------------------------------
public:
typedef enum
{
typedef enum {
HGM_STATE_GOTO_ENTITY,
HGM_STATE_FACE_TARGET,
HGM_STATE_ANIMATE,
@ -56,30 +54,34 @@ class HealGroupMember : public Behavior
HGM_STATE_SUCCESS,
} healGroupMemberStates_t;
typedef struct
{
typedef struct {
EntityPtr ent;
float health;
float dist;
bool treated;
} triageEntry_t;
//------------------------------------
// Parameters
//------------------------------------
private:
str _anim;
float _healDistance;
float _maxDistance;
float _initialHealPercentage;
float _regenHealPercentage;
float _regenInterval;
float _maxPercentage;
//-------------------------------------
// Public Interface
//-------------------------------------
CLASS_PROTOTYPE(HealGroupMember);
HealGroupMember();
~HealGroupMember();
void SetArgs(Event* ev);
void AnimDone(Event* ev);
void Begin(Actor& self);
BehaviorReturnCode_t Evaluate(Actor& self);
void End(Actor& self);
virtual void Archive(Archiver& arc);
protected:
//-------------------------------------
// Internal Functionality
//-------------------------------------
protected:
void init(Actor& self);
void doHeal(Actor& self);
@ -102,48 +104,36 @@ class HealGroupMember : public Behavior
void treatedPatient(Actor& self, Entity* ent);
Actor* findHighestPriorityPatient(Actor& self);
//-------------------------------------
// Public Interface
//-------------------------------------
public:
CLASS_PROTOTYPE( HealGroupMember );
HealGroupMember();
~HealGroupMember();
void SetArgs ( Event *ev );
void AnimDone ( Event *ev );
void Begin ( Actor &self );
BehaviorReturnCode_t Evaluate ( Actor &self );
void End ( Actor &self );
virtual void Archive ( Archiver &arc );
private:
//------------------------------------
// Parameters
//------------------------------------
str _anim;
float _healDistance;
float _maxDistance;
float _initialHealPercentage;
float _regenHealPercentage;
float _regenInterval;
float _maxPercentage;
//-------------------------------------
// Components
//-------------------------------------
private:
GotoEntity _gotoEntity;
RotateToEntity _rotateToEntity;
//-------------------------------------
// Member Variables
//-------------------------------------
private:
unsigned int _state;
ActorPtr _currentPatient;
str _legAnim;
float _nextTriageUpdate;
Container<triageEntry_t*> _triageList;
};
inline void HealGroupMember::Archive( Archiver &arc )
{
inline void HealGroupMember::Archive(Archiver& arc) {
int num, i;
triageEntry_t* checkEntry;
@ -168,28 +158,23 @@ inline void HealGroupMember::Archive( Archiver &arc )
arc.ArchiveString(&_legAnim);
arc.ArchiveFloat(&_nextTriageUpdate);
if ( arc.Saving() )
{
if (arc.Saving()) {
num = _triageList.NumObjects();
arc.ArchiveInteger(&num);
for ( i = num ; i > 0 ; i-- )
{
for (i = num; i > 0; i--) {
checkEntry = _triageList.ObjectAt(i);
arc.ArchiveSafePointer(&checkEntry->ent);
arc.ArchiveFloat(&checkEntry->health);
arc.ArchiveFloat(&checkEntry->dist);
arc.ArchiveBool(&checkEntry->treated);
}
}
else
{
} else {
arc.ArchiveInteger(&num);
_triageList.ClearObjectList();
_triageList.Resize(num);
for ( i = 1 ; i<= num ; i++ )
{
for (i = 1; i <= num; i++) {
checkEntry = new triageEntry_t;
arc.ArchiveSafePointer(&checkEntry->ent);
arc.ArchiveFloat(&checkEntry->health);