hoa_map::private_map::VirtualSprite Class Reference

An invisible and possible mobile sprite on a map. More...

#include <map_sprites.h>

Inheritance diagram for hoa_map::private_map::VirtualSprite:

Inheritance graph
[legend]
Collaboration diagram for hoa_map::private_map::VirtualSprite:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void Draw ()
 Draws a dialogue icon over the virtual sprite if it has to.
virtual bool LoadState ()
 This method will load the saved state of a sprite. Attributes loaded: direction, speed, moving state, name, current action.
virtual void SaveState ()
 This method will save the state of a sprite. Attributes saved: direction, speed, moving state, name, current action.
void SetRandomDirection ()
 Sets the sprite's direction to a random value This function is used mostly for the ActionRandomMove class.
virtual void Update ()
 Updates the virtual object's position if it is moving, otherwise does nothing.
void UpdateSeenDialogue ()
 Examines all dialogue owned by the sprite and sets the appropriate value of VirtualSprite::seen_all_dialogue.
 VirtualSprite ()
 ~VirtualSprite ()
Dialogue control methods
These methods are used to add and control which dialogue should the sprite speak.

void AddAction (SpriteAction *act)
void AddDialogue (MapDialogue *md)
MapDialogueGetCurrentDialogue () const
int16 GetNumDialogues () const
bool HasDialogue () const
bool IsShowingDialogueIcon () const
void NextDialogue ()
void SetDialogue (const int16 dialogue)
void ShowDialogueIcon (bool state)
Lua Access Functions
These functions are specifically written for Lua binding, to enable Lua to access the members of this class.

uint16 GetDirection () const
float GetMovementSpeed () const
void SetDirection (uint16 dir)
void SetFacePortrait (std::string pn)
void SetMovementSpeed (float speed)

Static Public Member Functions

static uint16 CalculateOppositeDirection (const uint16 direction)
 This static class function returns the opposite direction of the direction given in parameter.

Public Attributes

int16 _current_dialogue
 An index to the dialogues vector, representing the current sprite dialogue to display when talked to by the player. A negative value indicates that the sprite has no dialogue.
hoa_video::Color _dialogue_icon_color
 Used to fade the dialogue icon according to distance.
bool _show_dialogue_icon
 Indicates if the icon indicating that there is a dialogue available should be drawn or not.
std::vector< SpriteAction * > actions
 A container for all of the actions this sprite performs.
int8 current_action
 An index to the actions vector, representing the current sprite action being performed. A negative value indicates that the sprite is taking no action. If the sprite has no entries in its actions vector, this member should remain negative, otherwise a segmentation fault will occur.
std::vector< MapDialogue * > dialogues
 This vector contains all the dialogues of the sprite.
uint16 direction
 A bit-mask for the sprite's draw orientation and direction vector. This member determines both where to move the sprite (8 directions) and which way the sprite is facing (4 directions). See the Sprite Directions series of constants for the values that this member may be set to.
hoa_video::StillImageface_portrait
 A pointer to the face portrait of the sprite, as seen in dialogues and menus.
int8 forced_action
float movement_speed
 The speed at which the sprite moves around the map.
bool moving
 Set to true when the sprite is currently moving.
hoa_utils::ustring name
 The name of the sprite, as seen by the player in the game.
bool seen_all_dialogue
 Set to false if the sprite contains dialogue that has not been seen by the player.
bool sky_object
 When set to true, indicates that the object exists on the sky object layer (default = false). This member is necessary for collision detection purposes. When a sprite needs to detect if it has encountered a collision, that collision must be examined with other objects on the appropriate layer (the ground or sky layer).
Saved state attributes
These attributes are used to save and load the state of a VirtualSprite

bool _saved
 This indicates if a state was saved or not.
int8 _saved_current_action
uint16 _saved_direction
float _saved_movement_speed
bool _saved_moving
hoa_utils::ustring _saved_name

Detailed Description

An invisible and possible mobile sprite on a map.

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

The VirtualSprite is a special type of MapObject because it has no physical form (no image). Virtual sprites may be manipulated to move around on the screen, or they may remain stationary. VirtualSprites do take collision detection into account by default, unless the no_collision member is set to true. Here are some examples of where virtual sprites may be of use:

Definition at line 114 of file map_sprites.h.


Constructor & Destructor Documentation

hoa_map::private_map::VirtualSprite::VirtualSprite (  ) 

Definition at line 48 of file map_sprites.cpp.

References hoa_map::private_map::MapObject::_object_type, and hoa_map::private_map::VIRTUAL_TYPE.

hoa_map::private_map::VirtualSprite::~VirtualSprite (  ) 

Definition at line 66 of file map_sprites.cpp.

References actions, hoa_video::GameVideo::DeleteImage(), dialogues, face_portrait, and hoa_video::VideoManager.

Here is the call graph for this function:


Member Function Documentation

void hoa_map::private_map::VirtualSprite::AddAction ( SpriteAction act  )  [inline]

Definition at line 244 of file map_sprites.h.

References actions, and hoa_map::private_map::SpriteAction::SetSprite().

Here is the call graph for this function:

void hoa_map::private_map::VirtualSprite::AddDialogue ( MapDialogue md  )  [inline]

Definition at line 247 of file map_sprites.h.

References dialogues, hoa_map::private_map::MapDialogue::HasAlreadySeen(), seen_all_dialogue, and hoa_map::private_map::MapDialogue::SetOwner().

Here is the call graph for this function:

uint16 hoa_map::private_map::VirtualSprite::CalculateOppositeDirection ( const uint16  direction  )  [static]

This static class function returns the opposite direction of the direction given in parameter.

Note:
This is mostly used as an helper function to make sprites face each other.

Definition at line 98 of file map_sprites.cpp.

References hoa_map::private_map::EAST, hoa_map::MAP_DEBUG, hoa_map::private_map::NE_EAST, hoa_map::private_map::NE_NORTH, hoa_map::private_map::NORTH, hoa_map::private_map::NW_NORTH, hoa_map::private_map::NW_WEST, hoa_map::private_map::SE_EAST, hoa_map::private_map::SE_SOUTH, hoa_map::private_map::SOUTH, hoa_map::private_map::SW_SOUTH, hoa_map::private_map::SW_WEST, and hoa_map::private_map::WEST.

Referenced by hoa_map::private_map::EnemySprite::Update().

void hoa_map::private_map::VirtualSprite::Draw (  )  [virtual]

Draws a dialogue icon over the virtual sprite if it has to.

Implements hoa_map::private_map::MapObject.

Reimplemented in hoa_map::private_map::MapSprite, and hoa_map::private_map::EnemySprite.

Definition at line 236 of file map_sprites.cpp.

References _dialogue_icon_color, hoa_map::MapMode::_IsShowingDialogueIcons(), hoa_video::GameVideo::DrawImage(), hoa_map::private_map::MapObject::GetImgHeight(), HasDialogue(), IsShowingDialogueIcon(), hoa_video::GameVideo::MoveRelative(), hoa_map::private_map::new_dialogue_icon, seen_all_dialogue, and hoa_video::VideoManager.

Referenced by hoa_map::private_map::MapSprite::Draw().

Here is the call graph for this function:

MapDialogue* hoa_map::private_map::VirtualSprite::GetCurrentDialogue (  )  const [inline]

Definition at line 253 of file map_sprites.h.

References _current_dialogue, and dialogues.

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

uint16 hoa_map::private_map::VirtualSprite::GetDirection (  )  const [inline]

Definition at line 217 of file map_sprites.h.

References direction.

Referenced by hoa_map::MapMode::_HandleInputExplore(), and hoa_map::private_map::EnemySprite::Update().

float hoa_map::private_map::VirtualSprite::GetMovementSpeed (  )  const [inline]

Definition at line 220 of file map_sprites.h.

References movement_speed.

int16 hoa_map::private_map::VirtualSprite::GetNumDialogues (  )  const [inline]

Definition at line 262 of file map_sprites.h.

References dialogues.

bool hoa_map::private_map::VirtualSprite::HasDialogue (  )  const [inline]

Definition at line 250 of file map_sprites.h.

References dialogues.

Referenced by hoa_map::MapMode::_HandleInputExplore(), and Draw().

bool hoa_map::private_map::VirtualSprite::IsShowingDialogueIcon (  )  const [inline]

Definition at line 268 of file map_sprites.h.

References _show_dialogue_icon.

Referenced by Draw().

bool hoa_map::private_map::VirtualSprite::LoadState (  )  [virtual]

This method will load the saved state of a sprite. Attributes loaded: direction, speed, moving state, name, current action.

Returns:
false if there was no saved state, true otherwise.

Reimplemented in hoa_map::private_map::MapSprite.

Definition at line 313 of file map_sprites.cpp.

References _saved, _saved_current_action, _saved_direction, _saved_movement_speed, _saved_moving, _saved_name, current_action, direction, movement_speed, moving, and name.

Referenced by hoa_map::private_map::MapSprite::LoadState().

void hoa_map::private_map::VirtualSprite::NextDialogue (  )  [inline]

Definition at line 259 of file map_sprites.h.

References _current_dialogue, and dialogues.

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

void hoa_map::private_map::VirtualSprite::SaveState (  )  [virtual]

This method will save the state of a sprite. Attributes saved: direction, speed, moving state, name, current action.

Reimplemented in hoa_map::private_map::MapSprite.

Definition at line 299 of file map_sprites.cpp.

References _saved, _saved_current_action, _saved_direction, _saved_movement_speed, _saved_moving, _saved_name, current_action, direction, movement_speed, moving, and name.

Referenced by hoa_map::MapMode::_HandleInputExplore(), and hoa_map::private_map::MapSprite::SaveState().

void hoa_map::private_map::VirtualSprite::SetDialogue ( const int16  dialogue  )  [inline]

Definition at line 256 of file map_sprites.h.

References _current_dialogue, and dialogues.

void hoa_map::private_map::VirtualSprite::SetDirection ( uint16  dir  ) 

Note:
This method takes into account the current direction when setting the new direction in the case of diagonal movement. For example, if the sprite is currently facing north and this function indicates that the sprite should move northwest, it will face north during the northwest movement.

Definition at line 247 of file map_sprites.cpp.

References direction, hoa_map::private_map::EAST, hoa_map::private_map::FACING_EAST, hoa_map::private_map::FACING_NORTH, hoa_map::private_map::FACING_SOUTH, hoa_map::private_map::FACING_WEST, hoa_map::MAP_DEBUG, hoa_map::private_map::NE_EAST, hoa_map::private_map::NE_NORTH, hoa_map::private_map::NORTH, hoa_map::private_map::NORTHEAST, hoa_map::private_map::NORTHWEST, hoa_map::private_map::NW_NORTH, hoa_map::private_map::NW_WEST, hoa_map::private_map::SE_EAST, hoa_map::private_map::SE_SOUTH, hoa_map::private_map::SOUTH, hoa_map::private_map::SOUTHEAST, hoa_map::private_map::SOUTHWEST, hoa_map::private_map::SW_SOUTH, hoa_map::private_map::SW_WEST, and hoa_map::private_map::WEST.

Referenced by hoa_map::MapMode::_HandleInputExplore(), hoa_map::private_map::ActionPathMove::Execute(), SetRandomDirection(), and hoa_map::private_map::EnemySprite::Update().

void hoa_map::private_map::VirtualSprite::SetFacePortrait ( std::string  pn  ) 

Definition at line 287 of file map_sprites.cpp.

References face_portrait, hoa_video::GameVideo::LoadImage(), hoa_video::StillImage::SetFilename(), and hoa_video::VideoManager.

Here is the call graph for this function:

void hoa_map::private_map::VirtualSprite::SetMovementSpeed ( float  speed  )  [inline]

Definition at line 214 of file map_sprites.h.

References movement_speed.

void hoa_map::private_map::VirtualSprite::SetRandomDirection (  ) 

Sets the sprite's direction to a random value This function is used mostly for the ActionRandomMove class.

Definition at line 331 of file map_sprites.cpp.

References hoa_map::private_map::EAST, hoa_map::MAP_DEBUG, hoa_map::private_map::NORTH, hoa_map::private_map::NORTHEAST, hoa_map::private_map::NORTHWEST, hoa_utils::RandomBoundedInteger(), SetDirection(), hoa_map::private_map::SOUTH, hoa_map::private_map::SOUTHEAST, hoa_map::private_map::SOUTHWEST, and hoa_map::private_map::WEST.

Referenced by hoa_map::private_map::ActionRandomMove::Execute().

Here is the call graph for this function:

void hoa_map::private_map::VirtualSprite::ShowDialogueIcon ( bool  state  )  [inline]

Definition at line 265 of file map_sprites.h.

References _show_dialogue_icon.

void hoa_map::private_map::VirtualSprite::Update (  )  [virtual]

Updates the virtual object's position if it is moving, otherwise does nothing.

Implements hoa_map::private_map::MapObject.

Reimplemented in hoa_map::private_map::MapSprite, and hoa_map::private_map::EnemySprite.

Definition at line 121 of file map_sprites.cpp.

References hoa_map::MapMode::_current_map, _dialogue_icon_color, hoa_map::MapMode::_time_elapsed, actions, hoa_map::private_map::MapObject::ComputeXLocation(), hoa_map::private_map::MapObject::ComputeYLocation(), current_action, direction, hoa_map::private_map::EAST, forced_action, movement_speed, moving, hoa_map::private_map::NE_EAST, hoa_map::private_map::NE_NORTH, hoa_map::private_map::new_dialogue_icon, hoa_map::private_map::NORTH, hoa_map::private_map::NW_NORTH, hoa_map::private_map::NW_WEST, hoa_map::private_map::SE_EAST, hoa_map::private_map::SE_SOUTH, hoa_video::Color::SetAlpha(), hoa_map::private_map::SOUTH, hoa_map::private_map::SW_SOUTH, hoa_map::private_map::SW_WEST, hoa_map::private_map::MapObject::updatable, hoa_video::AnimatedImage::Update(), hoa_map::private_map::WEST, hoa_map::private_map::MapObject::x_offset, hoa_map::private_map::MapObject::x_position, hoa_map::private_map::MapObject::y_offset, and hoa_map::private_map::MapObject::y_position.

Referenced by hoa_map::private_map::MapSprite::Update().

Here is the call graph for this function:

void hoa_map::private_map::VirtualSprite::UpdateSeenDialogue (  ) 

Examines all dialogue owned by the sprite and sets the appropriate value of VirtualSprite::seen_all_dialogue.

Definition at line 84 of file map_sprites.cpp.

References dialogues, and seen_all_dialogue.

Referenced by hoa_map::private_map::MapDialogue::ReadNextLine().


Member Data Documentation

int16 hoa_map::private_map::VirtualSprite::_current_dialogue

An index to the dialogues vector, representing the current sprite dialogue to display when talked to by the player. A negative value indicates that the sprite has no dialogue.

Note:
If the sprite has no entries in its dialogues vector, this member should remain negative, otherwise a segmentation fault will occur.

Definition at line 182 of file map_sprites.h.

Referenced by GetCurrentDialogue(), NextDialogue(), and SetDialogue().

hoa_video::Color hoa_map::private_map::VirtualSprite::_dialogue_icon_color

Used to fade the dialogue icon according to distance.

Definition at line 188 of file map_sprites.h.

Referenced by Draw(), and Update().

bool hoa_map::private_map::VirtualSprite::_saved

This indicates if a state was saved or not.

Definition at line 166 of file map_sprites.h.

Referenced by LoadState(), and SaveState().

int8 hoa_map::private_map::VirtualSprite::_saved_current_action

Definition at line 171 of file map_sprites.h.

Referenced by LoadState(), and SaveState().

uint16 hoa_map::private_map::VirtualSprite::_saved_direction

Definition at line 167 of file map_sprites.h.

Referenced by LoadState(), and SaveState().

float hoa_map::private_map::VirtualSprite::_saved_movement_speed

Definition at line 168 of file map_sprites.h.

Referenced by LoadState(), and SaveState().

bool hoa_map::private_map::VirtualSprite::_saved_moving

Definition at line 169 of file map_sprites.h.

Referenced by LoadState(), and SaveState().

hoa_utils::ustring hoa_map::private_map::VirtualSprite::_saved_name

Definition at line 170 of file map_sprites.h.

Referenced by LoadState(), and SaveState().

bool hoa_map::private_map::VirtualSprite::_show_dialogue_icon

Indicates if the icon indicating that there is a dialogue available should be drawn or not.

Definition at line 185 of file map_sprites.h.

Referenced by IsShowingDialogueIcon(), and ShowDialogueIcon().

std::vector<SpriteAction*> hoa_map::private_map::VirtualSprite::actions

A container for all of the actions this sprite performs.

Definition at line 159 of file map_sprites.h.

Referenced by AddAction(), Update(), and ~VirtualSprite().

int8 hoa_map::private_map::VirtualSprite::current_action

An index to the actions vector, representing the current sprite action being performed. A negative value indicates that the sprite is taking no action. If the sprite has no entries in its actions vector, this member should remain negative, otherwise a segmentation fault will occur.

Definition at line 153 of file map_sprites.h.

Referenced by hoa_map::MapMode::_HandleInputExplore(), LoadState(), SaveState(), hoa_map::private_map::EnemySprite::Update(), hoa_map::private_map::MapSprite::Update(), and Update().

std::vector<MapDialogue*> hoa_map::private_map::VirtualSprite::dialogues

This vector contains all the dialogues of the sprite.

Definition at line 175 of file map_sprites.h.

Referenced by AddDialogue(), GetCurrentDialogue(), GetNumDialogues(), HasDialogue(), NextDialogue(), SetDialogue(), UpdateSeenDialogue(), and ~VirtualSprite().

uint16 hoa_map::private_map::VirtualSprite::direction

A bit-mask for the sprite's draw orientation and direction vector. This member determines both where to move the sprite (8 directions) and which way the sprite is facing (4 directions). See the Sprite Directions series of constants for the values that this member may be set to.

Definition at line 121 of file map_sprites.h.

Referenced by hoa_map::MapMode::_FindNearestObject(), GetDirection(), LoadState(), SaveState(), SetDirection(), hoa_map::private_map::MapSprite::Update(), and Update().

hoa_video::StillImage* hoa_map::private_map::VirtualSprite::face_portrait

A pointer to the face portrait of the sprite, as seen in dialogues and menus.

Definition at line 143 of file map_sprites.h.

Referenced by hoa_map::private_map::DialogueManager::Draw(), hoa_map::private_map::MapSprite::MapSprite(), SetFacePortrait(), hoa_map::private_map::MapSprite::~MapSprite(), and ~VirtualSprite().

int8 hoa_map::private_map::VirtualSprite::forced_action

Definition at line 156 of file map_sprites.h.

Referenced by Update().

float hoa_map::private_map::VirtualSprite::movement_speed

The speed at which the sprite moves around the map.

Definition at line 124 of file map_sprites.h.

Referenced by GetMovementSpeed(), hoa_map::private_map::MapSprite::LoadStandardAnimations(), LoadState(), SaveState(), SetMovementSpeed(), and Update().

bool hoa_map::private_map::VirtualSprite::moving

Set to true when the sprite is currently moving.

Note:
This does not necessarily mean that the sprite actually is moving, but rather that the sprite is trying to move in a certain direction.

Definition at line 130 of file map_sprites.h.

Referenced by hoa_map::MapMode::_HandleInputExplore(), hoa_map::private_map::EnemySprite::EnemySprite(), hoa_map::private_map::ActionRandomMove::Execute(), hoa_map::private_map::ActionPathMove::Execute(), LoadState(), SaveState(), hoa_map::private_map::MapSprite::Update(), and Update().

hoa_utils::ustring hoa_map::private_map::VirtualSprite::name

The name of the sprite, as seen by the player in the game.

Definition at line 140 of file map_sprites.h.

Referenced by hoa_map::private_map::DialogueManager::Draw(), LoadState(), SaveState(), and hoa_map::private_map::MapSprite::SetName().

bool hoa_map::private_map::VirtualSprite::seen_all_dialogue

Set to false if the sprite contains dialogue that has not been seen by the player.

Definition at line 146 of file map_sprites.h.

Referenced by AddDialogue(), Draw(), and UpdateSeenDialogue().

bool hoa_map::private_map::VirtualSprite::sky_object

When set to true, indicates that the object exists on the sky object layer (default = false). This member is necessary for collision detection purposes. When a sprite needs to detect if it has encountered a collision, that collision must be examined with other objects on the appropriate layer (the ground or sky layer).

Definition at line 137 of file map_sprites.h.

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


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