Added Glitch Room Source code to Gitty
This commit is contained in:
commit
1ac9eb5644
505 files changed
+28504
No files matched your search
@@ -0,0 +1,63 @@
|
||||
[gd_scene format=3 uid="uid://b0ojyvkcwkvpr"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bm2wpeevmxudu" path="res://main/main.gd" id="1_qv31u"]
|
||||
[ext_resource type="Resource" uid="uid://8qqlypjp3hd4" path="res://data/project_database.tres" id="2_5kcm4"]
|
||||
[ext_resource type="Script" uid="uid://cp6novpbgl1uk" path="res://core/runtime/game_host.gd" id="3_5kcm4"]
|
||||
|
||||
[node name="Main" type="Control" unique_id=12370566]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_qv31u")
|
||||
database = ExtResource("2_5kcm4")
|
||||
|
||||
[node name="GameHost" type="Node" parent="." unique_id=832996101]
|
||||
script = ExtResource("3_5kcm4")
|
||||
|
||||
[node name="DebugUI" type="Node" parent="." unique_id=28531604]
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="DebugUI" unique_id=1495913667]
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -219.0
|
||||
offset_top = -190.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="DebugUI/VBoxContainer" unique_id=619442521]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="StatusLabel" type="Label" parent="DebugUI/VBoxContainer" unique_id=818182868]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="StartButton" type="Button" parent="DebugUI/VBoxContainer" unique_id=1410664970]
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
text = "Start"
|
||||
|
||||
[node name="ForceWinButton" type="Button" parent="DebugUI/VBoxContainer" unique_id=2070309557]
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
text = "SIMULATE WIN"
|
||||
|
||||
[node name="ForceLoseButton" type="Button" parent="DebugUI/VBoxContainer" unique_id=1760144315]
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
text = "SIMULATE LOSE"
|
||||
|
||||
[node name="ResetButton" type="Button" parent="DebugUI/VBoxContainer" unique_id=657055303]
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
text = "Reset
|
||||
"
|
||||
|
||||
[connection signal="pressed" from="DebugUI/VBoxContainer/StartButton" to="." method="_on_start_button_pressed"]
|
||||
[connection signal="pressed" from="DebugUI/VBoxContainer/ForceWinButton" to="." method="_on_force_win_button_pressed"]
|
||||
[connection signal="pressed" from="DebugUI/VBoxContainer/ForceLoseButton" to="." method="_on_force_lose_button_pressed"]
|
||||
[connection signal="pressed" from="DebugUI/VBoxContainer/ResetButton" to="." method="_on_reset_button_pressed"]
|
||||
+233
@@ -0,0 +1,233 @@
|
||||
extends Control
|
||||
|
||||
|
||||
@export_group("Database")
|
||||
@export var database: ProjectDatabase
|
||||
|
||||
|
||||
@export_group("Editor Defaults")
|
||||
@export var default_cabinet_id: StringName = &"cabinet_01"
|
||||
@export var default_scenario_id: StringName = &"proof_of_concept"
|
||||
|
||||
|
||||
@onready var game_host: GameHost = $GameHost
|
||||
@onready var status_label: Label = (
|
||||
$DebugUI/VBoxContainer/StatusLabel
|
||||
)
|
||||
|
||||
|
||||
var active_scenario: ScenarioDefinition
|
||||
var active_assignment: ScenarioAssignment
|
||||
var launch_config: LaunchConfig
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if database == null:
|
||||
push_error(
|
||||
"Main has no ProjectDatabase assigned."
|
||||
)
|
||||
return
|
||||
|
||||
launch_config = LaunchConfig.from_command_line(
|
||||
default_cabinet_id,
|
||||
default_scenario_id
|
||||
)
|
||||
|
||||
launch_config.print_debug()
|
||||
|
||||
if not _resolve_scenario():
|
||||
return
|
||||
|
||||
if not _resolve_assignment():
|
||||
return
|
||||
|
||||
if not _validate_assignment():
|
||||
return
|
||||
|
||||
_start_assignment()
|
||||
|
||||
|
||||
func _resolve_scenario() -> bool:
|
||||
active_scenario = database.get_scenario(
|
||||
launch_config.scenario_id
|
||||
)
|
||||
|
||||
if active_scenario == null:
|
||||
push_error(
|
||||
"Scenario '%s' was not found in ProjectDatabase."
|
||||
% launch_config.scenario_id
|
||||
)
|
||||
|
||||
return false
|
||||
|
||||
print(
|
||||
"[LAUNCHER] Scenario resolved: %s v%d"
|
||||
% [
|
||||
active_scenario.display_name,
|
||||
active_scenario.version
|
||||
]
|
||||
)
|
||||
|
||||
return true
|
||||
|
||||
|
||||
func _resolve_assignment() -> bool:
|
||||
active_assignment = (
|
||||
active_scenario.get_assignment_for_cabinet(
|
||||
launch_config.cabinet_id
|
||||
)
|
||||
)
|
||||
|
||||
if active_assignment == null:
|
||||
push_error(
|
||||
"Scenario '%s' has no assignment for cabinet '%s'."
|
||||
% [
|
||||
active_scenario.scenario_id,
|
||||
launch_config.cabinet_id
|
||||
]
|
||||
)
|
||||
|
||||
return false
|
||||
|
||||
print(
|
||||
"[LAUNCHER] Assignment: %s -> %s"
|
||||
% [
|
||||
active_assignment.cabinet.display_name,
|
||||
active_assignment.game.display_name
|
||||
]
|
||||
)
|
||||
|
||||
return true
|
||||
|
||||
|
||||
func _validate_assignment() -> bool:
|
||||
if active_assignment.cabinet == null:
|
||||
push_error(
|
||||
"Scenario assignment has no CabinetProfile."
|
||||
)
|
||||
return false
|
||||
|
||||
if active_assignment.game == null:
|
||||
push_error(
|
||||
"Scenario assignment has no GameDefinition."
|
||||
)
|
||||
return false
|
||||
|
||||
if (
|
||||
active_assignment.cabinet.cabinet_id
|
||||
!= launch_config.cabinet_id
|
||||
):
|
||||
push_error(
|
||||
"Assignment cabinet ID does not match "
|
||||
+ "requested cabinet."
|
||||
)
|
||||
|
||||
return false
|
||||
|
||||
if not active_assignment.game.can_run_on(
|
||||
active_assignment.cabinet
|
||||
):
|
||||
push_error(
|
||||
"Game '%s' is incompatible with cabinet '%s'."
|
||||
% [
|
||||
active_assignment.game.game_id,
|
||||
active_assignment.cabinet.cabinet_id
|
||||
]
|
||||
)
|
||||
|
||||
return false
|
||||
|
||||
print("[LAUNCHER] Assignment validated.")
|
||||
|
||||
return true
|
||||
|
||||
|
||||
func _start_assignment() -> void:
|
||||
RoomRuntime.configure(
|
||||
active_assignment
|
||||
)
|
||||
|
||||
var game := game_host.load_game(
|
||||
active_assignment.game
|
||||
)
|
||||
|
||||
if game == null:
|
||||
return
|
||||
|
||||
game.game_started.connect(
|
||||
_update_status_started
|
||||
)
|
||||
|
||||
game.game_won.connect(
|
||||
_update_status_won
|
||||
)
|
||||
|
||||
game.game_lost.connect(
|
||||
_update_status_lost
|
||||
)
|
||||
|
||||
game.game_reset.connect(
|
||||
_update_status_reset
|
||||
)
|
||||
|
||||
status_label.text = (
|
||||
"%s\n%s\n%s"
|
||||
% [
|
||||
active_scenario.display_name,
|
||||
active_assignment.cabinet.display_name,
|
||||
active_assignment.game.display_name
|
||||
]
|
||||
)
|
||||
|
||||
print("")
|
||||
print("=========== READY ===========")
|
||||
print(
|
||||
"Scenario: ",
|
||||
active_scenario.display_name
|
||||
)
|
||||
print(
|
||||
"Cabinet: ",
|
||||
active_assignment.cabinet.display_name
|
||||
)
|
||||
print(
|
||||
"Game: ",
|
||||
active_assignment.game.display_name
|
||||
)
|
||||
print("=============================")
|
||||
print("")
|
||||
|
||||
|
||||
func _on_start_button_pressed() -> void:
|
||||
if game_host.current_game:
|
||||
game_host.current_game.start_game()
|
||||
|
||||
|
||||
func _on_force_win_button_pressed() -> void:
|
||||
if game_host.current_game:
|
||||
game_host.current_game.win_game()
|
||||
|
||||
|
||||
func _on_force_lose_button_pressed() -> void:
|
||||
if game_host.current_game:
|
||||
game_host.current_game.lose_game()
|
||||
|
||||
|
||||
func _on_reset_button_pressed() -> void:
|
||||
if game_host.current_game:
|
||||
game_host.current_game.reset_game()
|
||||
|
||||
|
||||
func _update_status_started() -> void:
|
||||
status_label.text = "GAME RUNNING"
|
||||
|
||||
|
||||
func _update_status_won() -> void:
|
||||
status_label.text = "GAME WON"
|
||||
|
||||
|
||||
func _update_status_lost() -> void:
|
||||
status_label.text = "GAME LOST"
|
||||
|
||||
|
||||
func _update_status_reset() -> void:
|
||||
status_label.text = "READY"
|
||||
@@ -0,0 +1 @@
|
||||
uid://bm2wpeevmxudu
|
||||
Reference in new issue
Block a user