ef2gamesource/dlls/game/rotateToEntity.hpp
Walter Julius Hennecke a24940bed2 reformat
2014-03-09 22:39:44 +01:00

112 lines
3 KiB
C++

//-----------------------------------------------------------------------------
//
// $Logfile:: /Code/DLLs/game/rotateToEntity.h $
// $Revision:: 169 $
// $Author:: Bschofield $
// $Date:: 4/26/02 2:22p $
//
// Copyright (C) 2002 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
//
// DESCRIPTION:
// RotateToEntity Behavior Definition
//
//--------------------------------------------------------------------------------
//==============================
// Forward Declarations
//==============================
class RotateToEntity;
#ifndef __ROTATE_TO_ENTITY_H__
#define __ROTATE_TO_ENTITY_H__
#include "behavior.h"
//------------------------- CLASS ------------------------------
//
// Name: RotateToEntity
// Base Class: Behavior
//
// Description: Rotates the actor to face the passed in entity
//
// Method of Use: Should be aggregated by other behaviors
//--------------------------------------------------------------
class RotateToEntity : public Behavior {
public:
//-------------------------------------
// Public Interface
//-------------------------------------
CLASS_PROTOTYPE(RotateToEntity);
RotateToEntity();
~RotateToEntity();
void SetArgs(Event* ev);
void Begin(Actor& self);
BehaviorReturnCode_t Evaluate(Actor& self);
void End(Actor& self);
virtual void Archive(Archiver& arc);
void SetAnim(const str& animName);
void SetTurnSpeed(float turnSpeed);
void SetEntity(Entity* entity);
void SetEntityType(const str& ent);
private:
//------------------------------------
// Parameters
//------------------------------------
float _turnspeed;
EntityPtr _ent;
str _anim;
str _entityType;
//-------------------------------------
// Member Variables
//-------------------------------------
float _oldTurnSpeed;
};
inline void RotateToEntity::SetTurnSpeed(float turnSpeed) {
_turnspeed = turnSpeed;
}
inline void RotateToEntity::SetEntity(Entity* entity) {
if (entity)
_ent = entity;
}
inline void RotateToEntity::SetAnim(const str& animName) {
_anim = animName;
}
inline void RotateToEntity::SetEntityType(const str& ent) {
if (ent == "player" || ent == "enemy")
_entityType = ent;
}
inline void RotateToEntity::Archive(Archiver& arc) {
Behavior::Archive(arc);
//-------------------------------------
// Archive Parameters
//-------------------------------------
arc.ArchiveFloat(&_turnspeed);
arc.ArchiveSafePointer(&_ent);
arc.ArchiveString(&_anim);
arc.ArchiveString(&_entityType);
//-------------------------------------
// Archive Member Variables
//-------------------------------------
arc.ArchiveFloat(&_oldTurnSpeed);
}
#endif /* __ROTATE_TO_ENTITY_H__ */