aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-12-04 13:46:41 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-12-04 13:46:41 +0100
commitf9f5600b60d6944dc9a7dd502988703d59d0cd62 (patch)
tree4f6d7cfe7e15bf0fd3b838769cb2a093de487ba6 /src/crepe/system
parentac87bfad20e1bcf1fd066a4eda231608fe12f504 (diff)
Setup some behaviors
Diffstat (limited to 'src/crepe/system')
-rw-r--r--src/crepe/system/AISystem.cpp32
-rw-r--r--src/crepe/system/AISystem.h6
2 files changed, 36 insertions, 2 deletions
diff --git a/src/crepe/system/AISystem.cpp b/src/crepe/system/AISystem.cpp
index 012f4fa..12da3d9 100644
--- a/src/crepe/system/AISystem.cpp
+++ b/src/crepe/system/AISystem.cpp
@@ -1,6 +1,34 @@
+#include "../ComponentManager.h"
+
#include "AISystem.h"
-#include <iostream>
using namespace crepe;
-void AISystem::update() { std::cout << "AI System update" << std::endl; }
+void AISystem::update() {
+ ComponentManager & mgr = this->component_manager;
+ RefVector<AI> ai_components = mgr.get_components_by_type<AI>();
+
+ for (AI & ai : ai_components) {
+ vec2 force = this->calculate(ai);
+ //...
+ }
+}
+
+vec2 AISystem::calculate(AI & ai) {
+ vec2 force;
+
+ if (ai.on(AI::BehaviorType::SEEK)) {
+ // Seek the target
+ }
+ if (ai.on(AI::BehaviorType::FLEE)) {
+ // Flee from the target
+ }
+ if (ai.on(AI::BehaviorType::ARRIVE)) {
+ // Arrive at the target
+ }
+ if (ai.on(AI::BehaviorType::PATH_FOLLOW)) {
+ // Follow the path
+ }
+
+ return force;
+}
diff --git a/src/crepe/system/AISystem.h b/src/crepe/system/AISystem.h
index 4138e01..eb8d08c 100644
--- a/src/crepe/system/AISystem.h
+++ b/src/crepe/system/AISystem.h
@@ -1,6 +1,9 @@
#pragma once
+#include "api/AI.h"
+
#include "System.h"
+#include "types.h"
namespace crepe {
@@ -9,6 +12,9 @@ public:
using System::System;
void update() override;
+
+private:
+ vec2 calculate(AI & ai);
};
} // namespace crepe