diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | engine/CMakeLists.txt | 9 | ||||
-rw-r--r-- | engine/include/kurator/engine/Point.h (renamed from sim/include/kurator/sim/Point.h) | 4 | ||||
-rw-r--r-- | engine/src/Point.cpp (renamed from sim/src/Point.cpp) | 6 | ||||
-rw-r--r-- | kurator/src/Battle.cpp | 1 | ||||
-rw-r--r-- | kurator/src/Camera.h | 4 | ||||
-rw-r--r-- | kurator/src/PopupEmitter.cpp | 4 | ||||
-rw-r--r-- | kurator/src/components.h | 10 | ||||
-rw-r--r-- | sim/CMakeLists.txt | 2 | ||||
-rw-r--r-- | sim/include/kurator/sim/FloatingMovement.h | 4 | ||||
-rw-r--r-- | sim/include/kurator/sim/components.h | 6 | ||||
-rw-r--r-- | sim/src/BaseBattle.cpp | 2 | ||||
-rw-r--r-- | sim/src/Builder.cpp | 5 | ||||
-rw-r--r-- | sim/src/RandomSpawner.cpp | 4 |
14 files changed, 37 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 79eae9f..ae2a9b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ include(AddResources) include(AddVersionFile) add_subdirectory(campaign) add_subdirectory(contrib) +add_subdirectory(engine) add_subdirectory(kurator) add_subdirectory(sim) add_subdirectory(stats) diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt new file mode 100644 index 0000000..041965a --- /dev/null +++ b/engine/CMakeLists.txt @@ -0,0 +1,9 @@ +project(engine) +add_library( + ${PROJECT_NAME} STATIC + src/Point.cpp +) +target_include_directories( + ${PROJECT_NAME} + PUBLIC include +) diff --git a/sim/include/kurator/sim/Point.h b/engine/include/kurator/engine/Point.h index afd30ba..0e9f0ab 100644 --- a/sim/include/kurator/sim/Point.h +++ b/engine/include/kurator/engine/Point.h @@ -3,7 +3,7 @@ namespace kurator { -namespace sim +namespace engine { @@ -22,5 +22,5 @@ struct Point }; -} // namespace sim +} // namespace engine } // namespace kurator diff --git a/sim/src/Point.cpp b/engine/src/Point.cpp index 1f49774..b5ce4eb 100644 --- a/sim/src/Point.cpp +++ b/engine/src/Point.cpp @@ -1,11 +1,11 @@ -#include <kurator/sim/Point.h> +#include <kurator/engine/Point.h> #include <cmath> namespace kurator { -namespace sim +namespace engine { @@ -68,5 +68,5 @@ Point::operator+(const Point& other) const } -} // namespace sim +} // namespace engine } // namespace kurator diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp index d6df0b1..d300011 100644 --- a/kurator/src/Battle.cpp +++ b/kurator/src/Battle.cpp @@ -14,7 +14,6 @@ #include <kurator/sim/Battle.h> #include <kurator/sim/components.h> #include <kurator/sim/events.h> -#include <kurator/sim/Point.h> #include <kurator/stats/events.h> #include <kurator/universe/ShipType.h> #include <kurator/universe/UniqueIdentifier.h> diff --git a/kurator/src/Camera.h b/kurator/src/Camera.h index b6ca7d1..6056c7a 100644 --- a/kurator/src/Camera.h +++ b/kurator/src/Camera.h @@ -1,6 +1,6 @@ #pragma once -#include <kurator/sim/Point.h> +#include <kurator/engine/Point.h> namespace kurator @@ -9,7 +9,7 @@ namespace kurator struct Camera { - sim::Point offset = {}; + engine::Point offset = {}; double scale = 1.0; }; diff --git a/kurator/src/PopupEmitter.cpp b/kurator/src/PopupEmitter.cpp index c382ef1..0605da2 100644 --- a/kurator/src/PopupEmitter.cpp +++ b/kurator/src/PopupEmitter.cpp @@ -5,8 +5,8 @@ #include <entt/entity/registry.hpp> #include <raylib.h> +#include <kurator/engine/Point.h> #include <kurator/sim/components.h> -#include <kurator/sim/Point.h> #include "components.h" @@ -26,7 +26,7 @@ PopupEmitter::emit(entt::registry& registry, const sim::Transform& transform, co registry.emplace<sim::Transform>(popup, transform.position, 0.0); registry.emplace<CenteredText>(popup, std::string{}, 0, size, RED); registry.emplace<UIOffset>(popup, 0, 0); - registry.emplace<PopMove>(popup, sim::Point{0, -20}, 0.9998); + registry.emplace<PopMove>(popup, engine::Point{0, -20}, 0.9998); } total += damage; auto& text = registry.get<CenteredText>(popup); diff --git a/kurator/src/components.h b/kurator/src/components.h index bcd34e6..ff52bfe 100644 --- a/kurator/src/components.h +++ b/kurator/src/components.h @@ -4,7 +4,7 @@ #include <raylib.h> -#include <kurator/sim/Point.h> +#include <kurator/engine/Point.h> namespace kurator @@ -27,14 +27,14 @@ struct CenteredText }; -struct UIOffset : public sim::Point +struct UIOffset : public engine::Point { }; struct PopMove { - sim::Point speed; + engine::Point speed; double damp; }; @@ -50,8 +50,8 @@ struct Marker struct Line { Color color; - sim::Point start; - sim::Point end; + engine::Point start; + engine::Point end; double hlength; double duration; double position = 0.0; diff --git a/sim/CMakeLists.txt b/sim/CMakeLists.txt index 1cae7b0..ef80c77 100644 --- a/sim/CMakeLists.txt +++ b/sim/CMakeLists.txt @@ -6,7 +6,6 @@ add_library( src/Builder.cpp src/FloatingMovement.cpp src/HitPoints.cpp - src/Point.cpp src/RandomSpawner.cpp src/TeamManager.cpp src/TurretControl.cpp @@ -19,6 +18,7 @@ target_link_libraries( ${PROJECT_NAME} PUBLIC EnTT::EnTT PUBLIC campaign + PUBLIC engine PRIVATE stats PUBLIC universe ) diff --git a/sim/include/kurator/sim/FloatingMovement.h b/sim/include/kurator/sim/FloatingMovement.h index 352377d..d7e8479 100644 --- a/sim/include/kurator/sim/FloatingMovement.h +++ b/sim/include/kurator/sim/FloatingMovement.h @@ -3,7 +3,7 @@ #include <entt/entity/registry.hpp> #include <entt/signal/dispatcher.hpp> -#include "Point.h" +#include <kurator/engine/Point.h> namespace kurator @@ -18,7 +18,7 @@ struct FloatingMovement double acceleration; double deceleration; double destination_boundary = 100.0; - Point speed = {0.0, 0.0}; + engine::Point speed = {0.0, 0.0}; static void update(entt::registry& registry, entt::dispatcher& dispatcher, float dt); }; diff --git a/sim/include/kurator/sim/components.h b/sim/include/kurator/sim/components.h index f4f1799..e8b2591 100644 --- a/sim/include/kurator/sim/components.h +++ b/sim/include/kurator/sim/components.h @@ -2,7 +2,7 @@ #include <entt/entity/entity.hpp> -#include "Point.h" +#include <kurator/engine/Point.h> namespace kurator @@ -13,7 +13,7 @@ namespace sim struct Transform { - Point position; + engine::Point position; double angle; entt::entity reference_frame = entt::null; }; @@ -28,7 +28,7 @@ struct Team struct AIState { double keep_at_range; - Point destination; + engine::Point destination; entt::entity target = entt::null; }; diff --git a/sim/src/BaseBattle.cpp b/sim/src/BaseBattle.cpp index 99a0199..3e3815c 100644 --- a/sim/src/BaseBattle.cpp +++ b/sim/src/BaseBattle.cpp @@ -89,7 +89,7 @@ BaseBattle::keep_at_range() if (!_registry.valid(ai.target)) continue; const auto target = _registry.get<Transform>(ai.target); - const Point offset = target.position - self.position; + const auto offset = target.position - self.position; ai.destination = target.position - offset.normalized().scale(ai.keep_at_range); } } diff --git a/sim/src/Builder.cpp b/sim/src/Builder.cpp index b5762b3..279cd8b 100644 --- a/sim/src/Builder.cpp +++ b/sim/src/Builder.cpp @@ -2,10 +2,10 @@ #include <entt/entity/registry.hpp> +#include <kurator/engine/Point.h> #include <kurator/sim/components.h> #include <kurator/sim/FloatingMovement.h> #include <kurator/sim/HitPoints.h> -#include <kurator/sim/Point.h> #include <kurator/sim/TurretControl.h> #include <kurator/universe/ShipType.h> #include <kurator/universe/TurretType.h> @@ -19,6 +19,9 @@ namespace sim { +using engine::Point; + + Builder::Builder(entt::registry& _registry, Spawner& _spawner) : registry {_registry}, spawner {_spawner} diff --git a/sim/src/RandomSpawner.cpp b/sim/src/RandomSpawner.cpp index 7b85f21..a0b0f78 100644 --- a/sim/src/RandomSpawner.cpp +++ b/sim/src/RandomSpawner.cpp @@ -2,8 +2,8 @@ #include <cmath> +#include <kurator/engine/Point.h> #include <kurator/sim/components.h> -#include <kurator/sim/Point.h> namespace kurator @@ -30,7 +30,7 @@ RandomSpawner::get(const int team) double facing = clean_angle + M_PI; if (facing > 2 * M_PI) facing -= 2 * M_PI; - const Point position { + const engine::Point position { distance * std::cos(angle), distance * std::sin(angle), }; |