Tactics: Western Philosophers Vs. Musicians  0.12
A turn-based tactical game combining rules and gameplay elements inspired by Final Fantasy Tactics and the Mayfair Exponential Game System. Unlike most games of this type, motion is in full, grid-less 3D.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
OpenSkyNet::Core::Updater Class Reference

#include <CUpdater.h>

Inheritance diagram for OpenSkyNet::Core::Updater:
OpenSkyNet::Core::AIUpdater OpenSkyNet::Core::CollisionDetector OpenSkyNet::Core::MotionUpdater OpenSkyNet::Core::PathFinder OpenSkyNet::Core::PhysicsUpdater OpenSkyNet::Core::PhysVisUpdater OpenSkyNet::Core::TransformChangeDetector OpenSkyNet::OgreCore::OgreAnimationUpdater

Classes

struct  UpdateInfo
 

Public Types

enum  UPDATER_TYPE {
  BASE, AI, CAMERA, PATH_FINDER,
  PATH, TRANSFORM_INTERPOLATOR, PHYSICS, ANIMATION,
  COLLISION_DETECTOR, PHYS_VIS, TRANSFORM_CHANGE_DETECTOR, CORE_MAX,
  MAX =32
}
 
enum  UPDATER_PRIORITY {
  UPD_DISABLED, UPD_1, UPD_2, UPD_3,
  UPD_4, UPD_5, UPD_6, UPD_7,
  UPD_8, UPD_NUM_PRIORITIES
}
 
enum  OBJECT_PRIORITY {
  OBJ_DISABLED, OBJ_1, OBJ_2, OBJ_3,
  OBJ_NUM_PRIORITIES
}
 
typedef std::map< Object
*, UpdateInfo * > 
ObjMap
 

Public Member Functions

 Updater ()
 
 Updater (UPDATER_TYPE type_, const char *typeName_, UPDATER_PRIORITY prio_, float interval_)
 
virtual ~Updater ()
 
UPDATER_TYPE getType () const
 
const std::string & getTypeName () const
 
virtual bool update (float dt_)
 
float getInterval () const
 
void setInterval (float interval_)
 
Utils::uint getNumObjects () const
 
Utils::uint getNumObjectsThatCanUpdate () const
 
bool find (Object *obj_) const
 
UPDATER_PRIORITY getPriority () const
 
OBJECT_PRIORITY getPriority (Object *obj_) const
 
virtual bool setPriority (Object *obj_, OBJECT_PRIORITY prio_)
 

Protected Member Functions

virtual bool addObject (Object *obj_, OBJECT_PRIORITY prio_=OBJ_1, bool isOneShot_=false)
 
virtual bool removeObject (Object *obj_)
 
virtual void removeAllObjects ()
 
int getNumToUpdate (float dt_)
 
void allObjectsUpdated ()
 
void setPriority (UPDATER_PRIORITY prio_)
 

Protected Attributes

std::list< Object * > _objLists [OBJ_NUM_PRIORITIES]
 
ObjMap _objMap
 
UPDATER_TYPE _type
 
std::string _typeName
 
UPDATER_PRIORITY _prio
 
float _interval
 
float _dtSinceAllWereUpdated
 
float _prevTotalTimeForAllUpdates
 
float _partialUpdate
 
int _currPrio
 
std::list< Object * >::iterator _currObj
 

Friends

class Core::UpdateManager
 

Detailed Description

Updates game objects. This class can distribute its objects' updates (approximately) equally over time according to the interval assigned the updater. For example, an updater with 10 objects and an interval of 0.033 seconds (a little over 30 update calls a second) will update one object about every 3 calls to update(). This behavior can be overridden by assigning an interval of 0 to the updater. In that case, all objects are updated per update() call.

Member Typedef Documentation

Member Enumeration Documentation

Higher priority objects are updated first - order is read low to high.

Enumerator
OBJ_DISABLED 
OBJ_1 
OBJ_2 
OBJ_3 
OBJ_NUM_PRIORITIES 

Higher priority updaters update their objects first - order is read low to high.

Enumerator
UPD_DISABLED 
UPD_1 
UPD_2 
UPD_3 
UPD_4 
UPD_5 
UPD_6 
UPD_7 
UPD_8 
UPD_NUM_PRIORITIES 

All updater types tracked by the UpdateManager.

Enumerator
BASE 
AI 
CAMERA 
PATH_FINDER 
PATH 
TRANSFORM_INTERPOLATOR 
PHYSICS 
ANIMATION 
COLLISION_DETECTOR 
PHYS_VIS 
TRANSFORM_CHANGE_DETECTOR 
CORE_MAX 
MAX 

Constructor & Destructor Documentation

OpenSkyNet::Core::Updater::Updater ( )
inline
OpenSkyNet::Core::Updater::Updater ( UPDATER_TYPE  type_,
const char *  typeName_,
UPDATER_PRIORITY  prio_,
float  interval_ 
)
inline
virtual OpenSkyNet::Core::Updater::~Updater ( )
inlinevirtual

Member Function Documentation

bool Updater::addObject ( Object obj_,
Updater::OBJECT_PRIORITY  prio_ = OBJ_1,
bool  isOneShot_ = false 
)
protectedvirtual
void Updater::allObjectsUpdated ( )
protected
bool OpenSkyNet::Core::Updater::find ( Object obj_) const
inline
float OpenSkyNet::Core::Updater::getInterval ( ) const
inline
Utils::uint OpenSkyNet::Core::Updater::getNumObjects ( ) const
inline

Returns the number of Objects in this Updater, including those with priority == OBJ_DISABLED.

Utils::uint OpenSkyNet::Core::Updater::getNumObjectsThatCanUpdate ( ) const
inline

Returns the number of Objects in this Updater with a priority > OBJ_DISABLED.

int Updater::getNumToUpdate ( float  dt_)
protected
UPDATER_PRIORITY OpenSkyNet::Core::Updater::getPriority ( ) const
inline
OBJECT_PRIORITY OpenSkyNet::Core::Updater::getPriority ( Object obj_) const

Returns OBJ_DISABLED if obj_ is not in this updater.

UPDATER_TYPE OpenSkyNet::Core::Updater::getType ( ) const
inline
const std::string& OpenSkyNet::Core::Updater::getTypeName ( ) const
inline
void Updater::removeAllObjects ( )
protectedvirtual
bool Updater::removeObject ( Object obj_)
protectedvirtual
void OpenSkyNet::Core::Updater::setInterval ( float  interval_)
inline

Set the ammount of time for all objects to be updated once.

Parameters
interval_= units of seconds
void OpenSkyNet::Core::Updater::setPriority ( UPDATER_PRIORITY  prio_)
inlineprotected
virtual bool OpenSkyNet::Core::Updater::setPriority ( Object obj_,
OBJECT_PRIORITY  prio_ 
)
virtual
bool Updater::update ( float  dt_)
virtual

Returns true if all objects were updated over the current interval (that's interval, not dt_), false if objects are left to be updated (see class description).

Parameters
dt_= seconds to update an object this call. dt_ accumulates for objects not updated.

Reimplemented in OpenSkyNet::Core::CollisionDetector, OpenSkyNet::Core::PathFinder, OpenSkyNet::Core::TransformInterpolator, OpenSkyNet::Core::PathUpdater, OpenSkyNet::Core::Director, OpenSkyNet::Core::TransformChangeDetector, OpenSkyNet::OgreCore::OgreAnimationUpdater, OpenSkyNet::Core::PhysicsUpdater, OpenSkyNet::Core::PhysVisUpdater, and OpenSkyNet::Core::AIUpdater.

Friends And Related Function Documentation

friend class Core::UpdateManager
friend

Member Data Documentation

std::list<Object*>::iterator OpenSkyNet::Core::Updater::_currObj
protected
int OpenSkyNet::Core::Updater::_currPrio
protected
float OpenSkyNet::Core::Updater::_dtSinceAllWereUpdated
protected
float OpenSkyNet::Core::Updater::_interval
protected
std::list<Object*> OpenSkyNet::Core::Updater::_objLists[OBJ_NUM_PRIORITIES]
protected
ObjMap OpenSkyNet::Core::Updater::_objMap
protected
float OpenSkyNet::Core::Updater::_partialUpdate
protected
float OpenSkyNet::Core::Updater::_prevTotalTimeForAllUpdates
protected
UPDATER_PRIORITY OpenSkyNet::Core::Updater::_prio
protected
UPDATER_TYPE OpenSkyNet::Core::Updater::_type
protected
std::string OpenSkyNet::Core::Updater::_typeName
protected

The documentation for this class was generated from the following files: