goodnight_jellybean/godot/GlobalCursorState.gd

48 lines
939 B
GDScript3
Raw Normal View History

2023-06-05 08:00:14 -06:00
extends Node3D
2022-12-31 01:19:40 -07:00
var cursor = weakref(null)
2023-01-01 14:02:34 -07:00
var is_frozen = false
2022-12-31 01:19:40 -07:00
signal cursor_interact
2023-01-01 19:59:44 -07:00
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
2022-12-31 01:19:40 -07:00
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()
2023-06-05 08:00:14 -06:00
signal sig_freeze
signal sig_unfreeze
2023-01-01 14:02:34 -07:00
func freeze():
is_frozen = true
2023-06-05 08:00:14 -06:00
emit_signal("sig_freeze")
2023-01-01 14:02:34 -07:00
func unfreeze():
is_frozen = false
2023-06-05 08:00:14 -06:00
emit_signal("sig_unfreeze")
2023-01-01 14:02:34 -07:00
2022-12-31 01:19:40 -07:00
# Interact events:
#########################################
func _on_Interact_leave_disclaimer():
2023-06-05 08:00:14 -06:00
var _err = get_tree().change_scene_to_file("res://world.tscn")
2023-01-01 02:23:56 -07:00
2023-01-01 14:02:34 -07:00
signal unchecked_goal(phrase)
func _on_Cursor_goal(phrase: Array):
emit_signal("unchecked_goal", phrase)
2023-01-01 02:23:56 -07:00
2023-06-05 08:00:14 -06:00
# Camera3D zones
2023-01-01 02:23:56 -07:00
signal set_camera_zone(zone)
func _on_Cursor_set_camera(where: String):
emit_signal("set_camera_zone", where)