Conquer Space 0.0.0
A space themed grand strategy game set in the near future, with realistic orbital mechanics, and an emphasis on economics and politics.
universe.h
Go to the documentation of this file.
1/* Conquer Space
2 * Copyright (C) 2021-2023 Conquer Space
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <fmt/format.h>
20
21#include <map>
22#include <memory>
23#include <string>
24#include <vector>
25
26#include <entt/entt.hpp>
27
28#include "common/stardate.h"
31
32namespace cqsp {
33namespace common {
34class Universe : public entt::registry {
35 public:
36 explicit Universe(std::string uuid);
37 Universe();
38
40
41 std::map<std::string, entt::entity> goods;
42 std::vector<entt::entity> consumergoods;
43 std::map<std::string, entt::entity> recipes;
44 std::map<std::string, entt::entity> terrain_data;
45 std::map<std::string, systems::names::NameGenerator> name_generators;
46 std::map<std::string, entt::entity> fields;
47 std::map<std::string, entt::entity> technologies;
48 std::map<std::string, entt::entity> planets;
49 std::map<std::string, entt::entity> time_zones;
50 std::map<std::string, entt::entity> countries;
51 std::map<std::string, entt::entity> provinces;
52 std::map<std::string, entt::entity> cities;
53 std::map<int, entt::entity> province_colors;
54 std::map<entt::entity, int> colors_province;
55 entt::entity sun;
56
57 void EnableTick() { to_tick = true; }
58 void DisableTick() { to_tick = false; }
59 bool ToTick() { return to_tick; }
60 void ToggleTick() { to_tick = !to_tick; }
61
62 int GetDate() { return date.GetDate(); }
63 std::unique_ptr<cqsp::common::util::IRandom> random;
64 std::string uuid;
65
69 double tick_fraction = 0;
70
71 private:
72 bool to_tick = false;
73};
74} // namespace common
75} // namespace cqsp
76
77template <>
78struct fmt::formatter<entt::entity> : formatter<std::string> {
79 template <typename FormatContext>
80 constexpr auto format(entt::entity entity, FormatContext& ctx) const {
81 return formatter<std::string>::format(std::to_string((uint64_t)entity), ctx);
82 }
83};
Definition: universe.h:34
void DisableTick()
Definition: universe.h:58
std::unique_ptr< cqsp::common::util::IRandom > random
Definition: universe.h:63
std::map< std::string, entt::entity > recipes
Definition: universe.h:43
std::vector< entt::entity > consumergoods
Definition: universe.h:42
int GetDate()
Definition: universe.h:62
std::map< std::string, entt::entity > planets
Definition: universe.h:48
std::map< std::string, entt::entity > terrain_data
Definition: universe.h:44
std::map< int, entt::entity > province_colors
Definition: universe.h:53
std::map< std::string, entt::entity > goods
Definition: universe.h:41
std::map< std::string, entt::entity > cities
Definition: universe.h:52
std::map< std::string, entt::entity > countries
Definition: universe.h:50
components::StarDate date
Definition: universe.h:39
void ToggleTick()
Definition: universe.h:60
Universe()
Definition: universe.cpp:25
bool ToTick()
Definition: universe.h:59
std::map< std::string, entt::entity > fields
Definition: universe.h:46
double tick_fraction
What is the current fraction of the wait of the tick we are processing
Definition: universe.h:69
std::map< std::string, systems::names::NameGenerator > name_generators
Definition: universe.h:45
std::map< entt::entity, int > colors_province
Definition: universe.h:54
std::map< std::string, entt::entity > provinces
Definition: universe.h:51
std::map< std::string, entt::entity > time_zones
Definition: universe.h:49
std::map< std::string, entt::entity > technologies
Definition: universe.h:47
entt::entity sun
Definition: universe.h:55
void EnableTick()
Definition: universe.h:57
bool to_tick
Definition: universe.h:72
std::string uuid
Definition: universe.h:64
Holds and calculates the tick that is on going. Date is the number of hours that has been ongoing sin...
Definition: stardate.h:45
int GetDate()
Definition: stardate.h:56
When adding assets, it is extremely crucial that you read cqsp::asset::AssetLoader::LoadResources to ...
Definition: clientctx.h:21
constexpr auto format(entt::entity entity, FormatContext &ctx) const
Definition: universe.h:80