GameEngine.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: GameEngine.h /////////////////////////////////////////////////////////
  24. // The Game engine interface
  25. // Author: Michael S. Booth, April 2001
  26. #pragma once
  27. #ifndef _GAME_ENGINE_H_
  28. #define _GAME_ENGINE_H_
  29. #include "Common/SubsystemInterface.h"
  30. #include "Common/GameType.h"
  31. #define DEFAULT_MAX_FPS 45
  32. // forward declarations
  33. class AudioManager;
  34. class GameLogic;
  35. class GameClient;
  36. class MessageStream; ///< @todo Create a MessageStreamInterface abstract class
  37. class FileSystem;
  38. class Keyboard;
  39. class LocalFileSystem;
  40. class ArchiveFileSystem;
  41. class FileSystem;
  42. class Mouse;
  43. class NetworkInterface;
  44. class ModuleFactory;
  45. class ThingFactory;
  46. class FunctionLexicon;
  47. class Radar;
  48. class WebBrowser;
  49. class ParticleSystemManager;
  50. /**
  51. * The implementation of the game engine
  52. */
  53. class GameEngine : public SubsystemInterface
  54. {
  55. public:
  56. GameEngine( void );
  57. virtual ~GameEngine();
  58. virtual void init( void ); ///< Init engine by creating client and logic
  59. virtual void init( int argc, char *argv[] ); ///< Init engine by creating client and logic
  60. virtual void reset( void ); ///< reset system to starting state
  61. virtual void update( void ); ///< per frame update
  62. virtual void execute( void ); /**< The "main loop" of the game engine.
  63. It will not return until the game exits. */
  64. virtual void setFramesPerSecondLimit( Int fps ); ///< Set the maximum rate engine updates are allowed to occur
  65. virtual Int getFramesPerSecondLimit( void ); ///< Get maxFPS. Not inline since it is called from another lib.
  66. virtual void setQuitting( Bool quitting ); ///< set quitting status
  67. virtual Bool getQuitting(void); ///< is app getting ready to quit.
  68. virtual Bool isMultiplayerSession( void );
  69. virtual void serviceWindowsOS(void) {}; ///< service the native OS
  70. virtual Bool isActive(void) {return m_isActive;} ///< returns whether app has OS focus.
  71. virtual void setIsActive(Bool isActive) { m_isActive = isActive; };
  72. protected:
  73. virtual FileSystem *createFileSystem( void ); ///< Factory for FileSystem classes
  74. virtual LocalFileSystem *createLocalFileSystem( void ) = 0; ///< Factory for LocalFileSystem classes
  75. virtual ArchiveFileSystem *createArchiveFileSystem( void ) = 0; ///< Factory for ArchiveFileSystem classes
  76. virtual GameLogic *createGameLogic( void ) = 0; ///< Factory for GameLogic classes.
  77. virtual GameClient *createGameClient( void ) = 0; ///< Factory for GameClient classes.
  78. virtual MessageStream *createMessageStream( void ); ///< Factory for the message stream
  79. virtual ModuleFactory *createModuleFactory( void ) = 0; ///< Factory for modules
  80. virtual ThingFactory *createThingFactory( void ) = 0; ///< Factory for the thing factory
  81. virtual FunctionLexicon *createFunctionLexicon( void ) = 0; ///< Factory for Function Lexicon
  82. virtual Radar *createRadar( void ) = 0; ///< Factory for radar
  83. virtual WebBrowser *createWebBrowser( void ) = 0; ///< Factory for embedded browser
  84. virtual ParticleSystemManager* createParticleSystemManager( void ) = 0;
  85. virtual AudioManager *createAudioManager( void ) = 0; ///< Factory for Audio Manager
  86. Int m_maxFPS; ///< Maximum frames per second allowed
  87. Bool m_quitting; ///< true when we need to quit the game
  88. Bool m_isActive; ///< app has OS focus.
  89. };
  90. inline void GameEngine::setQuitting( Bool quitting ) { m_quitting = quitting; }
  91. inline Bool GameEngine::getQuitting(void) { return m_quitting; }
  92. // the game engine singleton
  93. extern GameEngine *TheGameEngine;
  94. /// This function creates a new game engine instance, and is device specific
  95. extern GameEngine *CreateGameEngine( void );
  96. /// The entry point for the game system
  97. extern void GameMain( int argc, char *argv[] );
  98. #endif // _GAME_ENGINE_H_