💿🐜 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.

281 lines
7.3 KiB

  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 <string>
  42. #include <unordered_map>
  43. // Forward declarations
  44. class animator;
  45. class application;
  46. class bloom_pass;
  47. class clear_pass;
  48. class compositor;
  49. class config_file;
  50. class final_pass;
  51. class material;
  52. class material_pass;
  53. class orbit_cam;
  54. class pheromone_matrix;
  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. struct biome;
  64. template <typename T> class animation;
  65. template <typename T> class material_property;
  66. namespace debug
  67. {
  68. class cli;
  69. class logger;
  70. }
  71. namespace entity
  72. {
  73. namespace system
  74. {
  75. class subterrain;
  76. class terrain;
  77. class vegetation;
  78. class tool;
  79. class ui;
  80. class spatial;
  81. class tracking;
  82. class painting;
  83. class astronomy;
  84. class blackbody;
  85. class atmosphere;
  86. class orbit;
  87. class behavior;
  88. class collision;
  89. class constraint;
  90. class locomotion;
  91. class control;
  92. class snapping;
  93. class camera;
  94. class nest;
  95. class render;
  96. class samara;
  97. class proteome;
  98. }
  99. }
  100. namespace game {
  101. /// Structure containing the state of a game.
  102. struct context
  103. {
  104. application* app;
  105. debug::logger* logger;
  106. std::ofstream log_filestream;
  107. // Command-line options
  108. std::optional<std::string> option_biome;
  109. std::optional<bool> option_continue;
  110. std::optional<std::string> option_data;
  111. std::optional<bool> option_fullscreen;
  112. std::optional<bool> option_new_game;
  113. std::optional<bool> option_quick_start;
  114. std::optional<bool> option_reset;
  115. std::optional<int> option_vsync;
  116. std::optional<bool> option_windowed;
  117. // Paths
  118. std::string data_path;
  119. std::string config_path;
  120. std::string mods_path;
  121. std::string saves_path;
  122. std::string screenshots_path;
  123. std::string data_package_path;
  124. // Config
  125. config_file* config;
  126. // Resources
  127. resource_manager* resource_manager;
  128. // Localization
  129. std::string language_code;
  130. int language_index;
  131. string_table* string_table;
  132. string_table_map string_table_map;
  133. std::unordered_map<std::string, std::string>* strings;
  134. // Framebuffers
  135. gl::framebuffer* shadow_map_framebuffer;
  136. gl::texture_2d* shadow_map_depth_texture;
  137. gl::framebuffer* framebuffer_hdr;
  138. gl::texture_2d* framebuffer_hdr_color;
  139. gl::texture_2d* framebuffer_hdr_depth;
  140. gl::framebuffer* framebuffer_bloom; // General purpose framebuffer A
  141. gl::texture_2d* bloom_texture;
  142. // Rendering
  143. gl::rasterizer* rasterizer;
  144. renderer* renderer;
  145. gl::vertex_buffer* billboard_vbo;
  146. gl::vertex_array* billboard_vao;
  147. material* fallback_material;
  148. material* splash_billboard_material;
  149. gl::texture_2d** marker_albedo_textures;
  150. // Compositing
  151. clear_pass* ui_clear_pass;
  152. material_pass* ui_material_pass;
  153. compositor* ui_compositor;
  154. bloom_pass* common_bloom_pass;
  155. final_pass* common_final_pass;
  156. clear_pass* underground_clear_pass;
  157. material_pass* underground_material_pass;
  158. compositor* underground_compositor;
  159. clear_pass* surface_shadow_map_clear_pass;
  160. shadow_map_pass* surface_shadow_map_pass;
  161. clear_pass* surface_clear_pass;
  162. sky_pass* surface_sky_pass;
  163. material_pass* surface_material_pass;
  164. outline_pass* surface_outline_pass;
  165. compositor* surface_compositor;
  166. // Scene utilities
  167. scene::collection* active_scene;
  168. geom::aabb<float> no_cull;
  169. // UI scene
  170. scene::collection* ui_scene;
  171. scene::camera* ui_camera;
  172. scene::billboard* splash_billboard;
  173. // Surface scene
  174. scene::collection* surface_scene;
  175. scene::camera* surface_camera;
  176. scene::spot_light* lens_spot_light;
  177. // Underground scene
  178. scene::collection* underground_scene;
  179. scene::camera* underground_camera;
  180. scene::ambient_light* underground_ambient_light;
  181. scene::spot_light* flashlight_spot_light;
  182. // Animation
  183. timeline* timeline;
  184. animator* animator;
  185. tween<double>* time_tween;
  186. tween<float3>* focal_point_tween;
  187. animation<float>* radial_transition_in;
  188. animation<float>* radial_transition_out;
  189. screen_transition* fade_transition;
  190. material_property<float3>* fade_transition_color;
  191. screen_transition* radial_transition_inner;
  192. screen_transition* radial_transition_outer;
  193. animation<float>* equip_tool_animation;
  194. animation<float>* unequip_tool_animation;
  195. // Controls
  196. input::event_router* input_event_router;
  197. input::mapper* input_mapper;
  198. input::listener* input_listener;
  199. input::control_set* application_controls;
  200. input::control_set* camera_controls;
  201. input::control_set* menu_controls;
  202. input::control* menu_back_control;
  203. input::control* menu_select_control;
  204. input::control* screenshot_control;
  205. input::control* toggle_fullscreen_control;
  206. // Entities
  207. entity::registry* entity_registry;
  208. entity::id brush_entity;
  209. entity::id flashlight_entity;
  210. entity::id forceps_entity;
  211. entity::id lens_entity;
  212. entity::id marker_entity;
  213. entity::id container_entity;
  214. entity::id twig_entity;
  215. entity::id focal_point_entity;
  216. // Systems
  217. entity::system::behavior* behavior_system;
  218. entity::system::camera* camera_system;
  219. entity::system::collision* collision_system;
  220. entity::system::constraint* constraint_system;
  221. entity::system::control* control_system;
  222. entity::system::locomotion* locomotion_system;
  223. entity::system::nest* nest_system;
  224. entity::system::snapping* snapping_system;
  225. entity::system::render* render_system;
  226. entity::system::samara* samara_system;
  227. entity::system::subterrain* subterrain_system;
  228. entity::system::terrain* terrain_system;
  229. entity::system::tool* tool_system;
  230. entity::system::ui* ui_system;
  231. entity::system::vegetation* vegetation_system;
  232. entity::system::spatial* spatial_system;
  233. entity::system::tracking* tracking_system;
  234. entity::system::painting* painting_system;
  235. entity::system::blackbody* blackbody_system;
  236. entity::system::atmosphere* atmosphere_system;
  237. entity::system::astronomy* astronomy_system;
  238. entity::system::orbit* orbit_system;
  239. entity::system::proteome* proteome_system;
  240. std::unordered_map<std::string, entity::id> named_entities;
  241. // Game
  242. biome* biome;
  243. // Debug
  244. debug::cli* cli;
  245. // Misc
  246. pheromone_matrix* pheromones;
  247. };
  248. } // namespace game
  249. #endif // ANTKEEPER_GAME_CONTEXT_HPP