RigsofRods
Soft-body Physics Simulation
Private Attributes
RoR::GameContext Class Reference

Central game state manager. More...

#include <GameContext.h>

+ Collaboration diagram for RoR::GameContext:

Public Member Functions

Message queue
void PushMessage (Message m)
 Doesn't guarantee order! Use ChainMessage() if order matters. More...
 
void ChainMessage (Message m)
 Add to last pushed message's chain. More...
 
bool HasMessages ()
 
Message PopMessage ()
 
Terrain
bool LoadTerrain (std::string const &filename_part)
 
void UnloadTerrain ()
 
const TerrainPtrGetTerrain ()
 
Actors
ActorPtr SpawnActor (ActorSpawnRequest &rq)
 
void ModifyActor (ActorModifyRequest &rq)
 
void DeleteActor (ActorPtr actor)
 
void UpdateActors ()
 
ActorManagerGetActorManager ()
 
const ActorPtrFetchPrevVehicleOnList ()
 
const ActorPtrFetchNextVehicleOnList ()
 
ActorPtr FindActorByCollisionBox (std::string const &ev_src_instance_name, std::string const &box_name)
 
void RespawnLastActor ()
 
void SpawnPreselectedActor (std::string const &preset_vehicle, std::string const &preset_veh_config)
 needs Character to exist More...
 
const ActorPtrGetPlayerActor ()
 
const ActorPtrGetPrevPlayerActor ()
 
void SetPrevPlayerActor (ActorPtr actor)
 
void ChangePlayerActor (ActorPtr actor)
 
void ShowLoaderGUI (int type, const Ogre::String &instance, const Ogre::String &box)
 
void OnLoaderGuiCancel ()
 GUI callback. More...
 
void OnLoaderGuiApply (RoR::LoaderType type, CacheEntry *entry, std::string sectionconfig)
 GUI callback. More...
 
Characters


void CreatePlayerCharacter ()
 Terrain must be loaded. More...
 
CharacterGetPlayerCharacter ()
 
CharacterFactoryGetCharacterFactory ()
 
Savegames
void LoadScene (std::string const &filename)
 Matching terrain must be already loaded. More...
 
void SaveScene (std::string const &filename)
 
std::string GetQuicksaveFilename ()
 For currently loaded terrain (cvar 'sim_terrain_name') More...
 
std::string ExtractSceneName (std::string const &filename)
 
std::string ExtractSceneTerrain (std::string const &filename)
 Returns terrain filename. More...
 
void HandleSavegameHotkeys ()
 
Gameplay feats (misc.)
RaceSystemGetRaceSystem ()
 
RepairModeGetRepairMode ()
 
SceneMouseGetSceneMouse ()
 
void TeleportPlayer (float x, float z)
 
void UpdateGlobalInputEvents ()
 
void UpdateSimInputEvents (float dt)
 
void UpdateSkyInputEvents (float dt)
 
void UpdateCommonInputEvents (float dt)
 
void UpdateAirplaneInputEvents (float dt)
 
void UpdateBoatInputEvents (float dt)
 
void UpdateTruckInputEvents (float dt)
 

Private Attributes

GameMsgQueue m_msg_queue
 
Messagem_msg_chain_end = nullptr
 
std::mutex m_msg_mutex
 
TerrainPtr m_terrain
 
ActorManager m_actor_manager
 
ActorPtr m_player_actor = nullptr
 Actor (vehicle or machine) mounted and controlled by player. More...
 
ActorPtr m_prev_player_actor = nullptr
 Previous actor (vehicle or machine) mounted and controlled by player. More...
 
ActorPtr m_last_spawned_actor = nullptr
 Last actor spawned by user and still alive. More...
 
CacheEntrym_last_cache_selection = nullptr
 Vehicle/load. More...
 
CacheEntrym_last_skin_selection = nullptr
 
Ogre::String m_last_section_config
 
ActorSpawnRequest m_current_selection
 Context of the loader UI. More...
 
CacheEntry m_dummy_cache_selection
 
CharacterFactory m_character_factory
 
RaceSystem m_race_system
 
RepairMode m_recovery_mode
 Aka 'advanced repair' or 'interactive reset'. More...
 
SceneMouse m_scene_mouse
 Mouse interaction with scene. More...
 
Ogre::Timer m_timer
 
Ogre::Vector3 prev_pos = Ogre::Vector3::ZERO
 

Detailed Description

Central game state manager.

RoR's gameplay is quite simple in structure, it consists of:

CAUTION: PushMessage() doesn't guarantee order of processing: if message handler generates additional messages, it moves the original message at the end of the queue. To illustrate:

  1. Start with empty queue.
  2. push A.
  3. push B which needs A.
  4. Process the queue.
  5. pop A, which needs C done first. It pushes C and re-pushes A.
  6. Queue is now BCA. B fails because A wasn't done.

Message chaining is for situations where message order must be preserved.

  1. Start with empty queue
  2. push A.
  3. chain B which needs A. - it's added to A's chain: A{B}.
  4. Process the queue.
  5. pop A, which needs C done first. It pushes C and re-pushes A{B}.
  6. Queue is now C, A{B}. B succeeds because A gets done first.

Definition at line 96 of file GameContext.h.

Member Function Documentation

◆ ChainMessage()

void GameContext::ChainMessage ( Message  m)

Add to last pushed message's chain.

Definition at line 62 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ChangePlayerActor()

void GameContext::ChangePlayerActor ( ActorPtr  actor)

Definition at line 432 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreatePlayerCharacter()

void GameContext::CreatePlayerCharacter ( )

Terrain must be loaded.

Definition at line 772 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteActor()

void GameContext::DeleteActor ( ActorPtr  actor)

Definition at line 371 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ExtractSceneName()

std::string GameContext::ExtractSceneName ( std::string const &  filename)

Definition at line 73 of file Savegame.cpp.

+ Here is the call graph for this function:

◆ ExtractSceneTerrain()

std::string GameContext::ExtractSceneTerrain ( std::string const &  filename)

Returns terrain filename.

Definition at line 85 of file Savegame.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FetchNextVehicleOnList()

const ActorPtr & GameContext::FetchNextVehicleOnList ( )

Definition at line 540 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FetchPrevVehicleOnList()

const ActorPtr & GameContext::FetchPrevVehicleOnList ( )

Definition at line 535 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindActorByCollisionBox()

ActorPtr GameContext::FindActorByCollisionBox ( std::string const &  ev_src_instance_name,
std::string const &  box_name 
)

Definition at line 550 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetActorManager()

ActorManager* RoR::GameContext::GetActorManager ( )
inline

Definition at line 124 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetCharacterFactory()

CharacterFactory* RoR::GameContext::GetCharacterFactory ( )
inline

Definition at line 147 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetPlayerActor()

const ActorPtr& RoR::GameContext::GetPlayerActor ( )
inline

Definition at line 131 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetPlayerCharacter()

Character * GameContext::GetPlayerCharacter ( )

Definition at line 825 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPrevPlayerActor()

const ActorPtr& RoR::GameContext::GetPrevPlayerActor ( )
inline

Definition at line 132 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetQuicksaveFilename()

std::string GameContext::GetQuicksaveFilename ( )

For currently loaded terrain (cvar 'sim_terrain_name')

Definition at line 54 of file Savegame.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetRaceSystem()

RaceSystem& RoR::GameContext::GetRaceSystem ( )
inline

Definition at line 165 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetRepairMode()

RepairMode& RoR::GameContext::GetRepairMode ( )
inline

Definition at line 166 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetSceneMouse()

SceneMouse& RoR::GameContext::GetSceneMouse ( )
inline

Definition at line 167 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetTerrain()

const TerrainPtr& RoR::GameContext::GetTerrain ( )
inline

Definition at line 114 of file GameContext.h.

+ Here is the caller graph for this function:

◆ HandleSavegameHotkeys()

void GameContext::HandleSavegameHotkeys ( )

Definition at line 97 of file Savegame.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasMessages()

bool GameContext::HasMessages ( )

Definition at line 76 of file GameContext.cpp.

◆ LoadScene()

void GameContext::LoadScene ( std::string const &  filename)

Matching terrain must be already loaded.

Definition at line 62 of file Savegame.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadTerrain()

bool GameContext::LoadTerrain ( std::string const &  filename_part)

Definition at line 98 of file GameContext.cpp.

+ Here is the call graph for this function:

◆ ModifyActor()

void GameContext::ModifyActor ( ActorModifyRequest rq)

Definition at line 317 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OnLoaderGuiApply()

void GameContext::OnLoaderGuiApply ( RoR::LoaderType  type,
CacheEntry entry,
std::string  sectionconfig 
)

GUI callback.

Definition at line 649 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OnLoaderGuiCancel()

void GameContext::OnLoaderGuiCancel ( )

GUI callback.

Definition at line 633 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PopMessage()

Message GameContext::PopMessage ( )

Definition at line 82 of file GameContext.cpp.

+ Here is the caller graph for this function:

◆ PushMessage()

void GameContext::PushMessage ( Message  m)

Doesn't guarantee order! Use ChainMessage() if order matters.

Definition at line 55 of file GameContext.cpp.

+ Here is the caller graph for this function:

◆ RespawnLastActor()

void GameContext::RespawnLastActor ( )

Definition at line 556 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SaveScene()

void GameContext::SaveScene ( std::string const &  filename)

Definition at line 68 of file Savegame.cpp.

+ Here is the caller graph for this function:

◆ SetPrevPlayerActor()

void RoR::GameContext::SetPrevPlayerActor ( ActorPtr  actor)
inline

Definition at line 134 of file GameContext.h.

+ Here is the caller graph for this function:

◆ ShowLoaderGUI()

void GameContext::ShowLoaderGUI ( int  type,
const Ogre::String &  instance,
const Ogre::String &  box 
)

Definition at line 605 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SpawnActor()

ActorPtr GameContext::SpawnActor ( ActorSpawnRequest rq)

Definition at line 172 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SpawnPreselectedActor()

void GameContext::SpawnPreselectedActor ( std::string const &  preset_vehicle,
std::string const &  preset_veh_config 
)

needs Character to exist

Definition at line 569 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TeleportPlayer()

void GameContext::TeleportPlayer ( float  x,
float  z 
)

Definition at line 833 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnloadTerrain()

void GameContext::UnloadTerrain ( )

Definition at line 158 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateActors()

void GameContext::UpdateActors ( )

Definition at line 545 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateAirplaneInputEvents()

void GameContext::UpdateAirplaneInputEvents ( float  dt)

Definition at line 1484 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateBoatInputEvents()

void GameContext::UpdateBoatInputEvents ( float  dt)

Definition at line 1672 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateCommonInputEvents()

void GameContext::UpdateCommonInputEvents ( float  dt)

Definition at line 1208 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateGlobalInputEvents()

void GameContext::UpdateGlobalInputEvents ( )

Definition at line 871 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateSimInputEvents()

void GameContext::UpdateSimInputEvents ( float  dt)

Definition at line 986 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateSkyInputEvents()

void GameContext::UpdateSkyInputEvents ( float  dt)

Definition at line 1144 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateTruckInputEvents()

void GameContext::UpdateTruckInputEvents ( float  dt)

Definition at line 1732 of file GameContext.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ m_actor_manager

ActorManager RoR::GameContext::m_actor_manager
private

Definition at line 189 of file GameContext.h.

◆ m_character_factory

CharacterFactory RoR::GameContext::m_character_factory
private

Definition at line 201 of file GameContext.h.

◆ m_current_selection

ActorSpawnRequest RoR::GameContext::m_current_selection
private

Context of the loader UI.

Definition at line 197 of file GameContext.h.

◆ m_dummy_cache_selection

CacheEntry RoR::GameContext::m_dummy_cache_selection
private

Definition at line 198 of file GameContext.h.

◆ m_last_cache_selection

CacheEntry* RoR::GameContext::m_last_cache_selection = nullptr
private

Vehicle/load.

Definition at line 194 of file GameContext.h.

◆ m_last_section_config

Ogre::String RoR::GameContext::m_last_section_config
private

Definition at line 196 of file GameContext.h.

◆ m_last_skin_selection

CacheEntry* RoR::GameContext::m_last_skin_selection = nullptr
private

Definition at line 195 of file GameContext.h.

◆ m_last_spawned_actor

ActorPtr RoR::GameContext::m_last_spawned_actor = nullptr
private

Last actor spawned by user and still alive.

Definition at line 192 of file GameContext.h.

◆ m_msg_chain_end

Message* RoR::GameContext::m_msg_chain_end = nullptr
private

Definition at line 182 of file GameContext.h.

◆ m_msg_mutex

std::mutex RoR::GameContext::m_msg_mutex
private

Definition at line 183 of file GameContext.h.

◆ m_msg_queue

GameMsgQueue RoR::GameContext::m_msg_queue
private

Definition at line 181 of file GameContext.h.

◆ m_player_actor

ActorPtr RoR::GameContext::m_player_actor = nullptr
private

Actor (vehicle or machine) mounted and controlled by player.

Definition at line 190 of file GameContext.h.

◆ m_prev_player_actor

ActorPtr RoR::GameContext::m_prev_player_actor = nullptr
private

Previous actor (vehicle or machine) mounted and controlled by player.

Definition at line 191 of file GameContext.h.

◆ m_race_system

RaceSystem RoR::GameContext::m_race_system
private

Definition at line 204 of file GameContext.h.

◆ m_recovery_mode

RepairMode RoR::GameContext::m_recovery_mode
private

Aka 'advanced repair' or 'interactive reset'.

Definition at line 205 of file GameContext.h.

◆ m_scene_mouse

SceneMouse RoR::GameContext::m_scene_mouse
private

Mouse interaction with scene.

Definition at line 206 of file GameContext.h.

◆ m_terrain

TerrainPtr RoR::GameContext::m_terrain
private

Definition at line 186 of file GameContext.h.

◆ m_timer

Ogre::Timer RoR::GameContext::m_timer
private

Definition at line 207 of file GameContext.h.

◆ prev_pos

Ogre::Vector3 RoR::GameContext::prev_pos = Ogre::Vector3::ZERO
private

Definition at line 208 of file GameContext.h.


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