hoa_system::SystemTimer Class Reference

A class which allows the user to easily control timed events. More...

#include <system.h>

Collaboration diagram for hoa_system::SystemTimer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void Initialize (uint32 duration, int32 number_loops=0, hoa_mode_manager::GameMode *mode_owner=NULL)
 Initializes the critical members of the system timer class.
void Pause ()
 Pauses the timer if it is running.
void Reset ()
 Resets the timer to its initial state.
void Run ()
 Starts the timer from the initial state or resumes it if it is paused.
 SystemTimer (uint32 duration, int32 number_loops=0, hoa_mode_manager::GameMode *mode_owner=NULL)
 
Note:
This constructor automatically invokes the Initialize() method with its arguments

 SystemTimer ()
 ~SystemTimer ()
Member Get Access Functions
uint32 GetCurrentLoop () const
uint32 GetDuration () const
hoa_mode_manager::GameModeGetModeOwner () const
int32 GetNumberLoops () const
SYSTEM_TIMER_STATE GetState () const
uint32 GetTimeExpired () const
uint32 GetTimeLeft () const
 
Note:
Technically this does not get a class member, but instead returns the difference between two members

uint32 GetTimesCompleted () const
Timer State Checking Functions
bool IsFinished () const
bool IsInitial () const
bool IsPaused () const
bool IsRunning () const
Member Set Access Functions
Note:
Only call these methods when the timer is in its initial state. Trying to set any of these members when in any other state will yield no change and print a warning message.


void SetDuration (uint32 duration)
void SetModeOwner (hoa_mode_manager::GameMode *mode_owner)
void SetNumberLoops (int32 number_loops)

Private Member Functions

void _UpdateTimer ()
 Updates the timer if it is running This method can only be invoked by the GameSystem class. Invoking this method is also the only way in which the timer may arrive at the finished state.

Private Attributes

uint32 _duration
 The duration (in milliseconds) that the timer should run for.
hoa_mode_manager::GameMode_mode_owner
 A pointer to the game mode object which owns this timer, or NULL if it is unowned.
int32 _number_loops
 The number of loops the timer should run for. -1 indicates infinite looping.
SYSTEM_TIMER_STATE _state
 Maintains the current state of the timer (initial, running, paused, or finished).
uint32 _time_expired
 The amount of time that has expired on the current timer loop (counts up from 0 to _duration).
uint32 _times_completed
 Incremented by one each time the timer reaches the finished state.

Friends

class GameSystem

Detailed Description

A class which allows the user to easily control timed events.

****************************************************************************

This is a light-weight class for maintaining a simple timer. This class is designed specifically for use by the various game mode classes, but it is certainly capable of being utilized just as effectively by the engine or or other parts of the code. The operation of this class is also integrated with the GameSystem class, which routinely updates and manageds its timers. The features of this timing mechanism include:

Note:
The auto-pausing mechanism can only be utilized by game mode timers. The way it works is by detecting when the active game mode has changed and pausing all timers which do not belong to the AGM and un-pausing all timers which do belong to the AGM. The requirement to use the auto-pausing feature is to pass the class a pointer to the game mode class which "owns" the SystemTimer object. If this is not done, then the timer will not auto-pause.

It is a recommended practice to create derivative timer objects which inherit from this class. Using SystemTimer as a base class can make it relatively easy to create timers which perform specific functions in the game code, such as temporary displaying damage numbers.

Definition at line 98 of file system.h.


Constructor & Destructor Documentation

hoa_system::SystemTimer::SystemTimer (  ) 

Definition at line 39 of file system.cpp.

hoa_system::SystemTimer::SystemTimer ( uint32  duration,
int32  number_loops = 0,
hoa_mode_manager::GameMode mode_owner = NULL 
) [inline]

Note:
This constructor automatically invokes the Initialize() method with its arguments

Definition at line 105 of file system.h.

References Initialize().

Here is the call graph for this function:

hoa_system::SystemTimer::~SystemTimer (  ) 

Definition at line 50 of file system.cpp.

References _state, hoa_system::GameSystem::_system_timers, hoa_system::SYSTEM_TIMER_INVALID, and hoa_system::SystemManager.


Member Function Documentation

void hoa_system::SystemTimer::_UpdateTimer (  )  [private]

Updates the timer if it is running This method can only be invoked by the GameSystem class. Invoking this method is also the only way in which the timer may arrive at the finished state.

Definition at line 121 of file system.cpp.

References _duration, _number_loops, _state, _time_expired, _times_completed, hoa_system::GameSystem::GetUpdateTime(), IsRunning(), hoa_system::SYSTEM_TIMER_FINISHED, and hoa_system::SystemManager.

Here is the call graph for this function:

uint32 hoa_system::SystemTimer::GetCurrentLoop (  )  const [inline]

Note:
The exact same function as GetTimesCompleted(). When looping the first iteration is loop #0, the second iteration is loop #1, etc. So a timer that is supposed to run four loops will return 0, 1, 2, or 3 here.

Definition at line 186 of file system.h.

References _times_completed.

uint32 hoa_system::SystemTimer::GetDuration (  )  const [inline]

Definition at line 164 of file system.h.

References _duration.

Referenced by hoa_battle::private_battle::BattleEnemyActor::Update(), hoa_battle::private_battle::BattleCharacterActor::Update(), and hoa_battle::private_battle::ScriptEvent::Update().

hoa_mode_manager::GameMode* hoa_system::SystemTimer::GetModeOwner (  )  const [inline]

Definition at line 170 of file system.h.

References _mode_owner.

int32 hoa_system::SystemTimer::GetNumberLoops (  )  const [inline]

Definition at line 167 of file system.h.

References _number_loops.

SYSTEM_TIMER_STATE hoa_system::SystemTimer::GetState (  )  const [inline]

Definition at line 161 of file system.h.

References _state.

uint32 hoa_system::SystemTimer::GetTimeExpired (  )  const [inline]

Definition at line 173 of file system.h.

References _time_expired.

Referenced by hoa_map::MapMode::Draw().

uint32 hoa_system::SystemTimer::GetTimeLeft (  )  const [inline]

Note:
Technically this does not get a class member, but instead returns the difference between two members

Definition at line 177 of file system.h.

References _duration, and _time_expired.

uint32 hoa_system::SystemTimer::GetTimesCompleted (  )  const [inline]

Definition at line 180 of file system.h.

References _times_completed.

void hoa_system::SystemTimer::Initialize ( uint32  duration,
int32  number_loops = 0,
hoa_mode_manager::GameMode mode_owner = NULL 
)

Initializes the critical members of the system timer class.

Parameters:
duration The duration (in milliseconds) that the timer should count for
number_loops The number of times that the timer should loop its counter. Default value is set to no looping.
mode_owner A pointer to the GameMode which owns this class. Default value is set to NULL (no owner).
Invoking this method will instantly halt the timer and reset it to the initial state, so use it with care.

Definition at line 61 of file system.cpp.

References _duration, _mode_owner, _number_loops, _state, hoa_system::GameSystem::_system_timers, _time_expired, _times_completed, hoa_system::SYSTEM_TIMER_INITIAL, hoa_system::SYSTEM_TIMER_INVALID, and hoa_system::SystemManager.

Referenced by hoa_battle::private_battle::BattleActor::BattleActor(), hoa_battle::private_battle::ScriptEvent::ScriptEvent(), SystemTimer(), and hoa_battle::private_battle::BattleActor::TEMP_ResetAttackTimer().

bool hoa_system::SystemTimer::IsFinished (  )  const [inline]

Definition at line 143 of file system.h.

References _state, and hoa_system::SYSTEM_TIMER_FINISHED.

Referenced by hoa_battle::BattleMode::_UpdateCharacterSelection(), hoa_map::MapMode::Draw(), hoa_battle::BattleMode::GetIndexOfFirstIdleCharacter(), hoa_battle::private_battle::BattleActor::TEMP_IsAttacking(), hoa_battle::private_battle::BattleEnemyActor::Update(), hoa_battle::private_battle::BattleCharacterActor::Update(), and hoa_battle::BattleMode::Update().

bool hoa_system::SystemTimer::IsInitial (  )  const [inline]

Definition at line 134 of file system.h.

References _state, and hoa_system::SYSTEM_TIMER_INITIAL.

Referenced by Run(), SetDuration(), SetModeOwner(), and SetNumberLoops().

bool hoa_system::SystemTimer::IsPaused (  )  const [inline]

Definition at line 140 of file system.h.

References _state, and hoa_system::SYSTEM_TIMER_PAUSED.

Referenced by Run().

bool hoa_system::SystemTimer::IsRunning (  )  const [inline]

Definition at line 137 of file system.h.

References _state, and hoa_system::SYSTEM_TIMER_RUNNING.

Referenced by _UpdateTimer(), Pause(), hoa_battle::private_battle::BattleEnemyActor::Update(), hoa_battle::private_battle::BattleCharacterActor::Update(), and hoa_battle::private_battle::ScriptEvent::Update().

void hoa_system::SystemTimer::Pause (  )  [inline]

Pauses the timer if it is running.

Definition at line 129 of file system.h.

References _state, IsRunning(), and hoa_system::SYSTEM_TIMER_PAUSED.

Here is the call graph for this function:

void hoa_system::SystemTimer::Reset (  )  [inline]

Resets the timer to its initial state.

Definition at line 121 of file system.h.

References _state, _time_expired, _times_completed, hoa_system::SYSTEM_TIMER_INITIAL, and hoa_system::SYSTEM_TIMER_INVALID.

Referenced by hoa_battle::private_battle::BattleActor::OnDeath(), and hoa_battle::private_battle::BattleActor::ResetWaitTime().

void hoa_system::SystemTimer::Run (  )  [inline]

Starts the timer from the initial state or resumes it if it is paused.

Definition at line 125 of file system.h.

References _state, IsInitial(), IsPaused(), and hoa_system::SYSTEM_TIMER_RUNNING.

Referenced by hoa_battle::private_battle::BattleActor::BattleActor(), hoa_battle::private_battle::BattleActor::OnLife(), hoa_map::MapMode::Reset(), hoa_battle::private_battle::BattleActor::ResetWaitTime(), hoa_battle::private_battle::ScriptEvent::ScriptEvent(), and hoa_battle::private_battle::BattleActor::TEMP_ResetAttackTimer().

Here is the call graph for this function:

void hoa_system::SystemTimer::SetDuration ( uint32  duration  ) 

Definition at line 79 of file system.cpp.

References _duration, IsInitial(), and hoa_system::SYSTEM_DEBUG.

Here is the call graph for this function:

void hoa_system::SystemTimer::SetModeOwner ( hoa_mode_manager::GameMode mode_owner  ) 

Definition at line 107 of file system.cpp.

References _mode_owner, IsInitial(), and hoa_system::SYSTEM_DEBUG.

Here is the call graph for this function:

void hoa_system::SystemTimer::SetNumberLoops ( int32  number_loops  ) 

Definition at line 93 of file system.cpp.

References _number_loops, IsInitial(), and hoa_system::SYSTEM_DEBUG.

Here is the call graph for this function:


Friends And Related Function Documentation

friend class GameSystem [friend]

Definition at line 99 of file system.h.


Member Data Documentation

uint32 hoa_system::SystemTimer::_duration [private]

The duration (in milliseconds) that the timer should run for.

Definition at line 195 of file system.h.

Referenced by _UpdateTimer(), GetDuration(), GetTimeLeft(), Initialize(), and SetDuration().

hoa_mode_manager::GameMode* hoa_system::SystemTimer::_mode_owner [private]

A pointer to the game mode object which owns this timer, or NULL if it is unowned.

Definition at line 201 of file system.h.

Referenced by GetModeOwner(), Initialize(), and SetModeOwner().

int32 hoa_system::SystemTimer::_number_loops [private]

The number of loops the timer should run for. -1 indicates infinite looping.

Definition at line 198 of file system.h.

Referenced by _UpdateTimer(), GetNumberLoops(), Initialize(), and SetNumberLoops().

SYSTEM_TIMER_STATE hoa_system::SystemTimer::_state [private]

Maintains the current state of the timer (initial, running, paused, or finished).

Definition at line 192 of file system.h.

Referenced by _UpdateTimer(), GetState(), Initialize(), IsFinished(), IsInitial(), IsPaused(), IsRunning(), Pause(), Reset(), Run(), and ~SystemTimer().

uint32 hoa_system::SystemTimer::_time_expired [private]

The amount of time that has expired on the current timer loop (counts up from 0 to _duration).

Definition at line 204 of file system.h.

Referenced by _UpdateTimer(), GetTimeExpired(), GetTimeLeft(), Initialize(), and Reset().

uint32 hoa_system::SystemTimer::_times_completed [private]

Incremented by one each time the timer reaches the finished state.

Definition at line 207 of file system.h.

Referenced by _UpdateTimer(), GetCurrentLoop(), GetTimesCompleted(), Initialize(), and Reset().


The documentation for this class was generated from the following files:
Generated on Fri Jul 6 23:16:06 2007 for Hero of Allacrost by  doxygen 1.5.1