30 lines
726 B
GDScript
30 lines
726 B
GDScript
extends Area2D
|
|
|
|
signal spotChanged
|
|
|
|
onready var spot : Spot = get_node("../..")
|
|
|
|
var current_bod: PersonBody = null
|
|
var bod_in = false
|
|
|
|
func onBodyEnter(body: Node):
|
|
current_bod = body
|
|
|
|
func onBodyLeft(_body: Node):
|
|
current_bod = null
|
|
|
|
func _process(_delta):
|
|
if bod_in == false and current_bod != null and !current_bod.held:
|
|
center_bod()
|
|
emit_signal("spotChanged")
|
|
else if bod_in == true and current_bod == null:
|
|
emit_signal("spotChanged")
|
|
bod_in = !current_bod.held if current_bod != null else false
|
|
if current_bod:
|
|
current_bod.in_spot = bod_in
|
|
spot.person = current_bod.get_parent() if bod_in else null
|
|
|
|
func center_bod():
|
|
var root : PersonRoot = current_bod.get_parent()
|
|
root.position = spot.position
|