blob: 886bb308a04aa794f8160957fa31fe754759e43f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
extends Node
class_name AI
@export_group("Values")
@export var max_distance : float
@export_group("Scenes")
@export var shape_cast_original : ShapeCast2D
@export var shape_cast_skill_issue: ShapeCast2D
func _ready():
GlobalVariables.ai = self
func _process(_delta):
shape_cast_original.shape.radius = max_distance
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:
if !alternative:
step(true)
print("i have skill issue")
else:
print("i am softlocked!")
|