summaryrefslogtreecommitdiffhomepage
path: root/app/systems/ai
diff options
context:
space:
mode:
authorarngo <[email protected]>2021-12-23 01:04:59 -0500
committerarngo <[email protected]>2021-12-23 01:04:59 -0500
commit8116ce1f56aaf5344596ca16177c7abff11b1496 (patch)
treeac0b5e048f6b056129b01439fb20b89861efeee5 /app/systems/ai
parentb567c7ceb887a8da73a8e2c1015a7638ca1f8fad (diff)
downloadSteelWings-8116ce1f56aaf5344596ca16177c7abff11b1496.tar.gz
SteelWings-8116ce1f56aaf5344596ca16177c7abff11b1496.zip
implement ai components/systems
Diffstat (limited to 'app/systems/ai')
-rw-r--r--app/systems/ai/rejoin.rb14
-rw-r--r--app/systems/ai/scatter.rb18
-rw-r--r--app/systems/ai/target_player.rb11
3 files changed, 43 insertions, 0 deletions
diff --git a/app/systems/ai/rejoin.rb b/app/systems/ai/rejoin.rb
new file mode 100644
index 0000000..51137f9
--- /dev/null
+++ b/app/systems/ai/rejoin.rb
@@ -0,0 +1,14 @@
+FF::Sys.new("Rejoin", priority: 40) do
+ FF::Cmp::BoidsSeparation.each do |sep|
+ puts 'add align/cohesion'.upcase
+ sep.distance = 150
+ alignment_mgr = sep.entities[0].components[FF::Cmp::BoidsAlignment]
+ cohesion_mgr = sep.entities[0].components[FF::Cmp::BoidsCohesion]
+ if alignment_mgr.nil? || alignment_mgr.empty?
+ sep.entities[0].add FF::Cmp::BoidsAlignment.new(strength: 10)
+ end
+ if cohesion_mgr.nil? || cohesion_mgr.empty?
+ sep.entities[0].add FF::Cmp::BoidsCohesion.new(strength: 1000)
+ end
+ end
+end
diff --git a/app/systems/ai/scatter.rb b/app/systems/ai/scatter.rb
new file mode 100644
index 0000000..9b93c73
--- /dev/null
+++ b/app/systems/ai/scatter.rb
@@ -0,0 +1,18 @@
+FF::Sys.new("Scatter", priority: 40) do
+ FF::Cmp::BoidsSeparation.each do |sep|
+ sep.distance = 200
+ puts 'remove align/cohesion/follow'.upcase
+ alignment_mgr = sep.entities[0].components[FF::Cmp::BoidsAlignment]
+ cohesion_mgr = sep.entities[0].components[FF::Cmp::BoidsCohesion]
+ follow_mgr = sep.entities[0].components[FF::Cmp::Follow]
+ unless follow_mgr.nil? || follow_mgr.empty?
+ follow_mgr[0].delete
+ end
+ unless alignment_mgr.nil? || alignment_mgr.empty?
+ alignment_mgr[0].delete
+ end
+ unless cohesion_mgr.nil? || cohesion_mgr.empty?
+ cohesion_mgr[0].delete
+ end
+ end
+end
diff --git a/app/systems/ai/target_player.rb b/app/systems/ai/target_player.rb
new file mode 100644
index 0000000..c72ffb4
--- /dev/null
+++ b/app/systems/ai/target_player.rb
@@ -0,0 +1,11 @@
+FF::Sys.new("TargetPlayer", priority: 40) do
+ FF::Cmp::BoidsSeparation.each do |sep|
+ puts 'target player'.upcase
+ sep.distance = 200
+ follow_mgr = sep.entities[0].components[FF::Cmp::Follow]
+ player_boid = FF::Cmp::SingletonPlayer[0].entities[0].components[FF::Cmp::Boid][0]
+ if follow_mgr.nil? || follow_mgr.empty?
+ sep.entities[0].add FF::Cmp::Follow.new(target: player_boid, strength: 500)
+ end
+ end
+end