V-Gears 0
Free Final Fantasy VII engine.
EntityManager Class Reference

The entity manager. More...

#include <EntityManager.h>

Inheritance diagram for EntityManager:
Collaboration diagram for EntityManager:

Public Member Functions

 EntityManager ()
 Constructor. More...
 
virtual ~EntityManager ()
 Destructor. More...
 
void Input (const VGears::Event &event) override
 Handles an input event. More...
 
void UpdateDebug () override
 Updates the entities in the manager with debug information. More...
 
void OnResize () override
 Handles resizing events. More...
 
void ClearField () override
 Clears all field information in the entity manager. More...
 
void ClearBattle () override
 Clears all battle information in the entity manager. More...
 
void ClearWorld () override
 Clears all world map information in the entity manager. More...
 
WalkmeshGetWalkmesh ()
 Retrieves the walkmesh. More...
 
Background2DGetBackground2D ()
 Retrieves the 2D background. More...
 
void AddEntity (const Ogre::String &name, const Ogre::String &file_name, const Ogre::Vector3 &position, const Ogre::Degree &direction, int index)
 Adds an entity to the manager. More...
 
void AddEntity (const Ogre::String &name, const Ogre::String &file_name, const Ogre::Vector3 &position, const Ogre::Degree &rotation, const Ogre::Vector3 &scale, const Ogre::Quaternion &root_orientation, const int index)
 Adds a field entity to the manager. More...
 
void ScriptAddEntity (const char *name, const char *file_name, const float x, const float y, const float z, const float direction, int index)
 Adds an entity to the manager. More...
 
void AddEntityTrigger (const Ogre::String &name, const Ogre::Vector3 &point1, const Ogre::Vector3 &point2, const bool enabled)
 Adds an entity trigger to the manager. More...
 
void AddEntityPoint (const Ogre::String &name, const Ogre::Vector3 &position, const float rotation)
 Adds an entity point to the manager. More...
 
void AddEntityScript (const Ogre::String &name)
 Adds an entity script to the manager. More...
 
void ScriptAddEntityScript (const char *name)
 Adds an entity script to the manager. More...
 
EntityGetEntity (const Ogre::String &name) const
 Retrieves an entity by name. More...
 
EntityGetEntityFromIndex (const int id) const
 Retrieves an entity by it's index in the field. More...
 
EntityGetEntityFromCharacterId (const int id) const
 Retrieves an entity by it's assigned character ID. More...
 
EntityScriptGetEntity (const char *name) const
 Retrieves an entity by name. More...
 
EntityPointScriptGetEntityPoint (const char *name) const
 Retrieves an entity point by name. More...
 
void ScriptSetPlayerEntity (const char *name)
 Sets the playable entity. More...
 
EntityScriptGetPlayerEntity () const
 Retrieves the playable entity. More...
 
void ScriptUnsetPlayerEntity ()
 Unsets any playable entities. More...
 
void ScriptPlayerLock (const bool lock)
 Locks or unlocks player control of the playable entity. More...
 
void SetPlayerMoveRotation (const Ogre::Radian rotation)
 Sets the baseline rotation for the player controlled entity. More...
 
bool GetRandomEncounters ()
 Checks if random battle encounters are active in the field. More...
 
void SetRandomEncounters (bool active)
 Enables or disables random encounters in the field. More...
 
float GetEncounterRate ()
 Get the encounter rate for the field. More...
 
void SetEncounterRate (float rate)
 Sets the battle encounter rate. More...
 
bool IsKeyOn (unsigned int key_code)
 Checks if a key is being pressed. More...
 
bool IsKeyOff (unsigned int key_code)
 Checks if a key is not being pressed. More...
 
void SetEntityToCharacter (const char *entity_name, unsigned int char_id)
 Assigns a character to an entity. More...
 
EntityGetBackground3D () const
 Retrieves the entity associated to the 3D background. More...
 
void SetBackground3D (const Ogre::String &name, const Ogre::String &file_name)
 Sets the 3D model for the background. More...
 
- Public Member Functions inherited from Manager
 Manager ()
 Constructor. More...
 
virtual ~Manager ()
 Destructor. More...
 
Module GetModule () const
 Retrieves the currently selected module. More...
 
bool IsModule (const Module module) const
 Checks the currently selected module. More...
 
bool IsFieldModule () const
 Checks if the currently selected module is the field module. More...
 
bool IsBattleModule () const
 Checks if the currently selected module is the battle module. More...
 
bool IsWorldModule () const
 Checks if the currently selected module is the world module. More...
 
void SetModule (const Module module)
 Sets the current module for the entity manager. More...
 
void SetFieldModule ()
 Sets the current module to the field mode. More...
 
void SetBattleModule ()
 Sets the current module to the battle mode. More...
 
void SetWorldModule ()
 Sets the current module to the world map mode. More...
 
void SetPreviousModule ()
 Sets the module that was loaded before a battle. More...
 
virtual void Input (const VGears::Event &event)=0
 Handles an input event. More...
 
void Update ()
 Called every frame, performs an update on the things controlled by the manager. More...
 
virtual void UpdateDebug ()=0
 Called every frame, performs an update on the things controlled by the manager. More...
 
virtual void OnResize ()=0
 Handles resizing events. More...
 
void Clear ()
 Clears the manager. More...
 
void Clear (const Module module)
 Clears the manager. More...
 
virtual void ClearField ()=0
 Clear all field information in the manager. More...
 
virtual void ClearBattle ()=0
 Clear all battle information in the manager. More...
 
virtual void ClearWorld ()=0
 Clear all world map information in the manager. More...
 
void ClearAll ()
 Clears the manager. More...
 
void ScriptSetPaused (const bool paused)
 Handles game pausing. More...
 

Private Member Functions

void UpdateField () override
 Updates the field entities in the manager. More...
 
void UpdateBattle () override
 Updates the battle entities in the manager. More...
 
void UpdateWorld () override
 Updates the world map entities in the manager. More...
 
void AddFieldOrWorldMapEntity (const Ogre::String &name, const Ogre::String &file_name, const Ogre::Vector3 &position, const Ogre::Degree &rotation, const Ogre::Vector3 &scale, const Ogre::Quaternion &root_orientation, const int index)
 Adds a field entity to the manager. More...
 
void AddBattleEntity (const Ogre::String &name, const Ogre::String &file_name, const Ogre::Vector3 &position, const Ogre::Degree &orientation, const Ogre::Vector3 &scale, const Ogre::Quaternion &root_orientation, const int index)
 Adds a battle entity to the manager. More...
 
bool SetEntityOnWalkmesh (Entity *entity)
 Attaches an entity to the walkmesh. More...
 
bool PerformWalkmeshMove (Entity *entity, const float speed)
 Moves an entity in the walkmesh. More...
 
bool WalkmeshBorderCross (Entity *entity, Ogre::Vector3 &position, const Ogre::Vector2 &move_vector)
 Checks if the entity is crossing a walkmesh triangle border. More...
 
bool CheckSolidCollisions (Entity *entity, Ogre::Vector3 &position)
 Checks for collisions of the entity with other entities. More...
 
void SetEntityDirectionByVector (Entity *entity, const Ogre::Vector2 &vector)
 Sets an entity direction. More...
 
void CheckTriggers (Entity *entity, const Ogre::Vector3 &position)
 Checks for entity triggers near a entity. More...
 
void CheckEntityInteract ()
 Checks if an entity can be interacted. More...
 
void SetNextOffsetStep (Entity *entity)
 Calculates the next offset step for an entity. More...
 
void SetNextTurnStep (Entity *entity)
 Calculates the next turn step for an entity. More...
 
void SetNextLinearStep (Entity *entity)
 Calculates and sets the next position during a linear movement. More...
 
void SetNextJumpStep (Entity *entity)
 Calculates and sets the next position during a jump. More...
 
void SetNextScrollStep ()
 

Static Private Member Functions

static float PointElevation (const Ogre::Vector2 &point, const Ogre::Vector3 &a, const Ogre::Vector3 &b, const Ogre::Vector3 &c)
 Calculates the point elevation over a plane. More...
 
static float SideOfVector (const Ogre::Vector2 &point, const Ogre::Vector2 &p1, const Ogre::Vector2 &p2)
 Determines at which side of a line a point is. More...
 
static float SquareDistanceToLine (const Ogre::Vector3 &point, const Ogre::Vector3 &point_a, const Ogre::Vector3 &point_b, Ogre::Vector3 &proj)
 Calculates the square distance between a point and a line. More...
 
static Ogre::Degree GetDirectionToPoint (const Ogre::Vector3 &current_point, const Ogre::Vector3 &direction_point)
 Calculates the direction degree between to points. More...
 

Private Attributes

Walkmesh walkmesh_
 The map walkmesh. More...
 
Background2D background_2d_
 The map background. More...
 
Ogre::String entity_table_name_
 The entity table name. More...
 
std::vector< Entity * > entity_
 The list of field or world entities. More...
 
std::vector< Entity * > battle_entity_
 The list of battle entities. More...
 
Entitybackground_3d_
 A 3D background. More...
 
Entityplayer_entity_
 The player controlled entity. More...
 
Ogre::Vector3 player_move_
 The playable entity current movement indicator. More...
 
Ogre::Radian player_move_rotation_
 The playable entity current movement turn indicator. More...
 
bool player_lock_
 Indicates if player control is locked. More...
 
bool player_run_
 Indicates if the playable is being moved by running. More...
 
std::vector< EntityTrigger * > entity_triggers_
 List of triggers. More...
 
std::vector< EntityPoint * > entity_points_
 List of points. More...
 
std::vector< Ogre::String > entity_scripts_
 List of scripts. More...
 
Ogre::SceneNode * scene_node_
 The scene node. More...
 
Ogre::Entity * grid_
 
Ogre::Entity * axis_
 
bool random_encounters_
 Indicates if random encounters happen in the map. More...
 
float encounter_rate_
 The encounter rate of the map. More...
 

Static Private Attributes

static const float SCENE_SCALE = 0.003f
 Scale factor for battle background models. More...
 
static const unsigned int BATTLE_BACKGROUND_ID = 1000
 Entity ID for battle background entity. More...
 
static const unsigned int WORLD_MAP_BACKGROUND_ID = 1001
 Entity ID for world map background entity. More...
 

Additional Inherited Members

- Public Types inherited from Manager
enum  Module { FIELD = 0 , BATTLE = 1 , WORLD = 2 }
 The modules the entity manager can handle. More...
 
- Protected Member Functions inherited from Manager
virtual void UpdateField ()=0
 Updates the field entities in the manager. More...
 
virtual void UpdateBattle ()=0
 Updates the battle entities in the manager. More...
 
virtual void UpdateWorld ()=0
 Updates the world map entities in the manager. More...
 
void Update (Module module)
 Updates the entities of one module in the manager. More...
 
- Protected Attributes inherited from Manager
Module module_
 The currently selected module. More...
 
Module prev_module_
 The previous module. More...
 
bool paused_
 Indicates if the game is paused. More...
 

Detailed Description

The entity manager.

Constructor & Destructor Documentation

◆ EntityManager()

EntityManager::EntityManager ( )

Constructor.

◆ ~EntityManager()

EntityManager::~EntityManager ( )
virtual

Destructor.

Member Function Documentation

◆ AddBattleEntity()

void EntityManager::AddBattleEntity ( const Ogre::String &  name,
const Ogre::String &  file_name,
const Ogre::Vector3 &  position,
const Ogre::Degree &  orientation,
const Ogre::Vector3 &  scale,
const Ogre::Quaternion &  root_orientation,
const int  index 
)
private

Adds a battle entity to the manager.

If the manager is not in the battle module, it will do nothing.

Parameters
[in]nameEntity name.
[in]file_namePath to the entity model file.
[in]positionEntity position.
[in]rotationEntity face direction.
[in]scaleEntity scale.
[in]root_orientationThe node orientation.
[in]indexIndex of the entity.

◆ AddEntity() [1/2]

void EntityManager::AddEntity ( const Ogre::String &  name,
const Ogre::String &  file_name,
const Ogre::Vector3 &  position,
const Ogre::Degree &  direction,
int  index 
)

Adds an entity to the manager.

The entity will be added to the EntityManager current module entity list.

Parameters
[in]nameEntity name.
[in]file_namePath to the entity model file.
[in]positionEntity position.
[in]directionEntity face direction.
[in]indexIndex of the entity on the manager.

◆ AddEntity() [2/2]

void EntityManager::AddEntity ( const Ogre::String &  name,
const Ogre::String &  file_name,
const Ogre::Vector3 &  position,
const Ogre::Degree &  rotation,
const Ogre::Vector3 &  scale,
const Ogre::Quaternion &  root_orientation,
const int  index 
)

Adds a field entity to the manager.

The entity will be added to the EntityManager current module entity list.

Parameters
[in]nameEntity name.
[in]file_namePath to the entity model file.
[in]positionEntity position.
[in]rotationEntity face direction.
[in]scaleEntity scale.
[in]root_orientationEntity orientation. Unused for battle and world map entities.
[in]indexIndex of the entity on the manager.

◆ AddEntityPoint()

void EntityManager::AddEntityPoint ( const Ogre::String &  name,
const Ogre::Vector3 &  position,
const float  rotation 
)

Adds an entity point to the manager.

If the Battle manager is in battle mode, nothing will be done.

Parameters
[in]nameEntity point name.
[in]positionEntity point position.
[in]rotationThe point orientation.

◆ AddEntityScript()

void EntityManager::AddEntityScript ( const Ogre::String &  name)

Adds an entity script to the manager.

Parameters
[in]nameEntity script name.

◆ AddEntityTrigger()

void EntityManager::AddEntityTrigger ( const Ogre::String &  name,
const Ogre::Vector3 &  point1,
const Ogre::Vector3 &  point2,
const bool  enabled 
)

Adds an entity trigger to the manager.

A trigger is a line that does something when approached or crossed. If the Battle manager is in battle mode, nothing will be done.

Parameters
[in]nameEntity trigger name.
[in]point1One point of the trigger line.
[in]point2One point of the trigger line.
[in]enabledTrue to enable the trigger, false to leave it disabled.

◆ AddFieldOrWorldMapEntity()

void EntityManager::AddFieldOrWorldMapEntity ( const Ogre::String &  name,
const Ogre::String &  file_name,
const Ogre::Vector3 &  position,
const Ogre::Degree &  rotation,
const Ogre::Vector3 &  scale,
const Ogre::Quaternion &  root_orientation,
const int  index 
)
private

Adds a field entity to the manager.

Parameters
[in]nameEntity name.
[in]file_namePath to the entity model file.
[in]positionEntity position in the map.
[in]rotationEntity face direction.
[in]scaleEntity scale.
[in]root_orientationMap orientation. Unused for world map entities.
[in]indexIndex of the entity on the map.

◆ CheckEntityInteract()

void EntityManager::CheckEntityInteract ( )
private

Checks if an entity can be interacted.

It checks if there are entities that can be interacted with from the players current position and orientation. If there are, the most appropriate one is selected and, if it has an on_interact script, it is run. If the manager is in battle mode, it will do nothing.

◆ CheckSolidCollisions()

bool EntityManager::CheckSolidCollisions ( Entity entity,
Ogre::Vector3 &  position 
)
private

Checks for collisions of the entity with other entities.

Parameters
[in]entityEntity to check for collisions.
[in]positionPosition of the entity.
Returns
True if the entity is colliding with another, false otherwise. If the entity is not solid, always false. If the manager is in battle mode, it will always return false.

◆ CheckTriggers()

void EntityManager::CheckTriggers ( Entity entity,
const Ogre::Vector3 &  position 
)
private

Checks for entity triggers near a entity.

If there are triggers, and the conditions are met, the appropriate trigger function will be added to the queue. This must be tested every time an entity moves. If the entity is not the playable character, is not solid or is locked, it will do nothing. If the manager is in battle mode, it will do nothing.

Parameters
[in]entityEntity to check for nearby triggers.
[in]positionThe position of the entity.

◆ ClearBattle()

void EntityManager::ClearBattle ( )
overridevirtual

Clears all battle information in the entity manager.

It clears any pending actions and all the battle entities.

Implements Manager.

◆ ClearField()

void EntityManager::ClearField ( )
overridevirtual

Clears all field information in the entity manager.

It clears the background, the walkmesh, any pending actions and all the field entities.

Implements Manager.

◆ ClearWorld()

void EntityManager::ClearWorld ( )
overridevirtual

Clears all world map information in the entity manager.

It clears the background, the walkmesh, any pending actions and all the world entities.

Implements Manager.

◆ GetBackground2D()

Background2D * EntityManager::GetBackground2D ( )

Retrieves the 2D background.

Returns
The 2D background.

◆ GetBackground3D()

Entity * EntityManager::GetBackground3D ( ) const

Retrieves the entity associated to the 3D background.

Returns
The 3D background entity. nullptr if not set, of if the manager is in field mode.

◆ GetDirectionToPoint()

Ogre::Degree EntityManager::GetDirectionToPoint ( const Ogre::Vector3 &  current_point,
const Ogre::Vector3 &  direction_point 
)
staticprivate

Calculates the direction degree between to points.

Parameters
[in]current_pointOrigin point.
[in]direction_pointNext point in the direction.
Returns
Degrees between the two points

◆ GetEncounterRate()

float EntityManager::GetEncounterRate ( )

Get the encounter rate for the field.

Returns
The encounter rate, between 0 and 1 (both included).

◆ GetEntity()

Entity * EntityManager::GetEntity ( const Ogre::String &  name) const

Retrieves an entity by name.

Only entities of the current active module will be searched.

Parameters
[in]nameName of the entity to retrieve.
Returns
The entity by the specified name, or nullptr if there is no one.

◆ GetEntityFromCharacterId()

Entity * EntityManager::GetEntityFromCharacterId ( const int  id) const

Retrieves an entity by it's assigned character ID.

Only entities of the current active module will be searched.

Parameters
[in]idCharacter ID of the entity to retrieve.
Returns
The entity assigned to the character, or nullptr if there is no one.

◆ GetEntityFromIndex()

Entity * EntityManager::GetEntityFromIndex ( const int  id) const

Retrieves an entity by it's index in the field.

Only entities of the current active module will be searched.

Parameters
[in]idIndex of the entity to retrieve.
Returns
The entity with the ID, or nullptr if there is no one.

◆ GetRandomEncounters()

bool EntityManager::GetRandomEncounters ( )

Checks if random battle encounters are active in the field.

Returns
True if random battles can occur, false otherwise.

◆ GetWalkmesh()

Walkmesh * EntityManager::GetWalkmesh ( )

Retrieves the walkmesh.

Returns
The walkmesh.

◆ Input()

void EntityManager::Input ( const VGears::Event event)
overridevirtual

Handles an input event.

Parameters
[in]eventEvent to handle.

Implements Manager.

◆ IsKeyOff()

bool EntityManager::IsKeyOff ( unsigned int  key_code)

Checks if a key is not being pressed.

Parameters
[in]key_codeThe code of the key to test.
Returns
False if the key is being pressed, true otherwise.

◆ IsKeyOn()

bool EntityManager::IsKeyOn ( unsigned int  key_code)

Checks if a key is being pressed.

Parameters
[in]key_codeThe code of the key to test.
Returns
True if the key is being pressed, false otherwise.

◆ OnResize()

void EntityManager::OnResize ( )
overridevirtual

Handles resizing events.

Implements Manager.

◆ PerformWalkmeshMove()

bool EntityManager::PerformWalkmeshMove ( Entity entity,
const float  speed 
)
private

Moves an entity in the walkmesh.

If the manager is in battle mode, it will do nothing.

Parameters
[in]entityEntity to move.
[in]speedMovement speed.
Returns
True if the movement was possible and the entity was moved, false otherwise. If the manager is in battle mode, it will always return false.

◆ PointElevation()

float EntityManager::PointElevation ( const Ogre::Vector2 &  point,
const Ogre::Vector3 &  a,
const Ogre::Vector3 &  b,
const Ogre::Vector3 &  c 
)
staticprivate

Calculates the point elevation over a plane.

Parameters
[in]pointPoint to calculate the elevation of.
[in]aFirst point of the plane.
[in]bSecond point of the plane.
[in]cThird point of the plane.
Returns
The elevation of the point.

◆ ScriptAddEntity()

void EntityManager::ScriptAddEntity ( const char *  name,
const char *  file_name,
const float  x,
const float  y,
const float  z,
const float  direction,
int  index 
)

Adds an entity to the manager.

Simplified version of {

See also
AddEntity}, to be called from Lua scripts.
Parameters
[in]nameEntity name.
[in]file_namePath to the entity model file.
[in]xX coordinate of the entity position in the map.
[in]yY coordinate of the entity position in the map.
[in]zZ coordinate of the entity position in the map.
[in]directionEntity face direction.
[in]indexIndex of the entity on the manager.

◆ ScriptAddEntityScript()

void EntityManager::ScriptAddEntityScript ( const char *  name)

Adds an entity script to the manager.

Parameters
[in]nameEntity script name.

◆ ScriptGetEntity()

Entity * EntityManager::ScriptGetEntity ( const char *  name) const

Retrieves an entity by name.

Only entities of the current active module will be searched.

Parameters
[in]nameName of the entity to retrieve.
Returns
The entity by the specified name, or nullptr if there is no one.

◆ ScriptGetEntityPoint()

EntityPoint * EntityManager::ScriptGetEntityPoint ( const char *  name) const

Retrieves an entity point by name.

Parameters
[in]nameName of the entity point to retrieve.
Returns
The entity point by the specified name, or nullptr if there is no one or the manager is in battle mode.

◆ ScriptGetPlayerEntity()

Entity * EntityManager::ScriptGetPlayerEntity ( ) const

Retrieves the playable entity.

Returns
The playable entity, or nullptr if it's not defined or the EntityManager is in battle mode.

◆ ScriptPlayerLock()

void EntityManager::ScriptPlayerLock ( const bool  lock)

Locks or unlocks player control of the playable entity.

If the EntityManager is in battle mode, nothing will be done.

Parameters
[in]lockTrue to lock, false to unlock.

◆ ScriptSetPlayerEntity()

void EntityManager::ScriptSetPlayerEntity ( const char *  name)

Sets the playable entity.

If no entities are found by name, no one will be assigned, the previous playable entity will remain so, and no warning will be issued. Also, if the EntityManager is in battle mode, nothing will be done.

Parameters
[in]nameName of the entity to make playable.

◆ ScriptUnsetPlayerEntity()

void EntityManager::ScriptUnsetPlayerEntity ( )

Unsets any playable entities.

If the EntityManager is in battle mode, nothing will be done.

◆ SetBackground3D()

void EntityManager::SetBackground3D ( const Ogre::String &  name,
const Ogre::String &  file_name 
)

Sets the 3D model for the background.

Parameters
[in]namename for the background entity, for debugging purposes only.
[in]file_namePath to the 3D model file.

◆ SetEncounterRate()

void EntityManager::SetEncounterRate ( float  rate)

Sets the battle encounter rate.

Parameters
[in]rateThe encounter rate (0-1).

◆ SetEntityDirectionByVector()

void EntityManager::SetEntityDirectionByVector ( Entity entity,
const Ogre::Vector2 &  vector 
)
private

Sets an entity direction.

Parameters
[in]entityEntity whose direction is to be set.
[in]vectorDirection vector.

◆ SetEntityOnWalkmesh()

bool EntityManager::SetEntityOnWalkmesh ( Entity entity)
private

Attaches an entity to the walkmesh.

It sets the triangle from the entity position coordinates. To account for multiple triangles on different levels, it uses only the X and Y coordinates, and automatically sets the Z one to the closest triangle. If the manager is in battle mode, it will do nothing.

Parameters
[in]entityEntity to attach.
Returns
True if the entity was assigned to a walkmesh triangle, false if the entity is not in a triangle or if the manager is in battle mode.

◆ SetEntityToCharacter()

void EntityManager::SetEntityToCharacter ( const char *  entity_name,
unsigned int  char_id 
)

Assigns a character to an entity.

Only entities of the currently active module can be assigned

Parameters
[in]entity_nameThe entity name.
[in]char_idThe character ID.

◆ SetNextJumpStep()

void EntityManager::SetNextJumpStep ( Entity entity)
private

Calculates and sets the next position during a jump.

If the manager is in battle mode, it will do nothing

Parameters
[in]entityThe jump entity.

◆ SetNextLinearStep()

void EntityManager::SetNextLinearStep ( Entity entity)
private

Calculates and sets the next position during a linear movement.

If the manager is in battle mode, it will do nothing

Parameters
[in]entityThe moving entity.

◆ SetNextOffsetStep()

void EntityManager::SetNextOffsetStep ( Entity entity)
private

Calculates the next offset step for an entity.

Parameters
[in]entityThe entity.

◆ SetNextScrollStep()

void EntityManager::SetNextScrollStep ( )
private
Todo:
Understand and document.

◆ SetNextTurnStep()

void EntityManager::SetNextTurnStep ( Entity entity)
private

Calculates the next turn step for an entity.

Parameters
[in]entityThe entity.

◆ SetPlayerMoveRotation()

void EntityManager::SetPlayerMoveRotation ( const Ogre::Radian  rotation)

Sets the baseline rotation for the player controlled entity.

If the EntityManager is in battle mode, nothing will be done.

Parameters
[in]rotationBaseline rotation.
Todo:
Verify this description.

◆ SetRandomEncounters()

void EntityManager::SetRandomEncounters ( bool  active)

Enables or disables random encounters in the field.

Parameters
[in]activeTrue to enable encounters, false to deactivate them.

◆ SideOfVector()

float EntityManager::SideOfVector ( const Ogre::Vector2 &  point,
const Ogre::Vector2 &  p1,
const Ogre::Vector2 &  p2 
)
staticprivate

Determines at which side of a line a point is.

Parameters
[in]pointThe point to evaluate.
[in]p1The first point of the line.
[in]p2The second point of the line.
Returns
A negative value if the point is on the "left" of the line vector, a positive value if the point is on the "right" of the vector line, or 0 if the point is part of the line. "Left" and "right" are determined by going from p1 to p2.

◆ SquareDistanceToLine()

float EntityManager::SquareDistanceToLine ( const Ogre::Vector3 &  point,
const Ogre::Vector3 &  point_a,
const Ogre::Vector3 &  point_b,
Ogre::Vector3 &  proj 
)
staticprivate

Calculates the square distance between a point and a line.

The calculated distance is the vector orthogonal to the line that passes by the point, i.e. the shortest distance.

Parameters
[in]pointThe point.
[in]point_aFirst point of the line.
[in]point_bSecond point of the line.
[out]projVector representing the shortest distance.
Returns
The distance from the point to the line.

◆ UpdateBattle()

void EntityManager::UpdateBattle ( )
overrideprivatevirtual

Updates the battle entities in the manager.

Implements Manager.

◆ UpdateDebug()

void EntityManager::UpdateDebug ( )
overridevirtual

Updates the entities in the manager with debug information.

It's automatically called from {

See also
Update}.

Implements Manager.

◆ UpdateField()

void EntityManager::UpdateField ( )
overrideprivatevirtual

Updates the field entities in the manager.

Implements Manager.

◆ UpdateWorld()

void EntityManager::UpdateWorld ( )
overrideprivatevirtual

Updates the world map entities in the manager.

Implements Manager.

◆ WalkmeshBorderCross()

bool EntityManager::WalkmeshBorderCross ( Entity entity,
Ogre::Vector3 &  position,
const Ogre::Vector2 &  move_vector 
)
private

Checks if the entity is crossing a walkmesh triangle border.

Parameters
[in]entityEntity to check.
[in]positionThe position.
Todo:
document more.
Parameters
[in]move_vectorThe move vector.
Todo:
document more.
Returns
True if the entity is crossing a triangle border, false otherwise. If the manager is in battle mode, it will always return false.

Member Data Documentation

◆ axis_

Ogre::Entity* EntityManager::axis_
private
Todo:
Understand and document.

◆ background_2d_

Background2D EntityManager::background_2d_
private

The map background.

◆ background_3d_

Entity* EntityManager::background_3d_
private

A 3D background.

◆ BATTLE_BACKGROUND_ID

const unsigned int EntityManager::BATTLE_BACKGROUND_ID = 1000
staticprivate

Entity ID for battle background entity.

◆ battle_entity_

std::vector<Entity*> EntityManager::battle_entity_
private

The list of battle entities.

◆ encounter_rate_

float EntityManager::encounter_rate_
private

The encounter rate of the map.

◆ entity_

std::vector<Entity*> EntityManager::entity_
private

The list of field or world entities.

◆ entity_points_

std::vector<EntityPoint*> EntityManager::entity_points_
private

List of points.

◆ entity_scripts_

std::vector<Ogre::String> EntityManager::entity_scripts_
private

List of scripts.

◆ entity_table_name_

Ogre::String EntityManager::entity_table_name_
private

The entity table name.

◆ entity_triggers_

std::vector<EntityTrigger*> EntityManager::entity_triggers_
private

List of triggers.

◆ grid_

Ogre::Entity* EntityManager::grid_
private
Todo:
Understand and document.

◆ player_entity_

Entity* EntityManager::player_entity_
private

The player controlled entity.

◆ player_lock_

bool EntityManager::player_lock_
private

Indicates if player control is locked.

◆ player_move_

Ogre::Vector3 EntityManager::player_move_
private

The playable entity current movement indicator.

Applies only for manual movement.

◆ player_move_rotation_

Ogre::Radian EntityManager::player_move_rotation_
private

The playable entity current movement turn indicator.

Applies only for manual movement.

◆ player_run_

bool EntityManager::player_run_
private

Indicates if the playable is being moved by running.

Applies only for manual movement.

◆ random_encounters_

bool EntityManager::random_encounters_
private

Indicates if random encounters happen in the map.

◆ scene_node_

Ogre::SceneNode* EntityManager::scene_node_
private

The scene node.

◆ SCENE_SCALE

const float EntityManager::SCENE_SCALE = 0.003f
staticprivate

Scale factor for battle background models.

◆ walkmesh_

Walkmesh EntityManager::walkmesh_
private

The map walkmesh.

◆ WORLD_MAP_BACKGROUND_ID

const unsigned int EntityManager::WORLD_MAP_BACKGROUND_ID = 1001
staticprivate

Entity ID for world map background entity.


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