You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
GDScript
53 lines
1.2 KiB
GDScript
extends Node
|
|
|
|
# Event Handler for Moving
|
|
|
|
# Variable
|
|
var topic = "moved"
|
|
var positions = []
|
|
|
|
func _arrived(_character):
|
|
return false
|
|
|
|
# are positions the same?
|
|
func compare_pos():
|
|
var p1 = positions[0]
|
|
for p in positions:
|
|
if p != p1:
|
|
return false # moving
|
|
return true # not moving
|
|
|
|
func _reached(_character):
|
|
return false
|
|
|
|
func track_pos(new_pos):
|
|
positions.append(new_pos)
|
|
if len(positions) > 50:
|
|
positions.pop_front()
|
|
|
|
# Handle
|
|
func handle(_character):
|
|
return
|
|
# var current_pos = character.get_gpos()
|
|
# track_pos(current_pos)
|
|
# if _arrived(character):
|
|
# character.think("Moved/Arrived")
|
|
# character.emit_signal("arrived")
|
|
# return
|
|
# elif _reached(character):
|
|
# character.think("Moved/Reached Dot")
|
|
# character.emit_signal("reached")
|
|
# return
|
|
# elif compare_pos():
|
|
# character.think("Moved/Not Moving")
|
|
# character.emit_signal("not_moving")
|
|
# return
|
|
#elif character.get_internal_velocity() != Vector2(0.0,0.0) and character.get_velocity() != character.get_internal_velocity():
|
|
# var sdfoia = character.get_internal_velocity()
|
|
# var posjk = character.get_velocity()
|
|
# character.think("Moved/Wrong Directiaon")
|
|
# character.emit_signal("wrong_direction")
|
|
#else:
|
|
# return
|
|
|