Utoljára aktív 1747575254

A collection of files I consider to be at the "core" of CC

Revízió 2768b1d0488ff457c264f20ae9611b779217b066

main.gd Eredeti Playground
1# warning-ignore-all:return_value_discarded
2extends HBoxContainer
3class_name ChitinousCanrival
4
5const event_player_scene = preload("res://scenes/ui/EventPlayer.tscn")
6
7@onready var MinigameHandler := %MinigameHandler as MinigameHandler
8@onready var TravelButtons := %TravelButtons as TravelButtons
9@onready var EventPlayerContainer := %EventPlayerContainer as EventPlayerContainer
10@onready var InventoryMenu := %InventoryMenu as InventoryMenu
11@onready var SettingsMenu := %SettingsMenu as SettingsMenu
12@onready var SaveMenu := %SaveMenu as SaveMenu
13@onready var ChoicePanel := %ChoicePanel as Choice
14@onready var StatusPanel := %StatusPanel as StatusPanel
15@onready var Blackout := %BlackoutPanel as BlackoutPanel
16
17var _current_sequence: String = ""
18
19func _ready() -> void:
20 randomize()
21
22 MusicState.change_bg(MusicState.BACKGROUND_THEME)
23
24 ExploreState.set_start_time()
25 ExploreState._set_location(SimpleState.state.explore.location)
26 TravelButtons.set_button_disabled(SimpleState.state.explore.location)
27
28 SaveState.save_loaded.connect(_on_save_loaded)
29 EventPlayerContainer.minigame_started.connect(_on_minigame_started)
30 MinigameHandler.minigame_finished.connect(_on_minigame_finished)
31
32 StatusPanel.inventory_button_toggled.connect(_on_inventory_button_toggled)
33 StatusPanel.settings_button_toggled.connect(_on_settings_button_toggled)
34 StatusPanel.save_button_toggled.connect(_on_save_button_toggled)
35
36 InventoryMenu.visibility_changed.connect(_on_menu_visibility_changed)
37
38 SaveMenu.visibility_changed.connect(_on_menu_visibility_changed)
39 SaveMenu.closed.connect(StatusPanel.saving_closed)
40
41 SettingsMenu.visibility_changed.connect(_on_menu_visibility_changed)
42 SettingsMenu.closed.connect(StatusPanel.settings_closed)
43
44 TravelButtons.waited.connect(_on_wait_button_pressed)
45
46 ChoicePanel.options_shown.connect(_on_options_shown)
47 ChoicePanel.options_cleared.connect(_on_options_cleared)
48
49 ExploreState.trap_triggered.connect(_on_trap_triggered)
50 ExploreState.event_triggered.connect(_on_event_triggered)
51 ExploreState.event_trigger_forced.connect(_on_event_trigger_forced)
52 ExploreState.revisited.connect(_on_revisited)
53 ExploreState.wandered.connect(_on_wandered)
54 ExploreState.item_selected.connect(_on_item_selected)
55 ExploreState.masturbated.connect(_on_masturbated)
56
57 if not MemoryState.has_seen("00-intro/00-premise"):
58 InventoryState.add_trap("intro")
59 EventPlayerContainer.run("00-intro/00-premise")
60
61 if not SimpleState.state.sequence.current_sequence != "None":
62 EventPlayerContainer.restore_from_state()
63
64 await Blackout.fade_in()
65
66
67func _on_revisited(event: String) -> void:
68 EventPlayerContainer.run(event)
69
70
71func _on_wandered(where: String) -> void:
72 EventPlayerContainer.run("01-location/%s/wander" % where)
73
74
75func _on_item_selected(what: String) -> void:
76 StatusPanel.inventory_closed()
77 EventPlayerContainer.run("items/%s" % what)
78
79func _on_save_loaded(title) -> void:
80 if not title:
81 await Blackout.fade_out()
82
83 EventPlayerContainer.hard_stop()
84 ChoicePanel.clear_options()
85
86 if SimpleState.state.sequence.current_sequence != "NONE":
87 EventPlayerContainer.restore_from_state()
88 else:
89 EventPlayerContainer.hide()
90
91 await Blackout.fade_in()
92
93
94func _on_minigame_started(minigame: String, initial_state: Dictionary) -> void:
95 MinigameHandler.play_minigame(minigame, initial_state)
96
97
98func _on_minigame_finished(result) -> void:
99 EventPlayerContainer.minigame_finished(result)
100
101
102func _on_inventory_button_toggled(pressed: bool) -> void:
103
104 InventoryMenu.visible = pressed
105
106 if pressed:
107 SettingsMenu.visible = false
108 StatusPanel.settings_closed()
109
110 SaveMenu.visible = false
111 StatusPanel.saving_closed()
112
113
114func _on_settings_button_toggled(pressed: bool) -> void:
115 SettingsMenu.visible = pressed
116
117 if pressed:
118 InventoryMenu.visible = false
119 StatusPanel.inventory_closed()
120
121 SaveMenu.visible = false
122 StatusPanel.saving_closed()
123
124
125func _on_save_button_toggled(pressed: bool) -> void:
126 SaveMenu.visible = pressed
127
128 if pressed:
129 InventoryMenu.visible = false
130 StatusPanel.inventory_closed()
131
132 SettingsMenu.visible = false
133 StatusPanel.settings_closed()
134
135
136func _on_menu_visibility_changed() -> void:
137 EventPlayerContainer.set_input_disabled(any_menu_open())
138 ChoicePanel.visible = !any_menu_open() and ChoicePanel.active
139
140
141func _on_wait_button_pressed() -> void:
142 await Blackout.fade_out()
143 ExploreState.wait()
144 await Blackout.fade_in()
145
146
147func _on_options_shown() -> void:
148 ChoicePanel.visible = !any_menu_open() and ChoicePanel.active
149
150
151func _on_options_cleared() -> void:
152 ChoicePanel.hide()
153 await get_tree().process_frame
154
155
156func _on_trap_triggered(_trap_name: String, event: String) -> void:
157 EventPlayerContainer.run(event)
158
159
160func _on_event_triggered(event, entry: String = "intro") -> void:
161 EventPlayerContainer.run(event, entry)
162
163
164func _on_event_trigger_forced(event, entry: String) -> void:
165 if event == "NONE":
166 EventPlayerContainer._on_scene_ended()
167 ChoicePanel.clear_options()
168 else:
169 EventPlayerContainer._on_sequence_changed(event, entry)
170
171
172func _on_masturbated() -> void:
173 EventPlayerContainer.run("masturbations/init")
174
175
176func any_menu_open() -> bool:
177 return InventoryMenu.visible \
178 or SettingsMenu.visible \
179 or SaveMenu.visible
180