diff options
author | altaf-creator <dev@altafcreator.com> | 2024-04-13 21:50:12 +0700 |
---|---|---|
committer | altaf-creator <dev@altafcreator.com> | 2024-04-13 21:50:12 +0700 |
commit | b97ebd793eb17032f3929f307dfe644b17714619 (patch) | |
tree | 03a558e77757112a6fddce45dbbcc0139df479c2 /Scripts/AI.gd | |
parent | c5a806528af8a4de5f903d26cd33edb7e0bb6597 (diff) |
bare bones ai, softlock issues
Diffstat (limited to 'Scripts/AI.gd')
-rw-r--r-- | Scripts/AI.gd | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Scripts/AI.gd b/Scripts/AI.gd new file mode 100644 index 0000000..d5cbcbe --- /dev/null +++ b/Scripts/AI.gd @@ -0,0 +1,37 @@ +extends Node +class_name AI + +@export_group("Values") + +@export_group("Scenes") +@export var shape_cast_original : ShapeCast2D +@export var shape_cast_skill_issue: ShapeCast2D + +func _ready(): + GlobalVariables.ai = self + +func step(alternative : bool = false): + var shape_cast : ShapeCast2D + + if !alternative: + shape_cast = shape_cast_original + else: + shape_cast = shape_cast_skill_issue + + shape_cast.force_shapecast_update() + + var nodes : Array[NumberNode] = [] + + print(shape_cast.collision_result) + + for collision in shape_cast.collision_result: + if collision.collider.get_node("..") is NumberNode: + if collision.collider.get_node("..").do_scanning: + nodes.append(collision.collider.get_node("..")) + + nodes.sort_custom(func(a, b): return a.value > b.value) + + if nodes.size() > 0: + nodes[0].join_from($"..") + else: + step(true) |