💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

257 lines
6.7 KiB

2 years ago
2 years ago
  1. /*
  2. * Copyright (C) 2021 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_GAME_CONTEXT_HPP
  20. #define ANTKEEPER_GAME_CONTEXT_HPP
  21. #include "utility/fundamental-types.hpp"
  22. #include "resources/string-table.hpp"
  23. #include "entity/id.hpp"
  24. #include "entity/registry.hpp"
  25. #include "geom/aabb.hpp"
  26. #include "gl/vertex-array.hpp"
  27. #include "gl/vertex-buffer.hpp"
  28. #include "gl/texture-2d.hpp"
  29. #include "gl/rasterizer.hpp"
  30. #include "gl/framebuffer.hpp"
  31. #include "input/control.hpp"
  32. #include "input/control-set.hpp"
  33. #include "input/listener.hpp"
  34. #include "input/mapper.hpp"
  35. #include "input/event-router.hpp"
  36. #include "animation/tween.hpp"
  37. #include "scene/scene.hpp"
  38. #include <optional>
  39. #include <entt/entt.hpp>
  40. #include <fstream>
  41. #include <queue>
  42. #include <string>
  43. #include <unordered_map>
  44. #include "resources/json.hpp"
  45. #include "type/typeface.hpp"
  46. // Forward declarations
  47. class animator;
  48. class application;
  49. class bloom_pass;
  50. class clear_pass;
  51. class compositor;
  52. class final_pass;
  53. class material;
  54. class material_pass;
  55. class resource_manager;
  56. class screen_transition;
  57. class shadow_map_pass;
  58. class simple_render_pass;
  59. class sky_pass;
  60. class timeline;
  61. class renderer;
  62. class outline_pass;
  63. template <typename T> class animation;
  64. template <typename T> class material_property;
  65. namespace debug
  66. {
  67. class cli;
  68. class logger;
  69. }
  70. namespace entity
  71. {
  72. namespace system
  73. {
  74. class subterrain;
  75. class terrain;
  76. class vegetation;
  77. class ui;
  78. class spatial;
  79. class painting;
  80. class astronomy;
  81. class blackbody;
  82. class atmosphere;
  83. class orbit;
  84. class behavior;
  85. class collision;
  86. class constraint;
  87. class locomotion;
  88. class snapping;
  89. class camera;
  90. class nest;
  91. class render;
  92. class samara;
  93. class proteome;
  94. }
  95. }
  96. namespace game {
  97. /// Structure containing the state of a game.
  98. struct context
  99. {
  100. application* app;
  101. debug::logger* logger;
  102. std::ofstream log_filestream;
  103. // Command-line options
  104. std::optional<bool> option_continue;
  105. std::optional<std::string> option_data;
  106. std::optional<bool> option_fullscreen;
  107. std::optional<bool> option_new_game;
  108. std::optional<bool> option_quick_start;
  109. std::optional<bool> option_reset;
  110. std::optional<int> option_vsync;
  111. std::optional<bool> option_windowed;
  112. // Paths
  113. std::string data_path;
  114. std::string config_path;
  115. std::string mods_path;
  116. std::string saves_path;
  117. std::string screenshots_path;
  118. std::string controls_path;
  119. std::string data_package_path;
  120. // Configuration
  121. json* config;
  122. // Resources
  123. resource_manager* resource_manager;
  124. // Localization
  125. std::string language_code;
  126. int language_index;
  127. string_table* string_table;
  128. string_table_map string_table_map;
  129. std::unordered_map<std::string, std::string>* strings;
  130. std::unordered_map<std::string, type::typeface*> typefaces;
  131. // Framebuffers
  132. gl::framebuffer* shadow_map_framebuffer;
  133. gl::texture_2d* shadow_map_depth_texture;
  134. gl::framebuffer* framebuffer_hdr;
  135. gl::texture_2d* framebuffer_hdr_color;
  136. gl::texture_2d* framebuffer_hdr_depth;
  137. gl::framebuffer* framebuffer_bloom; // General purpose framebuffer A
  138. gl::texture_2d* bloom_texture;
  139. // Rendering
  140. gl::rasterizer* rasterizer;
  141. renderer* renderer;
  142. gl::vertex_buffer* billboard_vbo;
  143. gl::vertex_array* billboard_vao;
  144. material* fallback_material;
  145. material* splash_billboard_material;
  146. // Compositing
  147. clear_pass* ui_clear_pass;
  148. material_pass* ui_material_pass;
  149. compositor* ui_compositor;
  150. bloom_pass* common_bloom_pass;
  151. final_pass* common_final_pass;
  152. clear_pass* underground_clear_pass;
  153. material_pass* underground_material_pass;
  154. compositor* underground_compositor;
  155. clear_pass* surface_shadow_map_clear_pass;
  156. shadow_map_pass* surface_shadow_map_pass;
  157. clear_pass* surface_clear_pass;
  158. sky_pass* surface_sky_pass;
  159. material_pass* surface_material_pass;
  160. outline_pass* surface_outline_pass;
  161. compositor* surface_compositor;
  162. // Scene utilities
  163. scene::collection* active_scene;
  164. geom::aabb<float> no_cull;
  165. // UI scene
  166. scene::collection* ui_scene;
  167. scene::camera* ui_camera;
  168. scene::billboard* splash_billboard;
  169. scene::billboard* camera_flash_billboard;
  170. // Surface scene
  171. scene::collection* surface_scene;
  172. scene::camera* surface_camera;
  173. // Underground scene
  174. scene::collection* underground_scene;
  175. scene::camera* underground_camera;
  176. scene::ambient_light* underground_ambient_light;
  177. scene::spot_light* flashlight_spot_light;
  178. // Animation
  179. timeline* timeline;
  180. animator* animator;
  181. tween<double>* time_tween;
  182. animation<float>* radial_transition_in;
  183. animation<float>* radial_transition_out;
  184. screen_transition* fade_transition;
  185. material_property<float3>* fade_transition_color;
  186. screen_transition* radial_transition_inner;
  187. screen_transition* radial_transition_outer;
  188. animation<float>* equip_tool_animation;
  189. animation<float>* unequip_tool_animation;
  190. animation<float>* camera_flash_animation;
  191. // Controls
  192. input::event_router* input_event_router;
  193. input::mapper* input_mapper;
  194. input::listener* input_listener;
  195. std::unordered_map<std::string, input::control*> controls;
  196. bool mouse_look;
  197. // Parallel processes
  198. std::unordered_map<std::string, std::function<void(double, double)>> processes;
  199. // Entities
  200. entity::registry* entity_registry;
  201. std::unordered_map<std::string, entity::id> entities;
  202. // Systems
  203. entity::system::behavior* behavior_system;
  204. entity::system::camera* camera_system;
  205. entity::system::collision* collision_system;
  206. entity::system::constraint* constraint_system;
  207. entity::system::locomotion* locomotion_system;
  208. entity::system::snapping* snapping_system;
  209. entity::system::render* render_system;
  210. entity::system::samara* samara_system;
  211. entity::system::subterrain* subterrain_system;
  212. entity::system::terrain* terrain_system;
  213. entity::system::ui* ui_system;
  214. entity::system::vegetation* vegetation_system;
  215. entity::system::spatial* spatial_system;
  216. entity::system::painting* painting_system;
  217. entity::system::blackbody* blackbody_system;
  218. entity::system::atmosphere* atmosphere_system;
  219. entity::system::astronomy* astronomy_system;
  220. entity::system::orbit* orbit_system;
  221. entity::system::proteome* proteome_system;
  222. // Debug
  223. debug::cli* cli;
  224. };
  225. } // namespace game
  226. #endif // ANTKEEPER_GAME_CONTEXT_HPP