goodnight_jellybean/godot/GlobalCursorState.gd

48 lines
939 B
GDScript

extends Node3D
var cursor = weakref(null)
var is_frozen = false
signal cursor_interact
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
func set_cursor(set_as: Node):
cursor = weakref(set_as)
func is_cursor_collision(body):
return get_cursor() == body
func fire_interact():
emit_signal("cursor_interact")
func get_cursor():
return cursor.get_ref()
signal sig_freeze
signal sig_unfreeze
func freeze():
is_frozen = true
emit_signal("sig_freeze")
func unfreeze():
is_frozen = false
emit_signal("sig_unfreeze")
# Interact events:
#########################################
func _on_Interact_leave_disclaimer():
var _err = get_tree().change_scene_to_file("res://world.tscn")
signal unchecked_goal(phrase)
func _on_Cursor_goal(phrase: Array):
emit_signal("unchecked_goal", phrase)
# Camera3D zones
signal set_camera_zone(zone)
func _on_Cursor_set_camera(where: String):
emit_signal("set_camera_zone", where)