From 7653be9555f8d9b1ad1e90198c15abece12c762d Mon Sep 17 00:00:00 2001 From: Tiger Jove Date: Thu, 22 Jan 2026 11:02:58 +0100 Subject: [PATCH] refactor: rooms now ensure ID, rooms now share initialization code --- .../transition/code/subway_sequence.gd | 2 +- .../stations/volunteer_station.tscn | 64 +++++++++---------- .../transition/subway_sequence.tscn | 1 + .../volunteer_room/volunteer_room.gd | 18 +++--- .../volunteer_room/volunteer_room.tscn | 1 + .../youth_room/youth_room.gd | 7 +- .../youth_room/youth_room.tscn | 1 + src/dev-util/{room_template.gd => room.gd} | 33 ++++++---- .../{room_template.gd.uid => room.gd.uid} | 0 src/dev-util/room_with_board.gd | 10 +++ src/dev-util/room_with_board.gd.uid | 1 + src/logic-scenes/board/card-board.gd | 24 +++---- .../luna/playables/story_playable.gd | 39 +++++------ src/logic-scenes/playable.gd | 13 ++++ src/project.godot | 2 +- src/singletons/global_state.gd | 2 +- src/singletons/main/main.gd | 2 +- 17 files changed, 124 insertions(+), 96 deletions(-) rename src/dev-util/{room_template.gd => room.gd} (68%) rename src/dev-util/{room_template.gd.uid => room.gd.uid} (100%) create mode 100644 src/dev-util/room_with_board.gd create mode 100644 src/dev-util/room_with_board.gd.uid diff --git a/src/base-environments/transition/code/subway_sequence.gd b/src/base-environments/transition/code/subway_sequence.gd index affc618..3a2dde2 100644 --- a/src/base-environments/transition/code/subway_sequence.gd +++ b/src/base-environments/transition/code/subway_sequence.gd @@ -1,4 +1,4 @@ -extends RoomTemplate +extends Room class_name SubwaySequence @export var all_stations: Dictionary[Station.id, Station] diff --git a/src/base-environments/transition/stations/volunteer_station.tscn b/src/base-environments/transition/stations/volunteer_station.tscn index 6941b08..91a1e53 100644 --- a/src/base-environments/transition/stations/volunteer_station.tscn +++ b/src/base-environments/transition/stations/volunteer_station.tscn @@ -1,19 +1,19 @@ -[gd_scene format=3 uid="uid://uhayiqixlv0e"] +[gd_scene load_steps=3 format=3 uid="uid://uhayiqixlv0e"] [ext_resource type="PackedScene" uid="uid://7b8qxqyk4di2" path="res://base-environments/transition/import/volunteer_station.glb" id="1_gxnf0"] [ext_resource type="PackedScene" uid="uid://tuv111h6jsnu" path="res://base-environments/transition/import/textures/meta_station_imported.tscn" id="2_28xtj"] -[node name="volunteer_station" unique_id=1086700491 instance=ExtResource("1_gxnf0")] +[node name="volunteer_station" instance=ExtResource("1_gxnf0")] -[node name="meta_station" parent="." index="46" unique_id=928456797 instance=ExtResource("2_28xtj")] +[node name="meta_station" parent="." index="46" instance=ExtResource("2_28xtj")] -[node name="Lighting" type="Node3D" parent="." index="47" unique_id=614453572] +[node name="Lighting" type="Node3D" parent="." index="47"] visible = false -[node name="Left" type="Node3D" parent="Lighting" index="0" unique_id=841316440] +[node name="Left" type="Node3D" parent="Lighting" index="0"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.1015987, 0, 0) -[node name="OmniLight3D" type="SpotLight3D" parent="Lighting/Left" index="0" unique_id=858880331] +[node name="OmniLight3D" type="SpotLight3D" parent="Lighting/Left" index="0"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -10.1989) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -24,7 +24,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D13" type="SpotLight3D" parent="Lighting/Left" index="1" unique_id=1973416313] +[node name="OmniLight3D13" type="SpotLight3D" parent="Lighting/Left" index="1"] transform = Transform3D(1, 0, 0, 0, -0.50000024, 0.8660253, 0, -0.8660253, -0.50000024, -0.42258057, 2.0402927, -5.2949142) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -35,7 +35,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D2" type="SpotLight3D" parent="Lighting/Left" index="2" unique_id=1775276584] +[node name="OmniLight3D2" type="SpotLight3D" parent="Lighting/Left" index="2"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -15.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -46,7 +46,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D3" type="SpotLight3D" parent="Lighting/Left" index="3" unique_id=56001064] +[node name="OmniLight3D3" type="SpotLight3D" parent="Lighting/Left" index="3"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -20.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -57,7 +57,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D4" type="SpotLight3D" parent="Lighting/Left" index="4" unique_id=1665416716] +[node name="OmniLight3D4" type="SpotLight3D" parent="Lighting/Left" index="4"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -25.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -68,7 +68,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D5" type="SpotLight3D" parent="Lighting/Left" index="5" unique_id=168448101] +[node name="OmniLight3D5" type="SpotLight3D" parent="Lighting/Left" index="5"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -30.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -79,7 +79,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D6" type="SpotLight3D" parent="Lighting/Left" index="6" unique_id=144351960] +[node name="OmniLight3D6" type="SpotLight3D" parent="Lighting/Left" index="6"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -35.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -90,7 +90,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D7" type="SpotLight3D" parent="Lighting/Left" index="7" unique_id=2109500620] +[node name="OmniLight3D7" type="SpotLight3D" parent="Lighting/Left" index="7"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -40.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -101,7 +101,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D8" type="SpotLight3D" parent="Lighting/Left" index="8" unique_id=1075807285] +[node name="OmniLight3D8" type="SpotLight3D" parent="Lighting/Left" index="8"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -45.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -112,7 +112,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D9" type="SpotLight3D" parent="Lighting/Left" index="9" unique_id=469725055] +[node name="OmniLight3D9" type="SpotLight3D" parent="Lighting/Left" index="9"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -50.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -123,7 +123,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D10" type="SpotLight3D" parent="Lighting/Left" index="10" unique_id=1960377915] +[node name="OmniLight3D10" type="SpotLight3D" parent="Lighting/Left" index="10"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -55.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -134,7 +134,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D11" type="SpotLight3D" parent="Lighting/Left" index="11" unique_id=1816850027] +[node name="OmniLight3D11" type="SpotLight3D" parent="Lighting/Left" index="11"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -60.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -145,7 +145,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D12" type="SpotLight3D" parent="Lighting/Left" index="12" unique_id=308692117] +[node name="OmniLight3D12" type="SpotLight3D" parent="Lighting/Left" index="12"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -65.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -156,10 +156,10 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="Right" type="Node3D" parent="Lighting" index="1" unique_id=630868085] +[node name="Right" type="Node3D" parent="Lighting" index="1"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.8136845, 0, 0) -[node name="OmniLight3D" type="SpotLight3D" parent="Lighting/Right" index="0" unique_id=2056485181] +[node name="OmniLight3D" type="SpotLight3D" parent="Lighting/Right" index="0"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -10.1989) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -170,7 +170,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D13" type="SpotLight3D" parent="Lighting/Right" index="1" unique_id=809548263] +[node name="OmniLight3D13" type="SpotLight3D" parent="Lighting/Right" index="1"] transform = Transform3D(1, 0, 0, 0, -0.50000024, 0.8660253, 0, -0.8660253, -0.50000024, -0.42258057, 2.0402927, -5.2949142) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -181,7 +181,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D2" type="SpotLight3D" parent="Lighting/Right" index="2" unique_id=816752087] +[node name="OmniLight3D2" type="SpotLight3D" parent="Lighting/Right" index="2"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -15.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -192,7 +192,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D3" type="SpotLight3D" parent="Lighting/Right" index="3" unique_id=927174265] +[node name="OmniLight3D3" type="SpotLight3D" parent="Lighting/Right" index="3"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -20.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -203,7 +203,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D4" type="SpotLight3D" parent="Lighting/Right" index="4" unique_id=1690728036] +[node name="OmniLight3D4" type="SpotLight3D" parent="Lighting/Right" index="4"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -25.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -214,7 +214,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D5" type="SpotLight3D" parent="Lighting/Right" index="5" unique_id=2096526257] +[node name="OmniLight3D5" type="SpotLight3D" parent="Lighting/Right" index="5"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -30.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -225,7 +225,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D6" type="SpotLight3D" parent="Lighting/Right" index="6" unique_id=1776863402] +[node name="OmniLight3D6" type="SpotLight3D" parent="Lighting/Right" index="6"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -35.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -236,7 +236,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D7" type="SpotLight3D" parent="Lighting/Right" index="7" unique_id=620392762] +[node name="OmniLight3D7" type="SpotLight3D" parent="Lighting/Right" index="7"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -40.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -247,7 +247,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D8" type="SpotLight3D" parent="Lighting/Right" index="8" unique_id=1681381128] +[node name="OmniLight3D8" type="SpotLight3D" parent="Lighting/Right" index="8"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -45.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -258,7 +258,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D9" type="SpotLight3D" parent="Lighting/Right" index="9" unique_id=430454083] +[node name="OmniLight3D9" type="SpotLight3D" parent="Lighting/Right" index="9"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -50.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -269,7 +269,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D10" type="SpotLight3D" parent="Lighting/Right" index="10" unique_id=774180702] +[node name="OmniLight3D10" type="SpotLight3D" parent="Lighting/Right" index="10"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -55.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -280,7 +280,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D11" type="SpotLight3D" parent="Lighting/Right" index="11" unique_id=955522321] +[node name="OmniLight3D11" type="SpotLight3D" parent="Lighting/Right" index="11"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -60.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 @@ -291,7 +291,7 @@ spot_range = 6.5 spot_angle = 80.0 spot_angle_attenuation = 0.517633 -[node name="OmniLight3D12" type="SpotLight3D" parent="Lighting/Right" index="12" unique_id=513566485] +[node name="OmniLight3D12" type="SpotLight3D" parent="Lighting/Right" index="12"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.42258057, 2.022126, -65.2744) light_color = Color(0.978917, 0.789534, 0.685226, 1) light_size = 0.6 diff --git a/src/base-environments/transition/subway_sequence.tscn b/src/base-environments/transition/subway_sequence.tscn index d10167d..809a47f 100644 --- a/src/base-environments/transition/subway_sequence.tscn +++ b/src/base-environments/transition/subway_sequence.tscn @@ -206,6 +206,7 @@ compositor_effects = Array[CompositorEffect]([SubResource("CompositorEffect_820w [node name="SubwaySequence" type="Node3D"] script = ExtResource("1_yfan7") +id = 2 [node name="Logic" type="Node3D" parent="."] unique_name_in_owner = true diff --git a/src/base-environments/volunteer_room/volunteer_room.gd b/src/base-environments/volunteer_room/volunteer_room.gd index 0ffc24c..6639883 100644 --- a/src/base-environments/volunteer_room/volunteer_room.gd +++ b/src/base-environments/volunteer_room/volunteer_room.gd @@ -1,13 +1,12 @@ -extends RoomTemplate +extends RoomWithBoard class_name VolunteerRoom @onready var card_picker: CardPicker = %Picker @onready var player: PlayerController = %PlayerController -func _ready(): - id = State.rooms.ADULTHOOD - super._ready() - +func _ready() -> void: + super._ready() # UwU, superclass _ready is not called by Godot automatically... + prints("volunteer_room.gd", "_ready()", self) func get_ready() -> void: await super.get_ready() @@ -15,9 +14,6 @@ func get_ready() -> void: # Interactions can this way load their correct prompts get_tree().call_group("interactables", "pull_save_state") - %TherapyVoluntaryInteractable.visible = not save_game.subway_burnout - %TherapyUniInteractable.visible = save_game.subway_burnout - pull_save_state(State.save_game) Scenes.scene_finished.connect(_on_scene_finished) @@ -26,12 +22,16 @@ func get_ready() -> void: card_board.closed.connect(save_room) card_board.board_completed.connect(func(): save_game.childhood_board_complete = true - %DoorInteractable.show() + #%DoorInteractable.show() ) # This MUST happen after the signal connection, or the door will remain locked card_board.initialise_from_save(save_game) + %TherapyVoluntaryInteractable.visible = not save_game.subway_burnout + %TherapyUniInteractable.visible = save_game.subway_burnout + + func start_room(): await super.start_room() diff --git a/src/base-environments/volunteer_room/volunteer_room.tscn b/src/base-environments/volunteer_room/volunteer_room.tscn index e847e24..f477a86 100644 --- a/src/base-environments/volunteer_room/volunteer_room.tscn +++ b/src/base-environments/volunteer_room/volunteer_room.tscn @@ -201,6 +201,7 @@ func _on_environment_settings_update(): [node name="SharedFlat" type="Node3D"] script = ExtResource("1_wdfvq") +id = 3 [node name="PlayerController" parent="." instance=ExtResource("2_upyac")] unique_name_in_owner = true diff --git a/src/base-environments/youth_room/youth_room.gd b/src/base-environments/youth_room/youth_room.gd index 0e529bc..b7b7154 100644 --- a/src/base-environments/youth_room/youth_room.gd +++ b/src/base-environments/youth_room/youth_room.gd @@ -1,5 +1,5 @@ class_name YouthRoom -extends RoomTemplate +extends RoomWithBoard ## Used by the room system when this room becomes active # var is_active: bool = false # Reminder, do not uncomment, this field is inherited from RoomTemplate! @@ -7,10 +7,9 @@ extends RoomTemplate @onready var card_picker: CardPicker = %Picker @onready var ui: Control = %UI -func _ready() -> void: - id = State.rooms.YOUTH +func _ready() -> void: super._ready() # UwU, superclass _ready is not called by Godot automatically... - + prints("youth_room.gd", "_ready()", self) func start_room(): await super.start_room() diff --git a/src/base-environments/youth_room/youth_room.tscn b/src/base-environments/youth_room/youth_room.tscn index 52fabf2..7dabbb0 100644 --- a/src/base-environments/youth_room/youth_room.tscn +++ b/src/base-environments/youth_room/youth_room.tscn @@ -418,6 +418,7 @@ func hide(): [node name="youth room" type="Node3D" groups=["serializable"]] process_mode = 1 script = ExtResource("1_aitp0") +id = 1 [node name="logic" type="Node3D" parent="."] diff --git a/src/dev-util/room_template.gd b/src/dev-util/room.gd similarity index 68% rename from src/dev-util/room_template.gd rename to src/dev-util/room.gd index 1004914..f872203 100644 --- a/src/dev-util/room_template.gd +++ b/src/dev-util/room.gd @@ -1,27 +1,31 @@ -class_name RoomTemplate extends Node3D +extends Node3D +## A Room is a location that can be played through, and it emits a proceed signal that holds +## the scene path to the next room (or null for credits roll) +class_name Room -var initialised: bool = false -var id: State.rooms = State.rooms.NULL +## Tells the main loop to proceed to the next scene +signal proceed(next_scene_path: String) + +@export var id: State.rooms = State.rooms.NULL @onready var scene_player : AnimationPlayer = %SceneAnimationPlayer -@onready var card_board : CardBoard # Optional Board, if present - set by the board in its own _ready() var save_game : SaveGame: get: return State.save_game -signal proceed(next_scene_path: String) - func _ready() -> void: + prints("room.gd", "_ready()", self) + assert(id != State.rooms.NULL, "Room " + str(self) + name + " has no proper ID set, it's still State.Rooms.NULL") + State.room = self if not State.save_game: - push_warning("Room initialised without a SaveGame. Creating proxy save.") - State.save_game = ResourceLoader.load("res://dev-util/debug_save.tres") - + var debug_save_path := "res://dev-util/debug_save.tres" + push_warning("Room initialised without a SaveGame. Loading DEBUG save.", debug_save_path) + State.save_game = ResourceLoader.load(debug_save_path) if not Main.normal_boot: - push_warning("------- DEBUG MODE --------") - play.call_deferred() + _debug_mode() func get_ready(): @@ -74,3 +78,10 @@ func unload(): func prepare_scene_start(_scene_id: Scenes.id, _is_repeating: bool) -> void: prints("PREPARE SCENE", _scene_id, _is_repeating) await get_tree().process_frame # Dummy wait for LSP warning otherwise + +## Override this (and call super._debug_mode()) if you want to initialize some data +## for running this Room standalone ("play current scene") +func _debug_mode() -> void: + push_warning("room.gd: DEBUG MODE - ", self) + await get_tree().create_timer(1).timeout + play() diff --git a/src/dev-util/room_template.gd.uid b/src/dev-util/room.gd.uid similarity index 100% rename from src/dev-util/room_template.gd.uid rename to src/dev-util/room.gd.uid diff --git a/src/dev-util/room_with_board.gd b/src/dev-util/room_with_board.gd new file mode 100644 index 0000000..e502b1f --- /dev/null +++ b/src/dev-util/room_with_board.gd @@ -0,0 +1,10 @@ +extends Room +## A room with a CardBoard in it, has some special properties and initialization rules! +class_name RoomWithBoard + +func _ready() -> void: + prints("room_with_board.gd", "_ready()", self) + super._ready() # UwU, superclass _ready is not called by Godot automatically... + + +var card_board : CardBoard # Optional Board, if present - set by the board in its own _ready() diff --git a/src/dev-util/room_with_board.gd.uid b/src/dev-util/room_with_board.gd.uid new file mode 100644 index 0000000..56b1914 --- /dev/null +++ b/src/dev-util/room_with_board.gd.uid @@ -0,0 +1 @@ +uid://demkhdo5aj71j diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index 38119da..435a380 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -26,6 +26,15 @@ enum SelectionState {FREE,STICKIES,CARDS} enum {NAVIGATE, ASSIGN, DRAG} +func _ready() -> void: + prints("card-board.gd:", "_ready()", self, "room:", State.room) + super._ready() + + var board_room := State.room as RoomWithBoard + assert(board_room, "A CardBoard is placed in a Room that's not a RoomWithBoard") + board_room.card_board = self + + func play(): check_board_completion() await closed @@ -67,20 +76,6 @@ func _navigate_prev(): selection = candidates[index-1] -func _ready() -> void: - print("CardBoard.gd: %s._ready()" % self.name) - State.room.card_board = self - - super._ready() - - # HACK: Lets us debug more easily - if get_parent() == get_tree().root: - _debug_mode() - return - - print("Board Ready!", self, "room", State.room) - State.room.card_board = self - ## frame rate independent FIR smoothing filter used for small or dynamic card adjustments func _smooth(current: Vector2, goal: Vector2, delta: float) -> Vector2: @@ -527,6 +522,7 @@ var _selection_candidates : Array[Draggable]: # === Util === func _debug_mode() -> void: + super._debug_mode() populate_board(["c_void", 'c_gifted', "p_wet", "p_joy"]) populate_board(["c_jui_jutsu", 'c_hit', "p_girly", "p_vent"]) populate_board(["c_comic_heroes", 'c_teasing', "p_agent_q", "p_good_intended"]) diff --git a/src/logic-scenes/luna/playables/story_playable.gd b/src/logic-scenes/luna/playables/story_playable.gd index d2846da..674694f 100644 --- a/src/logic-scenes/luna/playables/story_playable.gd +++ b/src/logic-scenes/luna/playables/story_playable.gd @@ -7,8 +7,23 @@ signal intro @export var scene_id : Scenes.id +func _ready() -> void: + prints("story-playable.gd:", "_ready()", self, "room:", State.room) + super._ready() + State.settings_changed.connect(func(): story_array = story_array) + skip_control = %SkipControl + if skip_control is SkipControl and not Engine.is_editor_hint(): + skip_control.skip.connect(skip_text) + + # Clunky rebuild... + story_array = story_array + progress = progress + + +func _debug_mode(): + Main.curtain.open() + super._debug_mode() -#TODO properly implement animation taking stage, as it should do, disabling processing when it does not have stage. var max_lines: float = 0 @export var story_array: PackedStringArray: @@ -66,27 +81,6 @@ var all_text_revealed: bool = false: var substring_sizes: Array[int] -func _ready() -> void: - print("StoryPlayable.gd: %s._ready()" % self.name) - super._ready() - State.settings_changed.connect(func(): story_array = story_array) - skip_control = %SkipControl - if skip_control is SkipControl and not Engine.is_editor_hint(): - skip_control.skip.connect(skip_text) - - # Clunky rebuild... - story_array = story_array - progress = progress - - if get_parent() is not CanvasLayer: - push_warning("-------------- ", "DEBUG MODE ", self, " --------------") - hide() - await Main.curtain.open() - await appear() - await play() - push_warning("-------------- ", "FINISHED ", self, " --------------") - - func _rebuild(): print("StoryPlayable.gd: %s._rebuild()" % self.name) if is_node_ready(): @@ -216,6 +210,7 @@ func skip_text(): elif name == "JuiJutsu": _emit_thunder() + func _on_text_finished(): print("StoryPlayable.gd: %s._on_text_finished()" % self.name) if not animation_complete: diff --git a/src/logic-scenes/playable.gd b/src/logic-scenes/playable.gd index 3fac964..24efc86 100644 --- a/src/logic-scenes/playable.gd +++ b/src/logic-scenes/playable.gd @@ -1,8 +1,13 @@ extends Control +## An interactive sequence (mostly in UI space) that can be play()ed. class_name Playable + func _ready() -> void: + prints("playable.gd", "_ready()", self) hide() + # HACK: Lets us debug playables more easily + if get_parent() == get_tree().root: _debug_mode() ## Awaitable that encapsulates the core interaction with this Playable @@ -28,3 +33,11 @@ func vanish(): tween.tween_property(self, "modulate", TRANSPARENT_BLACK, 0.3) await tween.finished hide() + + +## Override this (and call super._debug_mode()) if you want to initialize some data +## for running this playable standalone ("play current scene") +func _debug_mode(): + push_warning("playable.gd: DEBUG MODE - ", self) + await get_tree().create_timer(1).timeout + play() diff --git a/src/project.godot b/src/project.godot index 613cd06..c01c1ca 100644 --- a/src/project.godot +++ b/src/project.godot @@ -232,7 +232,7 @@ textures/vram_compression/import_etc2_astc=true lights_and_shadows/directional_shadow/size=2048 global_illumination/voxel_gi/quality=1 viewport/hdr_2d=true -anti_aliasing/quality/msaa_3d=1 +anti_aliasing/quality/msaa_3d=2 environment/screen_space_reflection/roughness_quality=3 anti_aliasing/quality/use_taa=true anti_aliasing/quality/use_debanding=true diff --git a/src/singletons/global_state.gd b/src/singletons/global_state.gd index 106f6b7..72bcd5e 100644 --- a/src/singletons/global_state.gd +++ b/src/singletons/global_state.gd @@ -5,7 +5,7 @@ class_name GlobalState signal settings_changed var _settings_initialized -var room: RoomTemplate +var room: Room var save_game: SaveGame signal environment_settings_changed diff --git a/src/singletons/main/main.gd b/src/singletons/main/main.gd index cfa2935..49e074e 100644 --- a/src/singletons/main/main.gd +++ b/src/singletons/main/main.gd @@ -94,7 +94,7 @@ func _load_room(scene_path: String) -> void: match state: ResourceLoader.THREAD_LOAD_LOADED: var next_scene := ResourceLoader.load_threaded_get(scene_path) as PackedScene - State.room = next_scene.instantiate() as RoomTemplate + State.room = next_scene.instantiate() as Room get_tree().root.add_child(State.room) await get_tree().process_frame %Loading.stop()