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.
maneuver.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 <cmath>
20#include <deque>
21#include <utility>
22
24
25namespace cqsp::core::components {
26// Datatype returned by a command
27// impulse vector and time in seconds of the maneuver
28typedef std::pair<glm::dvec3, double> Maneuver_t;
29typedef std::pair<Maneuver_t, Maneuver_t> HohmannPair_t;
30
33struct Maneuver {
41 const glm::dvec3 delta_v;
42 const double time;
43 Maneuver() = delete;
44 explicit Maneuver(const std::pair<glm::dvec3, double>& maneuver) : delta_v(maneuver.first), time(maneuver.second) {
45 assert(std::isfinite(time));
46 }
47 /*
48 * @param maneuver maneuver pair
49 * @param offset seconds to offset how far in the future or in the past to put this maneuver
50 */
51 explicit Maneuver(const std::pair<glm::dvec3, double>& maneuver, double current_time)
52 : delta_v(maneuver.first), time(maneuver.second + current_time) {
53 assert(std::isfinite(time));
54 }
55};
56
58 std::deque<Maneuver> maneuvers;
59 std::deque<entt::entity> commands;
60 CommandQueue() = default;
61
62 auto begin() { return maneuvers.begin(); }
63 auto end() { return maneuvers.end(); }
64 bool empty() { return maneuvers.empty(); }
65 entt::entity& front() { return commands.front(); }
66};
67} // namespace cqsp::core::components
double second
Definition: units.h:42
Definition: area.h:23
std::pair< glm::dvec3, double > Maneuver_t
Definition: maneuver.h:28
std::pair< Maneuver_t, Maneuver_t > HohmannPair_t
Definition: maneuver.h:29
Definition: maneuver.h:57
std::deque< Maneuver > maneuvers
Definition: maneuver.h:58
auto end()
Definition: maneuver.h:63
entt::entity & front()
Definition: maneuver.h:65
std::deque< entt::entity > commands
Definition: maneuver.h:59
bool empty()
Definition: maneuver.h:64
auto begin()
Definition: maneuver.h:62
Definition: maneuver.h:33
Maneuver(const std::pair< glm::dvec3, double > &maneuver, double current_time)
Definition: maneuver.h:51
const double time
Definition: maneuver.h:42
const glm::dvec3 delta_v
Delta v applied with respect to the orbital vector positive y is prograde, negative y is retrograde I...
Definition: maneuver.h:41
Maneuver(const std::pair< glm::dvec3, double > &maneuver)
Definition: maneuver.h:44