RigsofRods
Soft-body Physics Simulation
Public Member Functions | Private Attributes | Friends
RoR::GameContext Class Reference

Central game state manager. More...

#include <GameContext.h>

+ Collaboration diagram for RoR::GameContext:

Public Member Functions

 GameContext ()
 
 ~GameContext ()
 
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, CacheEntryPtr 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
 Actor (vehicle or machine) mounted and controlled by player. More...
 
ActorPtr m_prev_player_actor
 Previous actor (vehicle or machine) mounted and controlled by player. More...
 
ActorPtr m_last_spawned_actor
 Last actor spawned by user and still alive. More...
 
CacheEntryPtr m_last_cache_selection
 Vehicle/load. More...
 
CacheEntryPtr m_last_skin_selection
 
CacheEntryPtr m_last_tuneup_selection
 
Ogre::String m_last_section_config
 
ActorSpawnRequest m_current_selection
 Context of the loader UI. More...
 
CacheEntryPtr 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
 

Friends

class AppContext
 

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 95 of file GameContext.h.

Constructor & Destructor Documentation

◆ GameContext()

GameContext::GameContext ( )

Definition at line 53 of file GameContext.cpp.

◆ ~GameContext()

GameContext::~GameContext ( )

Definition at line 58 of file GameContext.cpp.

Member Function Documentation

◆ ChainMessage()

void GameContext::ChainMessage ( Message  m)

Add to last pushed message's chain.

Definition at line 73 of file GameContext.cpp.

+ Here is the caller graph for this function:

◆ ChangePlayerActor()

void GameContext::ChangePlayerActor ( ActorPtr  actor)

Definition at line 473 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 826 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 412 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 74 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 86 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 581 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 576 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 591 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 127 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetCharacterFactory()

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

Definition at line 150 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetPlayerActor()

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

Definition at line 134 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetPlayerCharacter()

Character * GameContext::GetPlayerCharacter ( )

Definition at line 879 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 135 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 55 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 168 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetRepairMode()

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

Definition at line 169 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetSceneMouse()

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

Definition at line 170 of file GameContext.h.

+ Here is the caller graph for this function:

◆ GetTerrain()

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

Definition at line 117 of file GameContext.h.

+ Here is the caller graph for this function:

◆ HandleSavegameHotkeys()

void GameContext::HandleSavegameHotkeys ( )

Definition at line 98 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 90 of file GameContext.cpp.

◆ LoadScene()

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

Matching terrain must be already loaded.

Definition at line 63 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 112 of file GameContext.cpp.

+ Here is the call graph for this function:

◆ ModifyActor()

void GameContext::ModifyActor ( ActorModifyRequest rq)

Definition at line 357 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,
CacheEntryPtr  entry,
std::string  sectionconfig 
)

GUI callback.

Definition at line 690 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 674 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 96 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 66 of file GameContext.cpp.

+ Here is the caller graph for this function:

◆ RespawnLastActor()

void GameContext::RespawnLastActor ( )

Definition at line 597 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 69 of file Savegame.cpp.

+ Here is the caller graph for this function:

◆ SetPrevPlayerActor()

void GameContext::SetPrevPlayerActor ( ActorPtr  actor)

Definition at line 821 of file GameContext.cpp.

+ 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 646 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 191 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 610 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 887 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 177 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 586 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 1571 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 1759 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 1295 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 925 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 1040 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 1198 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 1819 of file GameContext.cpp.

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

Friends And Related Function Documentation

◆ AppContext

friend class AppContext
friend

Definition at line 97 of file GameContext.h.

Field Documentation

◆ m_actor_manager

ActorManager RoR::GameContext::m_actor_manager
private

Definition at line 192 of file GameContext.h.

◆ m_character_factory

CharacterFactory RoR::GameContext::m_character_factory
private

Definition at line 205 of file GameContext.h.

◆ m_current_selection

ActorSpawnRequest RoR::GameContext::m_current_selection
private

Context of the loader UI.

Definition at line 201 of file GameContext.h.

◆ m_dummy_cache_selection

CacheEntryPtr RoR::GameContext::m_dummy_cache_selection
private

Definition at line 202 of file GameContext.h.

◆ m_last_cache_selection

CacheEntryPtr RoR::GameContext::m_last_cache_selection
private

Vehicle/load.

Definition at line 197 of file GameContext.h.

◆ m_last_section_config

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

Definition at line 200 of file GameContext.h.

◆ m_last_skin_selection

CacheEntryPtr RoR::GameContext::m_last_skin_selection
private

Definition at line 198 of file GameContext.h.

◆ m_last_spawned_actor

ActorPtr RoR::GameContext::m_last_spawned_actor
private

Last actor spawned by user and still alive.

Definition at line 195 of file GameContext.h.

◆ m_last_tuneup_selection

CacheEntryPtr RoR::GameContext::m_last_tuneup_selection
private

Definition at line 199 of file GameContext.h.

◆ m_msg_chain_end

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

Definition at line 185 of file GameContext.h.

◆ m_msg_mutex

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

Definition at line 186 of file GameContext.h.

◆ m_msg_queue

GameMsgQueue RoR::GameContext::m_msg_queue
private

Definition at line 184 of file GameContext.h.

◆ m_player_actor

ActorPtr RoR::GameContext::m_player_actor
private

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

Definition at line 193 of file GameContext.h.

◆ m_prev_player_actor

ActorPtr RoR::GameContext::m_prev_player_actor
private

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

Definition at line 194 of file GameContext.h.

◆ m_race_system

RaceSystem RoR::GameContext::m_race_system
private

Definition at line 208 of file GameContext.h.

◆ m_recovery_mode

RepairMode RoR::GameContext::m_recovery_mode
private

Aka 'advanced repair' or 'interactive reset'.

Definition at line 209 of file GameContext.h.

◆ m_scene_mouse

SceneMouse RoR::GameContext::m_scene_mouse
private

Mouse interaction with scene.

Definition at line 210 of file GameContext.h.

◆ m_terrain

TerrainPtr RoR::GameContext::m_terrain
private

Definition at line 189 of file GameContext.h.

◆ m_timer

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

Definition at line 211 of file GameContext.h.

◆ prev_pos

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

Definition at line 212 of file GameContext.h.


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