gamelib.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #ifdef GAME_TEMPLATE
  2. Game g_Game;
  3. Game GetGame()
  4. {
  5. return g_Game;
  6. }
  7. class Game
  8. {
  9. ScriptModule GameScript;
  10. ScriptModule GetScriptModule()
  11. {
  12. return GameScript;
  13. }
  14. void SetDebug(bool isDebug) {}
  15. //!
  16. /**
  17. \brief Called when some system event occur.
  18. @param eventTypeId event type.
  19. @param params Param object, cast to specific param class to get parameters for particular event.
  20. */
  21. void OnEvent(EventType eventTypeId, Param params)
  22. {
  23. Print("OnEvent");
  24. }
  25. /**
  26. \brief Called after full initialization of Game instance
  27. */
  28. void OnAfterInit()
  29. {
  30. Print("OnAfterInit");
  31. }
  32. /**
  33. \brief Called on World update
  34. @param timeslice time elapsed from last call
  35. */
  36. void OnUpdate(float timeslice)
  37. {
  38. }
  39. /**
  40. \brief Sets world file to be loaded. Returns false if file doesn't exist.
  41. @param path Path to the ent file
  42. @param reload Force reload the world
  43. */
  44. proto native bool SetWorldFile(string path, bool reload);
  45. /**
  46. \brief Returns path of world file loaded
  47. */
  48. proto native owned string GetWorldFile();
  49. /**
  50. \brief Event which is called right before game starts (all entities are created and initialized). Returns true if the game can start.
  51. */
  52. bool OnGameStart()
  53. {
  54. return true;
  55. }
  56. /**
  57. \brief Event which is called right before game end.
  58. */
  59. void OnGameEnd()
  60. {
  61. }
  62. /**
  63. \brief Creates loading screen
  64. */
  65. void ShowLoadingAnim()
  66. {
  67. }
  68. /**
  69. \brief Hides loading screen
  70. */
  71. void HideLoadingAnim()
  72. {
  73. }
  74. /**
  75. \brief Used for updating the loading screen
  76. @param timeslice
  77. @param progress loading progress between 0 and 1
  78. */
  79. void UpdateLoadingAnim(float timeslice, float progress)
  80. {
  81. }
  82. /**
  83. \brief Safely instantiate the entity and calls EOnInit if the entity sets event mask EntityEvent.INIT.
  84. @param typename Name of entity's type to instantiate.
  85. @return instantiated entity
  86. */
  87. proto native IEntity SpawnEntity(typename typeName);
  88. /**
  89. \brief Safely instantiate the entity from template (with all components) and calls EOnInit if the entity sets event mask EntityEvent.INIT.
  90. @param templateResource Template resource of the entity to instantiate.
  91. @return instantiated entity
  92. */
  93. proto native IEntity SpawnEntityTemplate(vobject templateResource);
  94. /**
  95. \brief Safely instantiate the component from template, insert it to entity and calls EOnInit if the component sets event mask EntityEvent.INIT.
  96. @param owner Entity which will own the component
  97. @param templateResource Template resource of the component to instantiate.
  98. @return instantiated component
  99. */
  100. proto native GenericComponent SpawnComponentTemplate(IEntity owner, vobject templateResource);
  101. proto native IEntity FindEntity(string name);
  102. proto native WorkspaceWidget GetWorkspace();
  103. /**
  104. \brief Setting request flag for engine to exit the game
  105. */
  106. proto native void RequestClose();
  107. /**
  108. \brief Setting request flag for the engine to reinitialize the game
  109. * Doesn't do anything in Workbench
  110. */
  111. proto native void RequestReload();
  112. /**
  113. \brief Returns version of the game
  114. */
  115. proto native owned string GetBuildVersion();
  116. /**
  117. \brief Returns date and time when the game was built
  118. */
  119. proto native owned string GetBuildTime();
  120. /**
  121. \brief Returns World entity when in game or in play mode in WE. NULL otherwise.
  122. */
  123. proto native GenericWorldEntity GetWorldEntity();
  124. proto native InputManager GetInputManager();
  125. proto native MenuManager GetMenuManager();
  126. proto native int GetTickCount();
  127. }
  128. void GameLibInit()
  129. {
  130. }
  131. #endif