summaryrefslogtreecommitdiff
path: root/sim/src/systems.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-02-14 00:13:02 +0100
committerAki <please@ignore.pl>2023-02-14 00:28:48 +0100
commit632c367ae6885657e6c99b96b8bf7a96b61a2bb9 (patch)
tree3b6210086d2c082533288d06f2843b9150e747dd /sim/src/systems.cpp
parent2a9f378c66b28cef1c5ee063cf4d7e4e2889076e (diff)
downloadkurator-632c367ae6885657e6c99b96b8bf7a96b61a2bb9.zip
kurator-632c367ae6885657e6c99b96b8bf7a96b61a2bb9.tar.gz
kurator-632c367ae6885657e6c99b96b8bf7a96b61a2bb9.tar.bz2
Extracted basic simulation behaviour and that part of state to own class
Diffstat (limited to 'sim/src/systems.cpp')
-rw-r--r--sim/src/systems.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/sim/src/systems.cpp b/sim/src/systems.cpp
index 114ed2f..4dc1e71 100644
--- a/sim/src/systems.cpp
+++ b/sim/src/systems.cpp
@@ -1,4 +1,4 @@
-#include <kurator/sim/systems.h>
+#include "systems.h"
#include <kurator/engine/Context.h>
#include <kurator/sim/components.h>
@@ -15,6 +15,17 @@ namespace sim
void
+pick_random_targets(engine::Context& ctx, TeamManager& manager)
+{
+ auto view = ctx.registry.view<Team, AIState>();
+ for (auto&& [entity, team, ai] : view.each()) {
+ if (!ctx.registry.valid(ai.target))
+ ai.target = manager.random(team.id);
+ }
+}
+
+
+void
keep_at_range(engine::Context& ctx)
{
auto view = ctx.registry.view<Transform, AIState>();