feat: implemented patrol behaviour
This commit is contained in:
parent
425525e56f
commit
8dbc7fc4ac
23 changed files with 270 additions and 139 deletions
|
|
@ -4,13 +4,15 @@ extends Area3D
|
|||
|
||||
var aware : Array[Node3D]
|
||||
|
||||
func _body_entered(node : Node3D):
|
||||
func _entered(node : Node3D):
|
||||
if node.is_in_group(target_group):
|
||||
aware.push_back(node)
|
||||
|
||||
func _body_exited(node : Node3D):
|
||||
func _exited(node : Node3D):
|
||||
aware.erase(node)
|
||||
|
||||
func _ready():
|
||||
body_entered.connect(_body_entered)
|
||||
body_exited.connect(_body_exited)
|
||||
area_entered.connect(_entered)
|
||||
area_exited.connect(_exited)
|
||||
body_entered.connect(_entered)
|
||||
body_exited.connect(_exited)
|
||||
|
|
|
|||
|
|
@ -11,21 +11,26 @@ func _body_entered(node : Node3D):
|
|||
if deal_damage and node.is_in_group(damage_group):
|
||||
node.emit_signal("damaged", weapon.power, source)
|
||||
|
||||
func set_weapon(instance : Area3D):
|
||||
if instance == null:
|
||||
push_error("Requested node is not a weapon, expected Area3D")
|
||||
return
|
||||
func drop_weapon():
|
||||
if weapon:
|
||||
weapon.body_entered.disconnect(_body_entered)
|
||||
remove_child(weapon)
|
||||
get_tree().current_scene.add_child(weapon)
|
||||
weapon.global_position = owner.global_position
|
||||
weapon.global_basis = ground_rotation
|
||||
weapon.held = false
|
||||
|
||||
func set_weapon(instance : Area3D):
|
||||
if instance == null:
|
||||
push_error("Requested node is not a weapon, expected Area3D")
|
||||
return
|
||||
drop_weapon()
|
||||
ground_rotation = instance.global_basis
|
||||
if instance.is_inside_tree():
|
||||
instance.get_parent().remove_child(instance)
|
||||
add_child(instance)
|
||||
deal_damage = false
|
||||
weapon = instance
|
||||
instance.held = true
|
||||
instance.body_entered.connect(_body_entered)
|
||||
instance.global_transform = global_transform
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue