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

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