wavelength 1.0.0
Loading...
Searching...
No Matches
worldmgr.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5#include "game/inputmgr.h"
6#include "game/world.h"
7
21class WorldMgr {
22public:
30
39
47
55
63 static WorldMgr *shared();
64
71 void Init();
72
81 void Terminate();
82
90 int GetState() const;
91
98 void Reset();
99
110 void Load();
111
118 void Start();
119
126 void Unload();
127
138
148 int Poll();
149
156 void Draw();
157
158private:
168 static void ResetSynthControllers();
169
171 World *GetWorld() const {
172 return mWorld.get();
173 }
174
176 InputMgr *GetInputMgr() const {
177 return mInputMgr.get();
178 }
179 std::unique_ptr<World> mWorld;
180 std::unique_ptr<InputMgr> mInputMgr;
181 int mState;
182 int mEvent;
183 int mInitialized;
184 int mWorldStarted;
185};
186
192extern WorldMgr *TheWorldMgr;
Router of controller input to a running world.
Definition inputmgr.h:22
Driver of the World that is loading, running, or being torn down.
Definition worldmgr.h:21
void Draw()
Draw TheGfxManager, at the running world's tick or at time 0 otherwise.
Event
Values Poll() reports.
Definition worldmgr.h:32
@ kEventUnloaded
Definition worldmgr.h:36
@ kEventNone
Definition worldmgr.h:33
@ kEventRestart
Definition worldmgr.h:37
@ kEventFinished
Definition worldmgr.h:35
@ kEventLoaded
Definition worldmgr.h:34
void Init()
Initialise TheGfxManager and TheGameConfig, and mark the driver initialised.
int GetState() const
Report mState.
static WorldMgr * shared()
Report the single instance, constructing it on first use.
State
Values of mState.
Definition worldmgr.h:24
@ kStateLoading
Definition worldmgr.h:26
@ kStateUnloaded
Definition worldmgr.h:28
@ kStateIdle
Definition worldmgr.h:25
@ kStatePlaying
Definition worldmgr.h:27
void Unload()
Destroy the router and the world and enter kStateUnloaded.
void UpdateTime()
Copy two timing values of the running world into the game database.
void Reset()
Reset TheGfxManager and enter kStateIdle.
void Load()
Build the World for the selected rule set and enter kStateLoading.
~WorldMgr()
Release the driver.
void Terminate()
Destroy the world and the router if either exists, and shut down TheGfxManager.
WorldMgr()
Construct the driver with every member clear.
void Start()
Attach an InputMgr to the loaded world and enter kStatePlaying.
int Poll()
Advance the current state by one frame and report what changed.
One game in progress under one rule set.
Definition world.h:31
WorldMgr * TheWorldMgr
The world driver, WorldMgr::shared() as the unit's static initialiser stored it.