forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 185
Expand file tree
/
Copy pathGameEngine.h
More file actions
119 lines (96 loc) · 4.57 KB
/
GameEngine.h
File metadata and controls
119 lines (96 loc) · 4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
** Command & Conquer Generals Zero Hour(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: GameEngine.h /////////////////////////////////////////////////////////
// The Game engine interface
// Author: Michael S. Booth, April 2001
#pragma once
#include "Common/SubsystemInterface.h"
#include "Common/GameType.h"
// forward declarations
class AudioManager;
class GameLogic;
class GameClient;
class MessageStream; ///< @todo Create a MessageStreamInterface abstract class
class FileSystem;
class Keyboard;
class LocalFileSystem;
class ArchiveFileSystem;
class FileSystem;
class Mouse;
class NetworkInterface;
class ModuleFactory;
class ThingFactory;
class FunctionLexicon;
class Radar;
class WebBrowser;
class ParticleSystemManager;
class GameEngine : public SubsystemInterface
{
public:
GameEngine();
virtual ~GameEngine() override;
virtual void init() override; ///< Init engine by creating client and logic
virtual void reset() override; ///< reset system to starting state
virtual void update() override; ///< per frame update
virtual void execute(); /**< The "main loop" of the game engine.
It will not return until the game exits. */
static Bool isTimeFrozen(); ///< Returns true if a script has frozen time.
static Bool isGameHalted(); ///< Returns true if the game is paused or the network is stalling.
virtual void setQuitting( Bool quitting ); ///< set quitting status
virtual Bool getQuitting(); ///< is app getting ready to quit.
virtual Bool isMultiplayerSession();
virtual void serviceWindowsOS() {}; ///< service the native OS
virtual Bool isActive() {return m_isActive;} ///< returns whether app has OS focus.
virtual void setIsActive(Bool isActive) { m_isActive = isActive; };
protected:
virtual void resetSubsystems();
Bool canUpdateGameLogic();
Bool canUpdateNetworkGameLogic();
Bool canUpdateRegularGameLogic();
virtual FileSystem *createFileSystem(); ///< Factory for FileSystem classes
virtual LocalFileSystem *createLocalFileSystem() = 0; ///< Factory for LocalFileSystem classes
virtual ArchiveFileSystem *createArchiveFileSystem() = 0; ///< Factory for ArchiveFileSystem classes
virtual GameLogic *createGameLogic() = 0; ///< Factory for GameLogic classes.
virtual GameClient *createGameClient() = 0; ///< Factory for GameClient classes.
virtual MessageStream *createMessageStream(); ///< Factory for the message stream
virtual ModuleFactory *createModuleFactory() = 0; ///< Factory for modules
virtual ThingFactory *createThingFactory() = 0; ///< Factory for the thing factory
virtual FunctionLexicon *createFunctionLexicon() = 0; ///< Factory for Function Lexicon
virtual Radar *createRadar() = 0; ///< Factory for radar
virtual WebBrowser *createWebBrowser() = 0; ///< Factory for embedded browser
virtual ParticleSystemManager* createParticleSystemManager(Bool dummy) = 0;
virtual AudioManager *createAudioManager() = 0; ///< Factory for Audio Manager
Real m_logicTimeAccumulator; ///< Frame time accumulated towards submitting a new logic frame
Bool m_quitting; ///< true when we need to quit the game
Bool m_isActive; ///< app has OS focus.
public:
Real getLogicTimeAccumulator() const { return m_logicTimeAccumulator; }
};
inline void GameEngine::setQuitting( Bool quitting ) { m_quitting = quitting; }
inline Bool GameEngine::getQuitting() { return m_quitting; }
// the game engine singleton
extern GameEngine *TheGameEngine;
/// This function creates a new game engine instance, and is device specific
extern GameEngine *CreateGameEngine();
/// The entry point for the game system
extern Int GameMain();