summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-12-03 00:44:57 +0100
committerAki <please@ignore.pl>2022-12-03 00:44:57 +0100
commit2f7d5c306430d65d18eac184551bac8937877d49 (patch)
tree36505d6b1df849c0d378ce58e4084fbd6c5aea50
parent18a763bcb19c5ece4b7b7d079dab07a1d915deb6 (diff)
downloadkurator-2f7d5c306430d65d18eac184551bac8937877d49.zip
kurator-2f7d5c306430d65d18eac184551bac8937877d49.tar.gz
kurator-2f7d5c306430d65d18eac184551bac8937877d49.tar.bz2
Renamed all battles module and ns references to sim
-rw-r--r--CMakeLists.txt2
-rw-r--r--kurator/CMakeLists.txt3
-rw-r--r--kurator/src/Battle.cpp32
-rw-r--r--kurator/src/Battle.h8
-rw-r--r--kurator/src/components.h6
-rw-r--r--sim/CMakeLists.txt2
-rw-r--r--sim/include/kurator/sim/Battle.h4
-rw-r--r--sim/include/kurator/sim/Point.h4
-rw-r--r--sim/include/kurator/sim/Scenario.h4
-rw-r--r--sim/include/kurator/sim/ShipConfig.h4
-rw-r--r--sim/include/kurator/sim/components.h4
-rw-r--r--sim/include/kurator/sim/events.h4
-rw-r--r--sim/include/kurator/sim/scenarios.h4
-rw-r--r--sim/src/BaseBattle.cpp10
-rw-r--r--sim/src/BaseBattle.h8
-rw-r--r--sim/src/Battle.cpp8
-rw-r--r--sim/src/Builder.cpp8
-rw-r--r--sim/src/Builder.h4
-rw-r--r--sim/src/Point.cpp6
-rw-r--r--sim/src/RandomSpawner.cpp8
-rw-r--r--sim/src/RandomSpawner.h6
-rw-r--r--sim/src/Scenario.cpp6
-rw-r--r--sim/src/Spawner.h6
-rw-r--r--sim/src/TeamManager.cpp4
-rw-r--r--sim/src/TeamManager.h4
-rw-r--r--sim/src/scenarios.cpp8
26 files changed, 84 insertions, 83 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6a2541b..3b0e4aa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,6 @@ set(CMAKE_CXX_EXTENSIONS No)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
find_package(EnTT 3 REQUIRED)
find_package(raylib 4 REQUIRED)
-add_subdirectory(battles)
add_subdirectory(kurator)
+add_subdirectory(sim)
add_subdirectory(universe)
diff --git a/kurator/CMakeLists.txt b/kurator/CMakeLists.txt
index c85cfdc..58a1e0c 100644
--- a/kurator/CMakeLists.txt
+++ b/kurator/CMakeLists.txt
@@ -10,6 +10,7 @@ add_executable(
)
target_link_libraries(
${PROJECT_NAME}
- PRIVATE battles
PRIVATE raylib
+ PRIVATE sim
+ PRIVATE universe
)
diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp
index 28c24c1..81f74fd 100644
--- a/kurator/src/Battle.cpp
+++ b/kurator/src/Battle.cpp
@@ -8,11 +8,11 @@
#include <raylib.h>
-#include <kurator/battles/Battle.h>
-#include <kurator/battles/components.h>
-#include <kurator/battles/events.h>
-#include <kurator/battles/Point.h>
-#include <kurator/battles/scenarios.h>
+#include <kurator/sim/Battle.h>
+#include <kurator/sim/components.h>
+#include <kurator/sim/events.h>
+#include <kurator/sim/Point.h>
+#include <kurator/sim/scenarios.h>
#include <kurator/universe/ShipType.h>
#include "components.h"
@@ -26,11 +26,11 @@ namespace kurator
Battle::Battle(std::shared_ptr<Session> _session) :
session {std::move(_session)},
- battle {battles::prepare(battles::scenarios::example())}
+ battle {sim::prepare(sim::scenarios::example())}
{
- battle->dispatcher().sink<battles::Hit>().connect<&Battle::receive>(*this);
+ battle->dispatcher().sink<sim::Hit>().connect<&Battle::receive>(*this);
auto& registry = battle->registry();
- auto ships = registry.view<battles::Team, universe::ShipType>();
+ auto ships = registry.view<sim::Team, universe::ShipType>();
for (const auto& [entity, team, type] : ships.each())
registry.emplace<Marker>(entity, 5.0, team.id ? GREEN : RED, type.name);
}
@@ -38,7 +38,7 @@ Battle::Battle(std::shared_ptr<Session> _session) :
Battle::~Battle()
{
- battle->dispatcher().sink<battles::Hit>().disconnect(*this);
+ battle->dispatcher().sink<sim::Hit>().disconnect(*this);
}
@@ -75,7 +75,7 @@ Battle::draw() const
const int height = GetScreenHeight();
const double scale = std::min(width/30000.0, height/30000.0);
auto& registry = battle->registry();
- auto view = registry.view<const Marker, const battles::Transform>();
+ auto view = registry.view<const Marker, const sim::Transform>();
for (auto [entity, marker, transform] : view.each()) {
const int x = width/2 + transform.position.x*scale;
const int y = height/2 + transform.position.y*scale;
@@ -83,13 +83,13 @@ Battle::draw() const
DrawLine(x, y, x + marker.radius*std::cos(transform.angle), y + marker.radius*std::sin(transform.angle), WHITE);
DrawText(marker.name.c_str(), x+10, y-10, 20.0f, GRAY);
}
- auto pops = registry.view<CenteredText, battles::Transform, UIOffset>();
+ auto pops = registry.view<CenteredText, sim::Transform, UIOffset>();
for (const auto& [entity, text, transform, offset] : pops.each()) {
const int x = width/2 + transform.position.x*scale - text.width/2 + offset.x;
const int y = height/2 + transform.position.y*scale - text.font_size/2 + offset.y;
DrawText(text.text.c_str(), x, y, text.font_size, text.color);
}
- auto points = registry.view<battles::HitPoints, battles::Team>();
+ auto points = registry.view<sim::HitPoints, sim::Team>();
double totals[2] {0.0, 0.0}; // FIXME and extract
for (const auto& [entity, points, team] : points.each()) {
if (team.id < 2)
@@ -105,19 +105,19 @@ Battle::draw() const
void
-Battle::receive(const battles::Hit& hit)
+Battle::receive(const sim::Hit& hit)
{
auto& registry = battle->registry();
if (!registry.valid(hit.victim))
return;
const auto entity = registry.create();
const std::string text = TextFormat("%.1f", hit.damage);
- const auto& transform = registry.get<battles::Transform>(hit.victim);
+ const auto& transform = registry.get<sim::Transform>(hit.victim);
registry.emplace<Timed>(entity, 1.2);
registry.emplace<CenteredText>(entity, text, MeasureText(text.c_str(), 10), 10, RED);
- registry.emplace<battles::Transform>(entity, transform.position, 0.0);
+ registry.emplace<sim::Transform>(entity, transform.position, 0.0);
registry.emplace<UIOffset>(entity, 0, 0);
- registry.emplace<PopMove>(entity, battles::Point{0.0, -20}, 0.9998);
+ registry.emplace<PopMove>(entity, sim::Point{0.0, -20}, 0.9998);
}
diff --git a/kurator/src/Battle.h b/kurator/src/Battle.h
index d59f024..85d4b18 100644
--- a/kurator/src/Battle.h
+++ b/kurator/src/Battle.h
@@ -2,8 +2,8 @@
#include <memory>
-#include <kurator/battles/Battle.h>
-#include <kurator/battles/events.h>
+#include <kurator/sim/Battle.h>
+#include <kurator/sim/events.h>
#include "Scene.h"
#include "Session.h"
@@ -20,10 +20,10 @@ public:
virtual ~Battle();
void update(float dt) override;
void draw() const override;
- void receive(const battles::Hit& hit);
+ void receive(const sim::Hit& hit);
private:
std::shared_ptr<Session> session;
- std::unique_ptr<battles::Battle> battle;
+ std::unique_ptr<sim::Battle> battle;
};
diff --git a/kurator/src/components.h b/kurator/src/components.h
index 5a6a43e..0b39ac0 100644
--- a/kurator/src/components.h
+++ b/kurator/src/components.h
@@ -4,7 +4,7 @@
#include <raylib.h>
-#include <kurator/battles/Point.h>
+#include <kurator/sim/Point.h>
namespace kurator
@@ -26,14 +26,14 @@ struct CenteredText
};
-struct UIOffset : public battles::Point
+struct UIOffset : public sim::Point
{
};
struct PopMove
{
- battles::Point speed;
+ sim::Point speed;
double damp;
};
diff --git a/sim/CMakeLists.txt b/sim/CMakeLists.txt
index f7478e3..fd7d75a 100644
--- a/sim/CMakeLists.txt
+++ b/sim/CMakeLists.txt
@@ -1,4 +1,4 @@
-project(battles)
+project(sim)
add_library(
${PROJECT_NAME}
src/BaseBattle.cpp
diff --git a/sim/include/kurator/sim/Battle.h b/sim/include/kurator/sim/Battle.h
index 1542597..e1728f4 100644
--- a/sim/include/kurator/sim/Battle.h
+++ b/sim/include/kurator/sim/Battle.h
@@ -10,7 +10,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -27,5 +27,5 @@ public:
auto prepare(const Scenario& scenario) -> std::unique_ptr<Battle>;
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/include/kurator/sim/Point.h b/sim/include/kurator/sim/Point.h
index ba9ab63..afd30ba 100644
--- a/sim/include/kurator/sim/Point.h
+++ b/sim/include/kurator/sim/Point.h
@@ -3,7 +3,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -22,5 +22,5 @@ struct Point
};
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/include/kurator/sim/Scenario.h b/sim/include/kurator/sim/Scenario.h
index afbb74c..b037365 100644
--- a/sim/include/kurator/sim/Scenario.h
+++ b/sim/include/kurator/sim/Scenario.h
@@ -8,7 +8,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -20,5 +20,5 @@ struct Scenario
};
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/include/kurator/sim/ShipConfig.h b/sim/include/kurator/sim/ShipConfig.h
index 2066430..bb089ac 100644
--- a/sim/include/kurator/sim/ShipConfig.h
+++ b/sim/include/kurator/sim/ShipConfig.h
@@ -6,7 +6,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -18,5 +18,5 @@ struct ShipConfig
};
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/include/kurator/sim/components.h b/sim/include/kurator/sim/components.h
index d4363c4..41c8053 100644
--- a/sim/include/kurator/sim/components.h
+++ b/sim/include/kurator/sim/components.h
@@ -7,7 +7,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -55,5 +55,5 @@ struct TurretControl
};
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/include/kurator/sim/events.h b/sim/include/kurator/sim/events.h
index 0e4af14..cacf443 100644
--- a/sim/include/kurator/sim/events.h
+++ b/sim/include/kurator/sim/events.h
@@ -5,7 +5,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -17,5 +17,5 @@ struct Hit
};
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/include/kurator/sim/scenarios.h b/sim/include/kurator/sim/scenarios.h
index 3d7e697..d22b62a 100644
--- a/sim/include/kurator/sim/scenarios.h
+++ b/sim/include/kurator/sim/scenarios.h
@@ -5,7 +5,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
namespace scenarios
{
@@ -15,5 +15,5 @@ Scenario example();
} // namespace scenarios
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/BaseBattle.cpp b/sim/src/BaseBattle.cpp
index 33e0957..3b56b0a 100644
--- a/sim/src/BaseBattle.cpp
+++ b/sim/src/BaseBattle.cpp
@@ -6,9 +6,9 @@
#include <entt/entity/registry.hpp>
#include <entt/signal/dispatcher.hpp>
-#include <kurator/battles/components.h>
-#include <kurator/battles/events.h>
-#include <kurator/battles/Scenario.h>
+#include <kurator/sim/components.h>
+#include <kurator/sim/events.h>
+#include <kurator/sim/Scenario.h>
#include <kurator/universe.h>
#include "Builder.h"
@@ -16,7 +16,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -158,5 +158,5 @@ BaseBattle::kill_off_dead()
}
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/BaseBattle.h b/sim/src/BaseBattle.h
index 8240fd2..13d7457 100644
--- a/sim/src/BaseBattle.h
+++ b/sim/src/BaseBattle.h
@@ -3,8 +3,8 @@
#include <entt/entity/registry.hpp>
#include <entt/signal/dispatcher.hpp>
-#include <kurator/battles/Battle.h>
-#include <kurator/battles/Scenario.h>
+#include <kurator/sim/Battle.h>
+#include <kurator/sim/Scenario.h>
#include "RandomSpawner.h"
#include "TeamManager.h"
@@ -12,7 +12,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -36,5 +36,5 @@ private:
};
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/Battle.cpp b/sim/src/Battle.cpp
index f44a88e..f8eacb5 100644
--- a/sim/src/Battle.cpp
+++ b/sim/src/Battle.cpp
@@ -1,15 +1,15 @@
-#include <kurator/battles/Battle.h>
+#include <kurator/sim/Battle.h>
#include <memory>
-#include <kurator/battles/Scenario.h>
+#include <kurator/sim/Scenario.h>
#include "BaseBattle.h"
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -20,5 +20,5 @@ prepare(const Scenario& scenario)
}
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/Builder.cpp b/sim/src/Builder.cpp
index d7cc893..dd10326 100644
--- a/sim/src/Builder.cpp
+++ b/sim/src/Builder.cpp
@@ -2,8 +2,8 @@
#include <entt/entity/registry.hpp>
-#include <kurator/battles/components.h>
-#include <kurator/battles/Point.h>
+#include <kurator/sim/components.h>
+#include <kurator/sim/Point.h>
#include <kurator/universe/ShipType.h>
#include <kurator/universe/TurretType.h>
@@ -12,7 +12,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -53,5 +53,5 @@ Builder::operator()(const universe::TurretType& turret_type, const entt::entity&
}
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/Builder.h b/sim/src/Builder.h
index df50c4e..31c7120 100644
--- a/sim/src/Builder.h
+++ b/sim/src/Builder.h
@@ -10,7 +10,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -31,5 +31,5 @@ private:
};
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/Point.cpp b/sim/src/Point.cpp
index 31aecae..1f49774 100644
--- a/sim/src/Point.cpp
+++ b/sim/src/Point.cpp
@@ -1,11 +1,11 @@
-#include <kurator/battles/Point.h>
+#include <kurator/sim/Point.h>
#include <cmath>
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -68,5 +68,5 @@ Point::operator+(const Point& other) const
}
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/RandomSpawner.cpp b/sim/src/RandomSpawner.cpp
index b85d140..8c401b2 100644
--- a/sim/src/RandomSpawner.cpp
+++ b/sim/src/RandomSpawner.cpp
@@ -2,13 +2,13 @@
#include <cmath>
-#include <kurator/battles/components.h>
-#include <kurator/battles/Point.h>
+#include <kurator/sim/components.h>
+#include <kurator/sim/Point.h>
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -38,5 +38,5 @@ RandomSpawner::get(const int team)
}
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/RandomSpawner.h b/sim/src/RandomSpawner.h
index 1ef2f20..d34e1ba 100644
--- a/sim/src/RandomSpawner.h
+++ b/sim/src/RandomSpawner.h
@@ -2,14 +2,14 @@
#include <random>
-#include <kurator/battles/components.h>
+#include <kurator/sim/components.h>
#include "Spawner.h"
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -26,5 +26,5 @@ private:
};
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/Scenario.cpp b/sim/src/Scenario.cpp
index 49a9c7c..49201c3 100644
--- a/sim/src/Scenario.cpp
+++ b/sim/src/Scenario.cpp
@@ -1,9 +1,9 @@
-#include <kurator/battles/Scenario.h>
+#include <kurator/sim/Scenario.h>
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -19,5 +19,5 @@ Scenario::total_teams() const
}
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/Spawner.h b/sim/src/Spawner.h
index ebae699..ae3f2fd 100644
--- a/sim/src/Spawner.h
+++ b/sim/src/Spawner.h
@@ -1,11 +1,11 @@
#pragma once
-#include <kurator/battles/components.h>
+#include <kurator/sim/components.h>
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -17,5 +17,5 @@ public:
};
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/TeamManager.cpp b/sim/src/TeamManager.cpp
index 9dc90e3..2dc3196 100644
--- a/sim/src/TeamManager.cpp
+++ b/sim/src/TeamManager.cpp
@@ -10,7 +10,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -58,5 +58,5 @@ TeamManager::clear(entt::registry& registry)
}
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/TeamManager.h b/sim/src/TeamManager.h
index 384d9ee..abc6d23 100644
--- a/sim/src/TeamManager.h
+++ b/sim/src/TeamManager.h
@@ -8,7 +8,7 @@
namespace kurator
{
-namespace battles
+namespace sim
{
@@ -27,5 +27,5 @@ private:
};
-} // namespace battles
+} // namespace sim
} // namespace kurator
diff --git a/sim/src/scenarios.cpp b/sim/src/scenarios.cpp
index 34b4a24..65588bf 100644
--- a/sim/src/scenarios.cpp
+++ b/sim/src/scenarios.cpp
@@ -1,11 +1,11 @@
-#include <kurator/battles/scenarios.h>
+#include <kurator/sim/scenarios.h>
-#include <kurator/battles/Scenario.h>
+#include <kurator/sim/Scenario.h>
namespace kurator
{
-namespace battles
+namespace sim
{
namespace scenarios
{
@@ -39,5 +39,5 @@ example()
} // namespace scenarios
-} // namespace battles
+} // namespace sim
} // namespace kurator