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.
sysorbit.h
Go to the documentation of this file.
1/* Conquer Space
2 * Copyright (C) 2021-2025 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 <unordered_map>
20#include <vector>
21
24
25namespace cqsp::core::systems {
27 public:
29 void DoSystem() override;
30 int Interval() const override { return 1; }
31 void Init() override;
32
33 private:
34 struct BodyCache {
35 glm::dvec3 position;
36 glm::dvec3 center;
37 glm::dvec3 future_position;
38 glm::dvec3 future_center;
39 double SOI;
40 double radius;
41 };
42
43 void ParseOrbitTree(entt::entity parent, entt::entity body);
44 void ComputePosition(entt::entity parent, entt::entity body);
45
52 void LeaveSOI(const entt::entity& body, entt::entity& parent, components::types::Orbit& orb,
54
61 bool CheckEnterSOI(const entt::entity& parent, const entt::entity& body, components::types::Kinematics& pos);
62
72 double radius);
73
74 void UpdateCommandQueue(components::types::Orbit& orb, entt::entity body, entt::entity parent);
75
76 void CalculateImpulse(components::types::Orbit& orb, entt::entity body);
77
78 void ParseChildren(entt::entity body);
79
80 void EnterSOI(entt::entity entity, entt::entity body, entt::entity parent, components::types::Orbit& orb,
81 components::types::Kinematics& vehicle_position, const components::bodies::Body& body_comp,
82 const components::types::Kinematics& target_position);
83 void ComputeCenters(entt::entity entity, glm::dvec3 parent_pos, glm::dvec3 future_parent_pos);
84 void CalculatePosition(entt::entity entity, components::types::Orbit& orbit,
86
87 const bool debug_prints = false;
88
89 std::unordered_map<entt::entity, BodyCache> body_cache;
90};
91} // namespace cqsp::core::systems
Wrapper class for all the components of the game, so that all the game stuff can be initialized in on...
Definition: game.h:27
Definition: isimulationsystem.h:25
Game & game
Definition: isimulationsystem.h:42
Definition: sysorbit.h:26
void CalculatePosition(entt::entity entity, components::types::Orbit &orbit, components::types::Kinematics &kinematics, components::types::FuturePosition &future_pos)
Definition: sysorbit.cpp:72
void ComputePosition(entt::entity parent, entt::entity body)
Definition: sysorbit.cpp:273
void Init() override
Definition: sysorbit.cpp:401
bool CheckEnterSOI(const entt::entity &parent, const entt::entity &body, components::types::Kinematics &pos)
Change the current body's SOI into a child SOI
Definition: sysorbit.cpp:321
void CalculateImpulse(components::types::Orbit &orb, entt::entity body)
Definition: sysorbit.cpp:177
void ComputeCenters(entt::entity entity, glm::dvec3 parent_pos, glm::dvec3 future_parent_pos)
Definition: sysorbit.cpp:385
void ParseOrbitTree(entt::entity parent, entt::entity body)
Definition: sysorbit.cpp:257
void ParseChildren(entt::entity body)
Definition: sysorbit.cpp:200
std::unordered_map< entt::entity, BodyCache > body_cache
Definition: sysorbit.h:89
void UpdateCommandQueue(components::types::Orbit &orb, entt::entity body, entt::entity parent)
Definition: sysorbit.cpp:223
int Interval() const override
Definition: sysorbit.h:30
void EnterSOI(entt::entity entity, entt::entity body, entt::entity parent, components::types::Orbit &orb, components::types::Kinematics &vehicle_position, const components::bodies::Body &body_comp, const components::types::Kinematics &target_position)
Definition: sysorbit.cpp:351
void DoSystem() override
Definition: sysorbit.cpp:44
void LeaveSOI(const entt::entity &body, entt::entity &parent, components::types::Orbit &orb, components::types::Kinematics &pos, components::types::Kinematics &p_pos)
Sets the SOI of the entity to the parent
Definition: sysorbit.cpp:112
const bool debug_prints
Definition: sysorbit.h:87
bool CrashObject(components::types::Orbit &orb, entt::entity body, components::types::Kinematics &pos, double radius)
Check if the entity has crashed into its parent object
Definition: sysorbit.cpp:144
SysOrbit(Game &game)
Definition: sysorbit.h:28
Definition: basicmaneuver.cpp:23
std::string parent
Definition: planetloader.cpp:51
Relative position from the parent orbiting object.
Definition: coordinates.h:30
double SOI
Definition: sysorbit.h:39
glm::dvec3 future_position
Definition: sysorbit.h:37
glm::dvec3 future_center
Definition: sysorbit.h:38
glm::dvec3 center
Definition: sysorbit.h:36
glm::dvec3 position
Definition: sysorbit.h:35
double radius
Definition: sysorbit.h:40