From f9d4725a0756706a73970a17584e4fe01e629dee Mon Sep 17 00:00:00 2001 From: kiwie <45514372+David20122@users.noreply.github.com> Date: Sun, 8 Mar 2026 05:01:54 +0100 Subject: [PATCH 01/26] runner: refactor and partial rewrite --- Rhythia.csproj | 2 +- Rhythia.csproj.old.2 | 19 + scenes/game.tscn | 761 ++++++++++++----------- scripts/Rhythia.cs | 10 +- scripts/SceneManager.cs | 1 - scripts/game/Attempt.cs | 122 +++- scripts/game/GameComponent.cs | 3 +- scripts/game/LegacyRenderer.cs | 32 +- scripts/game/Runner.cs | 301 +++++++++ scripts/game/Runner.cs.uid | 1 + scripts/game/managers/HudManager.cs | 70 +++ scripts/game/managers/HudManager.cs.uid | 1 + scripts/map/objects/HitObject.cs | 76 +++ scripts/map/objects/HitObject.cs.uid | 1 + scripts/map/objects/IHitObject.cs | 2 +- scripts/map/objects/Note.cs | 32 +- scripts/scenes/GameScene.cs | 308 +++++++++ scripts/scenes/GameScene.cs.uid | 1 + scripts/scenes/Results.cs | 64 +- scripts/spaces/BaseSpace.cs | 4 +- scripts/ui/FPSCounter.cs | 7 +- scripts/ui/menu/play/MapInfoContainer.cs | 2 +- scripts/ui/menu/play/MapList.cs | 4 +- scripts/ui/menu/play/ScorePanel.cs | 2 +- scripts/ui/results/Graph.cs | 13 +- 25 files changed, 1346 insertions(+), 493 deletions(-) create mode 100644 Rhythia.csproj.old.2 create mode 100644 scripts/game/Runner.cs create mode 100644 scripts/game/Runner.cs.uid create mode 100644 scripts/game/managers/HudManager.cs create mode 100644 scripts/game/managers/HudManager.cs.uid create mode 100644 scripts/map/objects/HitObject.cs create mode 100644 scripts/map/objects/HitObject.cs.uid create mode 100644 scripts/scenes/GameScene.cs create mode 100644 scripts/scenes/GameScene.cs.uid diff --git a/Rhythia.csproj b/Rhythia.csproj index fd915778..041d012e 100644 --- a/Rhythia.csproj +++ b/Rhythia.csproj @@ -1,4 +1,4 @@ - + net10.0 net10.0 diff --git a/Rhythia.csproj.old.2 b/Rhythia.csproj.old.2 new file mode 100644 index 00000000..fd915778 --- /dev/null +++ b/Rhythia.csproj.old.2 @@ -0,0 +1,19 @@ + + + net10.0 + net10.0 + true + preview + + + + + + + + + + + + + \ No newline at end of file diff --git a/scenes/game.tscn b/scenes/game.tscn index 794120fc..7cf3b507 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,10 +1,12 @@ [gd_scene format=3 uid="uid://vp1nmsiqt5yv"] -[ext_resource type="Script" uid="uid://8s0npsnw42ce" path="res://scripts/scenes/LegacyRunner.cs" id="1_1hgss"] +[ext_resource type="Script" uid="uid://dly10tvxguvhb" path="res://scripts/scenes/GameScene.cs" id="1_bhx41"] [ext_resource type="ArrayMesh" uid="uid://ceww5w8t33lqy" path="res://user/meshes/squircle.obj" id="2_e1j6l"] [ext_resource type="Texture2D" uid="uid://b3g4aw54n6bow" path="res://user/skins/default/game/grid.png" id="2_q78ea"] +[ext_resource type="Script" uid="uid://dp8nga2aot1n2" path="res://scripts/game/Runner.cs" id="2_qnb83"] [ext_resource type="Script" uid="uid://okqdw5gj567n" path="res://scripts/game/LegacyRenderer.cs" id="3_ew8wr"] [ext_resource type="Texture2D" uid="uid://3e1tjlr4m0wt" path="res://user/skins/default/game/cursor.png" id="3_negii"] +[ext_resource type="Script" uid="uid://n6n303pw3qbd" path="res://scripts/game/managers/HudManager.cs" id="3_sww3w"] [ext_resource type="Theme" uid="uid://dhuhu3mmaew1a" path="res://themes/theme.tres" id="4_rvp5o"] [ext_resource type="FontFile" uid="uid://4bnnn01f4dqr" path="res://fonts/Ubuntu-Medium.ttf" id="5_pxgh4"] [ext_resource type="Texture2D" uid="uid://cxv6ey5xb6b0f" path="res://user/skins/default/game/health_background.png" id="6_bbly8"] @@ -25,56 +27,6 @@ [ext_resource type="FontFile" uid="uid://dotb3skhwouha" path="res://fonts/Roboto-Bold.ttf" id="23_wf21h"] [ext_resource type="FontFile" uid="uid://rs2mb33nd3b1" path="res://fonts/Roboto-Italic.ttf" id="24_j6p10"] -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_sijr0"] -bg_color = Color(0.1072, 0.0896, 0.16, 0.25098) - -[sub_resource type="LabelSettings" id="LabelSettings_a70tm"] -font_color = Color(1, 1, 1, 0.25098) - -[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_d5aou"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_43mxh"] -bg_color = Color(0.0235294, 0.0196078, 0.0352941, 0.768627) - -[sub_resource type="LabelSettings" id="LabelSettings_pwlqp"] -font = ExtResource("23_wf21h") -font_size = 36 - -[sub_resource type="LabelSettings" id="LabelSettings_tjduq"] -font = ExtResource("24_j6p10") -font_size = 12 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kncke"] -bg_color = Color(0.0352941, 0.0313726, 0.0509804, 0.501961) - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_6kbgk"] -bg_color = Color(0.0352941, 0.0313726, 0.0509804, 0.501961) - -[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_jlnvv"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_y08lf"] -bg_color = Color(0.0745098, 0.0666667, 0.101961, 0.501961) - -[sub_resource type="Theme" id="Theme_e1j6l"] -Button/fonts/font = ExtResource("5_pxgh4") -Button/styles/focus = SubResource("StyleBoxFlat_kncke") -Button/styles/hover = SubResource("StyleBoxFlat_6kbgk") -Button/styles/normal = SubResource("StyleBoxEmpty_jlnvv") -Button/styles/pressed = SubResource("StyleBoxFlat_y08lf") - -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_73q55"] -transparency = 1 -cull_mode = 2 -shading_mode = 0 -disable_fog = true -vertex_color_use_as_albedo = true -vertex_color_is_srgb = true - -[sub_resource type="MultiMesh" id="MultiMesh_almyi"] -transform_format = 1 -use_colors = true -mesh = ExtResource("2_e1j6l") - [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_a6jk1"] resource_name = "Material" transparency = 1 @@ -86,6 +38,20 @@ texture_repeat = false material = SubResource("StandardMaterial3D_a6jk1") size = Vector2(4, 4) +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_lvhmj"] +transparency = 1 +shading_mode = 0 +disable_ambient_light = true +disable_fog = true +albedo_texture = ExtResource("3_negii") +texture_filter = 5 +texture_repeat = false +distance_fade_min_distance = 1076.07 + +[sub_resource type="QuadMesh" id="QuadMesh_xij4d"] +material = SubResource("StandardMaterial3D_lvhmj") +size = Vector2(0.263, 0.263) + [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ssr8x"] transparency = 1 cull_mode = 2 @@ -102,22 +68,21 @@ transform_format = 1 use_colors = true mesh = SubResource("QuadMesh_5p2n8") -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_lvhmj"] +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_73q55"] transparency = 1 +cull_mode = 2 shading_mode = 0 -disable_ambient_light = true disable_fog = true -albedo_texture = ExtResource("3_negii") -texture_filter = 5 -texture_repeat = false -distance_fade_min_distance = 1076.07 +vertex_color_use_as_albedo = true +vertex_color_is_srgb = true -[sub_resource type="QuadMesh" id="QuadMesh_xij4d"] -material = SubResource("StandardMaterial3D_lvhmj") -size = Vector2(0.263, 0.263) +[sub_resource type="MultiMesh" id="MultiMesh_almyi"] +transform_format = 1 +use_colors = true +mesh = ExtResource("2_e1j6l") [sub_resource type="ViewportTexture" id="ViewportTexture_pl11u"] -viewport_path = NodePath("Health/HealthViewport") +viewport_path = NodePath("HUD/Health/HealthViewport") [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4p8vu"] resource_local_to_scene = true @@ -133,7 +98,7 @@ material = SubResource("StandardMaterial3D_4p8vu") size = Vector2(10.88, 0.8) [sub_resource type="ViewportTexture" id="ViewportTexture_bhx41"] -viewport_path = NodePath("ProgressBar/ProgressBarViewport") +viewport_path = NodePath("HUD/ProgressBar/ProgressBarViewport") [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_p1h21"] resource_local_to_scene = true @@ -148,28 +113,8 @@ resource_local_to_scene = true material = SubResource("StandardMaterial3D_p1h21") size = Vector2(10.88, 0.8) -[sub_resource type="ViewportTexture" id="ViewportTexture_qnb83"] -viewport_path = NodePath("Video/VideoViewport") - -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rj3ky"] -resource_local_to_scene = true -transparency = 1 -no_depth_test = true -shading_mode = 0 -disable_ambient_light = true -disable_fog = true -albedo_texture = SubResource("ViewportTexture_qnb83") -texture_filter = 1 -texture_repeat = false - -[sub_resource type="QuadMesh" id="QuadMesh_3p7x2"] -size = Vector2(258.3, 210) - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_4qlgx"] -shader = ExtResource("8_ocxsu") - [sub_resource type="ViewportTexture" id="ViewportTexture_sww3w"] -viewport_path = NodePath("PanelLeft/PanelLeftViewport") +viewport_path = NodePath("HUD/PanelLeft/PanelLeftViewport") [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nody0"] resource_local_to_scene = true @@ -199,7 +144,7 @@ font = ExtResource("12_axsek") font_size = 50 [sub_resource type="ViewportTexture" id="ViewportTexture_suyxu"] -viewport_path = NodePath("PanelRight/PanelRightViewport") +viewport_path = NodePath("HUD/PanelRight/PanelRightViewport") [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ro5ir"] resource_local_to_scene = true @@ -231,267 +176,118 @@ font_size = 50 [sub_resource type="ShaderMaterial" id="ShaderMaterial_gc8yu"] shader = ExtResource("14_3xchs") -[node name="SceneGame" type="Node" unique_id=909809067] -script = ExtResource("1_1hgss") -UseGameSpace = true -AddSpaceAsChild = true +[sub_resource type="ViewportTexture" id="ViewportTexture_qnb83"] +viewport_path = NodePath("Video/VideoViewport") -[node name="SubViewportContainer" type="SubViewportContainer" parent="." unique_id=1797381631] -visible = false -z_index = -1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -focus_mode = 0 -mouse_filter = 2 -stretch = true +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rj3ky"] +resource_local_to_scene = true +transparency = 1 +no_depth_test = true +shading_mode = 0 +disable_ambient_light = true +disable_fog = true +albedo_texture = SubResource("ViewportTexture_qnb83") +texture_filter = 1 +texture_repeat = false -[node name="SubViewport" type="SubViewport" parent="SubViewportContainer" unique_id=671564774] -transparent_bg = true -handle_input_locally = false -screen_space_aa = 1 -size = Vector2i(1280, 720) -render_target_update_mode = 0 +[sub_resource type="QuadMesh" id="QuadMesh_3p7x2"] +size = Vector2(258.3, 210) -[node name="ReplayViewer" type="Panel" parent="." unique_id=1117476839] -visible = false -anchors_preset = 12 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 32.0 -offset_top = -84.0 -offset_right = -32.0 -offset_bottom = -32.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_sijr0") +[sub_resource type="ShaderMaterial" id="ShaderMaterial_4qlgx"] +shader = ExtResource("8_ocxsu") -[node name="Label" type="Label" parent="ReplayViewer" unique_id=919285545] -layout_mode = 1 -anchors_preset = -1 -offset_right = 40.0 -grow_vertical = 0 -text = "Press F1 to toggle" -label_settings = SubResource("LabelSettings_a70tm") +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_sijr0"] +bg_color = Color(0.1072, 0.0896, 0.16, 0.25098) -[node name="Time" type="Label" parent="ReplayViewer" unique_id=1277133470] -layout_mode = 1 -anchors_preset = -1 -anchor_bottom = 1.0 -offset_left = 64.0 -offset_top = 12.0 -offset_right = 164.0 -offset_bottom = -12.0 -text = "0:00 / 0:00" -horizontal_alignment = 1 -vertical_alignment = 1 +[sub_resource type="LabelSettings" id="LabelSettings_a70tm"] +font_color = Color(1, 1, 1, 0.25098) -[node name="Pause" type="TextureButton" parent="ReplayViewer" unique_id=1677045606] -texture_repeat = 1 -layout_mode = 1 -anchors_preset = -1 -anchor_top = 0.5 -anchor_bottom = 0.5 -offset_left = 12.0 -offset_right = 52.0 -grow_vertical = 2 -texture_normal = ExtResource("23_7silw") -stretch_mode = 3 +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_d5aou"] -[node name="Seek" type="HSlider" parent="ReplayViewer" unique_id=1706750343] -layout_mode = 1 -anchors_preset = -1 -anchor_top = 0.5 -anchor_right = 1.0 -anchor_bottom = 0.5 -offset_left = 192.0 -offset_right = -32.0 -grow_vertical = 2 -theme = ExtResource("4_rvp5o") -max_value = 1.0 -step = 0.0 +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_43mxh"] +bg_color = Color(0.0235294, 0.0196078, 0.0352941, 0.768627) -[node name="NotificationHolder" type="VBoxContainer" parent="." unique_id=1425635507] -anchors_preset = 3 -anchor_left = 1.0 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = -210.0 -offset_top = -110.0 -offset_right = -10.0 -offset_bottom = -10.0 -grow_horizontal = 0 -grow_vertical = 0 -mouse_filter = 2 -alignment = 2 +[sub_resource type="LabelSettings" id="LabelSettings_pwlqp"] +font = ExtResource("23_wf21h") +font_size = 36 -[node name="FPSCounter" parent="." unique_id=1955898342 instance=ExtResource("22_pl11u")] -anchors_preset = 2 -offset_top = -27.0 -offset_right = 72.0 +[sub_resource type="LabelSettings" id="LabelSettings_tjduq"] +font = ExtResource("24_j6p10") +font_size = 12 -[node name="Menu" type="Panel" parent="." unique_id=856970091] -visible = false -modulate = Color(1, 1, 1, 0) -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 -theme_override_styles/panel = SubResource("StyleBoxEmpty_d5aou") +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kncke"] +bg_color = Color(0.0352941, 0.0313726, 0.0509804, 0.501961) -[node name="Background" type="ColorRect" parent="Menu" unique_id=2094618318] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 -color = Color(0, 0, 0, 0.25098) +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_6kbgk"] +bg_color = Color(0.0352941, 0.0313726, 0.0509804, 0.501961) -[node name="Button" type="Button" parent="Menu" unique_id=1826268412] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -button_mask = 3 -flat = true +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_jlnvv"] -[node name="Holder" type="Panel" parent="Menu" unique_id=1204474678] -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -220.0 -offset_top = -280.0 -offset_right = 220.0 -offset_bottom = 280.0 -mouse_filter = 1 -theme_override_styles/panel = SubResource("StyleBoxFlat_43mxh") +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_y08lf"] +bg_color = Color(0.0745098, 0.0666667, 0.101961, 0.501961) -[node name="Header" type="Label" parent="Menu/Holder" unique_id=544084605] -layout_mode = 1 -anchors_preset = -1 -anchor_right = 1.0 -anchor_bottom = 0.2 -offset_top = 16.0 -text = "PAUSED" -label_settings = SubResource("LabelSettings_pwlqp") -horizontal_alignment = 1 +[sub_resource type="Theme" id="Theme_e1j6l"] +Button/fonts/font = ExtResource("5_pxgh4") +Button/styles/focus = SubResource("StyleBoxFlat_kncke") +Button/styles/hover = SubResource("StyleBoxFlat_6kbgk") +Button/styles/normal = SubResource("StyleBoxEmpty_jlnvv") +Button/styles/pressed = SubResource("StyleBoxFlat_y08lf") -[node name="Disclaimer" type="Label" parent="Menu/Holder" unique_id=1874627546] -layout_mode = 1 -anchors_preset = -1 -anchor_top = 0.8 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_bottom = -16.0 -text = "NOTE: Pausing disqualifies your pass" -label_settings = SubResource("LabelSettings_tjduq") -horizontal_alignment = 1 -vertical_alignment = 2 +[node name="SceneGame" type="Node" unique_id=909809067 node_paths=PackedStringArray("Runner", "HudManager", "Menu")] +script = ExtResource("1_bhx41") +Runner = NodePath("Runner") +HudManager = NodePath("Runner/HUDManager") +Menu = NodePath("Menu") +UseGameSpace = true +AddSpaceAsChild = true -[node name="Resume" type="Button" parent="Menu/Holder" unique_id=616429602] -layout_mode = 1 -anchors_preset = -1 -anchor_top = 0.2 -anchor_right = 1.0 -anchor_bottom = 0.35 -offset_left = 32.0 -offset_right = -32.0 -mouse_default_cursor_shape = 2 -theme = SubResource("Theme_e1j6l") -theme_override_font_sizes/font_size = 28 -text = "RESUME" +[node name="Runner" type="Node3D" parent="." unique_id=580620214 node_paths=PackedStringArray("Camera", "Grid", "Cursor", "Notes")] +script = ExtResource("2_qnb83") +Camera = NodePath("Camera3D") +Grid = NodePath("Grid") +Cursor = NodePath("Grid/Cursor") +Notes = NodePath("Notes") -[node name="Restart" type="Button" parent="Menu/Holder" unique_id=865082248] -layout_mode = 1 -anchors_preset = -1 -anchor_top = 0.35 -anchor_right = 1.0 -anchor_bottom = 0.5 -offset_left = 32.0 -offset_right = -32.0 -mouse_default_cursor_shape = 2 -theme = SubResource("Theme_e1j6l") -theme_override_font_sizes/font_size = 28 -text = "RESTART" +[node name="HUDManager" type="Node" parent="Runner" unique_id=1829246552 node_paths=PackedStringArray("Runner", "HUDContainer")] +script = ExtResource("3_sww3w") +Runner = NodePath("..") +HUDContainer = NodePath("../../HUD") -[node name="Settings" type="Button" parent="Menu/Holder" unique_id=730914507] -layout_mode = 1 -anchors_preset = -1 -anchor_top = 0.5 -anchor_right = 1.0 -anchor_bottom = 0.65 -offset_left = 32.0 -offset_right = -32.0 -mouse_default_cursor_shape = 2 -theme = SubResource("Theme_e1j6l") -theme_override_font_sizes/font_size = 28 -text = "SETTINGS" +[node name="Grid" type="MeshInstance3D" parent="Runner" unique_id=730517176] +mesh = SubResource("QuadMesh_aih2q") +skeleton = NodePath("../..") -[node name="Quit" type="Button" parent="Menu/Holder" unique_id=2118605072] -layout_mode = 1 -anchors_preset = -1 -anchor_top = 0.65 -anchor_right = 1.0 -anchor_bottom = 0.8 -offset_left = 32.0 -offset_right = -32.0 -mouse_default_cursor_shape = 2 -theme = SubResource("Theme_e1j6l") -theme_override_font_sizes/font_size = 28 -text = "GIVE UP" +[node name="Cursor" type="MeshInstance3D" parent="Runner/Grid" unique_id=292067677] +mesh = SubResource("QuadMesh_xij4d") +skeleton = NodePath("../../..") -[node name="Transition" type="ColorRect" parent="." unique_id=784178581] -self_modulate = Color(1, 1, 1, 0) -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 -color = Color(0, 0, 0, 1) +[node name="CursorTrail" type="MultiMeshInstance3D" parent="Runner/Grid" unique_id=913051903] +material_override = SubResource("StandardMaterial3D_ssr8x") +multimesh = SubResource("MultiMesh_e28va") -[node name="Camera3D" type="Camera3D" parent="." unique_id=112686709] +[node name="Camera3D" type="Camera3D" parent="Runner" unique_id=112686709] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3.75) current = true fov = 70.0 size = 5.0 -[node name="Notes" type="MultiMeshInstance3D" parent="." unique_id=77746100] +[node name="Notes" type="MultiMeshInstance3D" parent="Runner" unique_id=77746100 node_paths=PackedStringArray("Runner")] material_override = SubResource("StandardMaterial3D_73q55") cast_shadow = 0 multimesh = SubResource("MultiMesh_almyi") script = ExtResource("3_ew8wr") +Runner = NodePath("..") -[node name="Grid" type="MeshInstance3D" parent="." unique_id=730517176] -mesh = SubResource("QuadMesh_aih2q") - -[node name="CursorTrail" type="MultiMeshInstance3D" parent="." unique_id=913051903] -material_override = SubResource("StandardMaterial3D_ssr8x") -multimesh = SubResource("MultiMesh_e28va") - -[node name="Cursor" type="MeshInstance3D" parent="." unique_id=292067677] -mesh = SubResource("QuadMesh_xij4d") +[node name="HUD" type="Node3D" parent="." unique_id=1234434255] -[node name="Health" type="MeshInstance3D" parent="." unique_id=449857227] +[node name="Health" type="MeshInstance3D" parent="HUD" unique_id=449857227] +unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 0.965926, 0.258819, 0, -0.258819, 0.965926, 0, -6.3, -10) cast_shadow = 0 mesh = SubResource("QuadMesh_b1hbo") +skeleton = NodePath("../..") -[node name="HealthViewport" type="SubViewport" parent="Health" unique_id=1637011839] +[node name="HealthViewport" type="SubViewport" parent="HUD/Health" unique_id=1637011839] disable_3d = true transparent_bg = true canvas_item_default_texture_filter = 2 @@ -500,7 +296,7 @@ size_2d_override = Vector2i(1088, 80) size_2d_override_stretch = true render_target_update_mode = 4 -[node name="Background" type="TextureRect" parent="Health/HealthViewport" unique_id=2016213185] +[node name="Background" type="TextureRect" parent="HUD/Health/HealthViewport" unique_id=2016213185] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -508,7 +304,7 @@ grow_horizontal = 2 grow_vertical = 2 texture = ExtResource("6_bbly8") -[node name="Main" type="TextureRect" parent="Health/HealthViewport" unique_id=366630384] +[node name="Main" type="TextureRect" parent="HUD/Health/HealthViewport" unique_id=366630384] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -518,12 +314,14 @@ texture = ExtResource("7_wjg6i") expand_mode = 1 stretch_mode = 1 -[node name="ProgressBar" type="MeshInstance3D" parent="." unique_id=528447019] +[node name="ProgressBar" type="MeshInstance3D" parent="HUD" unique_id=528447019] +unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 0.965926, -0.258819, 0, 0.258819, 0.965926, 0, 6.3, -10) cast_shadow = 0 mesh = SubResource("QuadMesh_7mook") +skeleton = NodePath("../..") -[node name="ProgressBarViewport" type="SubViewport" parent="ProgressBar" unique_id=658400463] +[node name="ProgressBarViewport" type="SubViewport" parent="HUD/ProgressBar" unique_id=658400463] disable_3d = true transparent_bg = true canvas_item_default_texture_filter = 2 @@ -532,7 +330,7 @@ size_2d_override = Vector2i(1088, 80) size_2d_override_stretch = true render_target_update_mode = 4 -[node name="Background" type="TextureRect" parent="ProgressBar/ProgressBarViewport" unique_id=1129572664] +[node name="Background" type="TextureRect" parent="HUD/ProgressBar/ProgressBarViewport" unique_id=1129572664] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -540,51 +338,30 @@ grow_horizontal = 2 grow_vertical = 2 texture = ExtResource("8_eu3ux") -[node name="Main" type="TextureRect" parent="ProgressBar/ProgressBarViewport" unique_id=2016165310] -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -texture = ExtResource("9_nde5v") -expand_mode = 1 -stretch_mode = 1 - -[node name="Video" type="MeshInstance3D" parent="." unique_id=1036410191] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.479675, -0.459572, -99.9929) -visible = false -material_override = SubResource("StandardMaterial3D_rj3ky") -transparency = 1.0 -cast_shadow = 0 -mesh = SubResource("QuadMesh_3p7x2") - -[node name="VideoViewport" type="SubViewport" parent="Video" unique_id=866766269] -transparent_bg = true -canvas_item_default_texture_filter = 2 -size = Vector2i(1920, 1080) - -[node name="VideoStreamPlayer" type="VideoStreamPlayer" parent="Video/VideoViewport" unique_id=61327167] -material = SubResource("ShaderMaterial_4qlgx") +[node name="Main" type="TextureRect" parent="HUD/ProgressBar/ProgressBarViewport" unique_id=2016165310] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -volume_db = -80.0 -expand = true +texture = ExtResource("9_nde5v") +expand_mode = 1 +stretch_mode = 1 -[node name="PanelLeft" type="MeshInstance3D" parent="." unique_id=2045187203] +[node name="PanelLeft" type="MeshInstance3D" parent="HUD" unique_id=2045187203] +unique_name_in_owner = true transform = Transform3D(0.984808, 0, 0.173648, 0, 1, 0, -0.173648, 0, 0.984808, -7.5, 0, -9) material_override = SubResource("StandardMaterial3D_nody0") mesh = SubResource("QuadMesh_ssyve") +skeleton = NodePath("../..") -[node name="PanelLeftViewport" type="SubViewport" parent="PanelLeft" unique_id=944518522] +[node name="PanelLeftViewport" type="SubViewport" parent="HUD/PanelLeft" unique_id=944518522] disable_3d = true transparent_bg = true canvas_item_default_texture_filter = 2 size = Vector2i(250, 625) -[node name="Background" type="TextureRect" parent="PanelLeft/PanelLeftViewport" unique_id=1374853699] +[node name="Background" type="TextureRect" parent="HUD/PanelLeft/PanelLeftViewport" unique_id=1374853699] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -592,7 +369,7 @@ grow_horizontal = 2 grow_vertical = 2 texture = ExtResource("11_sdncv") -[node name="MultiplierProgress" type="Panel" parent="PanelLeft/PanelLeftViewport" unique_id=1067613329] +[node name="MultiplierProgress" type="Panel" parent="HUD/PanelLeft/PanelLeftViewport" unique_id=1067613329] clip_children = 2 material = SubResource("ShaderMaterial_x2xye") anchors_preset = -1 @@ -606,7 +383,7 @@ offset_right = 128.0 offset_bottom = 128.0 theme_override_styles/panel = SubResource("StyleBoxFlat_56f8v") -[node name="Score" type="Label" parent="PanelLeft/PanelLeftViewport" unique_id=1330190508] +[node name="Score" type="Label" parent="HUD/PanelLeft/PanelLeftViewport" unique_id=1330190508] anchors_preset = -1 anchor_left = 0.5 anchor_top = 0.35 @@ -619,7 +396,7 @@ text = "0" label_settings = SubResource("LabelSettings_usmyc") horizontal_alignment = 1 -[node name="Multiplier" type="Label" parent="PanelLeft/PanelLeftViewport" unique_id=1660490363] +[node name="Multiplier" type="Label" parent="HUD/PanelLeft/PanelLeftViewport" unique_id=1660490363] anchors_preset = -1 anchor_left = 0.5 anchor_top = 0.65 @@ -632,19 +409,21 @@ text = "1x" label_settings = SubResource("LabelSettings_usmyc") horizontal_alignment = 1 -[node name="PanelRight" type="MeshInstance3D" parent="." unique_id=1993445313] +[node name="PanelRight" type="MeshInstance3D" parent="HUD" unique_id=1993445313] +unique_name_in_owner = true transform = Transform3D(0.984808, 0, -0.173648, 0, 1, 0, 0.173648, 0, 0.984808, 7.5, 0, -9) material_override = SubResource("StandardMaterial3D_ro5ir") mesh = SubResource("QuadMesh_ssyve") +skeleton = NodePath("../..") -[node name="PanelRightViewport" type="SubViewport" parent="PanelRight" unique_id=623021244] +[node name="PanelRightViewport" type="SubViewport" parent="HUD/PanelRight" unique_id=623021244] process_mode = 3 disable_3d = true transparent_bg = true canvas_item_default_texture_filter = 2 size = Vector2i(250, 625) -[node name="Background" type="TextureRect" parent="PanelRight/PanelRightViewport" unique_id=1856482217] +[node name="Background" type="TextureRect" parent="HUD/PanelRight/PanelRightViewport" unique_id=1856482217] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -652,7 +431,7 @@ grow_horizontal = 2 grow_vertical = 2 texture = ExtResource("12_whe6p") -[node name="Accuracy" type="Label" parent="PanelRight/PanelRightViewport" unique_id=1669266042] +[node name="Accuracy" type="Label" parent="HUD/PanelRight/PanelRightViewport" unique_id=1669266042] anchors_preset = -1 anchor_left = 0.5 anchor_top = 0.35 @@ -665,7 +444,7 @@ text = "100.00%" label_settings = SubResource("LabelSettings_usmyc") horizontal_alignment = 1 -[node name="Hits" type="Label" parent="PanelRight/PanelRightViewport" unique_id=2096630009] +[node name="Hits" type="Label" parent="HUD/PanelRight/PanelRightViewport" unique_id=2096630009] anchors_preset = -1 anchor_left = 0.5 anchor_top = 0.625 @@ -680,7 +459,7 @@ text = "0" label_settings = SubResource("LabelSettings_5bid2") horizontal_alignment = 2 -[node name="Misses" type="Label" parent="PanelRight/PanelRightViewport" unique_id=1379241442] +[node name="Misses" type="Label" parent="HUD/PanelRight/PanelRightViewport" unique_id=1379241442] anchors_preset = -1 anchor_left = 0.5 anchor_top = 0.625 @@ -693,7 +472,7 @@ theme = ExtResource("4_rvp5o") text = "0" label_settings = SubResource("LabelSettings_v63ri") -[node name="SimpleMisses" type="Label" parent="PanelRight/PanelRightViewport" unique_id=1871751782] +[node name="SimpleMisses" type="Label" parent="HUD/PanelRight/PanelRightViewport" unique_id=1871751782] visible = false anchors_preset = 8 anchor_left = 0.5 @@ -707,7 +486,7 @@ theme = ExtResource("4_rvp5o") text = "0" label_settings = SubResource("LabelSettings_g4ffu") -[node name="Sum" type="Label" parent="PanelRight/PanelRightViewport" unique_id=150248329] +[node name="Sum" type="Label" parent="HUD/PanelRight/PanelRightViewport" unique_id=150248329] anchors_preset = -1 anchor_left = 0.5 anchor_top = 0.7 @@ -721,7 +500,7 @@ text = "0" label_settings = SubResource("LabelSettings_s1j5a") horizontal_alignment = 1 -[node name="HitsIcon" type="TextureRect" parent="PanelRight/PanelRightViewport" unique_id=482771805] +[node name="HitsIcon" type="TextureRect" parent="HUD/PanelRight/PanelRightViewport" unique_id=482771805] anchors_preset = -1 anchor_left = 0.5 anchor_top = 0.625 @@ -736,7 +515,7 @@ theme = ExtResource("4_rvp5o") texture = ExtResource("13_6rhgc") expand_mode = 2 -[node name="MissesIcon" type="TextureRect" parent="PanelRight/PanelRightViewport" unique_id=901292564] +[node name="MissesIcon" type="TextureRect" parent="HUD/PanelRight/PanelRightViewport" unique_id=901292564] anchors_preset = -1 anchor_left = 0.5 anchor_top = 0.625 @@ -750,7 +529,7 @@ theme = ExtResource("4_rvp5o") texture = ExtResource("14_bqf11") expand_mode = 2 -[node name="Line" type="ColorRect" parent="PanelRight/PanelRightViewport" unique_id=629344643] +[node name="Line" type="ColorRect" parent="HUD/PanelRight/PanelRightViewport" unique_id=629344643] material = SubResource("ShaderMaterial_gc8yu") anchors_preset = -1 anchor_top = 0.65 @@ -762,7 +541,8 @@ offset_bottom = 2.0 grow_horizontal = 2 grow_vertical = 2 -[node name="Progress" type="Label3D" parent="." unique_id=496335082] +[node name="Progress" type="Label3D" parent="HUD" unique_id=496335082] +unique_name_in_owner = true transform = Transform3D(3.5, 0, 0, 0, 3.38074, -0.905867, 0, 0.905867, 3.38074, 0, 7, -10) pixel_size = 0.0025 modulate = Color(1, 1, 1, 0.74509805) @@ -771,7 +551,8 @@ text = "0:00 / 0:00" font = ExtResource("12_axsek") font_size = 64 -[node name="Title" type="Label3D" parent="." unique_id=841289409] +[node name="Title" type="Label3D" parent="HUD" unique_id=841289409] +unique_name_in_owner = true transform = Transform3D(2, 0, 0, 0, 1.93185, -0.517638, 0, 0.517638, 1.93185, 0, 8.25, -10) outline_modulate = Color(0, 0, 0, 0) text = "N/A - N/A" @@ -780,7 +561,8 @@ font_size = 64 autowrap_mode = 3 width = 2500.0 -[node name="Combo" type="Label3D" parent="." unique_id=1330017059] +[node name="Combo" type="Label3D" parent="HUD" unique_id=1330017059] +unique_name_in_owner = true transform = Transform3D(7, 0, 0, 0, 6.89365, -1.21554, 0, 1.21554, 6.89365, 0, 3.5, -10) pixel_size = 0.0025 modulate = Color(1, 1, 1, 0) @@ -790,7 +572,8 @@ font = ExtResource("5_pxgh4") font_size = 64 outline_size = 4 -[node name="Speed" type="Label3D" parent="." unique_id=1294863906] +[node name="Speed" type="Label3D" parent="HUD" unique_id=1294863906] +unique_name_in_owner = true transform = Transform3D(7, 0, 0, 0, 6.76148, 1.81173, 0, -1.81173, 6.76148, 0, -7.5, -10) pixel_size = 0.0025 modulate = Color(1, 1, 1, 0.39215687) @@ -798,10 +581,262 @@ outline_modulate = Color(0, 0, 0, 0) text = "1.00x" font = ExtResource("5_pxgh4") -[node name="Skip" type="Label3D" parent="." unique_id=1231864437] +[node name="Skip" type="Label3D" parent="HUD" unique_id=1231864437] +unique_name_in_owner = true transform = Transform3D(7, 0, 0, 0, 6.76148, 1.81173, 0, -1.81173, 6.76148, 0, -5, -10) pixel_size = 0.0025 modulate = Color(1, 1, 1, 0) outline_modulate = Color(0, 0, 0, 0) text = "Press Space to skip" font = ExtResource("12_axsek") + +[node name="Video" type="MeshInstance3D" parent="." unique_id=1036410191] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.479675, -0.459572, -99.9929) +visible = false +material_override = SubResource("StandardMaterial3D_rj3ky") +transparency = 1.0 +cast_shadow = 0 +mesh = SubResource("QuadMesh_3p7x2") + +[node name="VideoViewport" type="SubViewport" parent="Video" unique_id=866766269] +transparent_bg = true +canvas_item_default_texture_filter = 2 +size = Vector2i(1920, 1080) + +[node name="VideoStreamPlayer" type="VideoStreamPlayer" parent="Video/VideoViewport" unique_id=61327167] +material = SubResource("ShaderMaterial_4qlgx") +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +volume_db = -80.0 +expand = true + +[node name="SubViewportContainer" type="SubViewportContainer" parent="." unique_id=1797381631] +visible = false +z_index = -1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +focus_mode = 0 +mouse_filter = 2 +stretch = true + +[node name="SubViewport" type="SubViewport" parent="SubViewportContainer" unique_id=671564774] +transparent_bg = true +handle_input_locally = false +screen_space_aa = 1 +size = Vector2i(1280, 720) +render_target_update_mode = 0 + +[node name="ReplayViewer" type="Panel" parent="." unique_id=1117476839] +visible = false +anchors_preset = 12 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 32.0 +offset_top = -84.0 +offset_right = -32.0 +offset_bottom = -32.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_sijr0") + +[node name="Label" type="Label" parent="ReplayViewer" unique_id=919285545] +layout_mode = 1 +anchors_preset = -1 +offset_right = 40.0 +grow_vertical = 0 +text = "Press F1 to toggle" +label_settings = SubResource("LabelSettings_a70tm") + +[node name="Time" type="Label" parent="ReplayViewer" unique_id=1277133470] +layout_mode = 1 +anchors_preset = -1 +anchor_bottom = 1.0 +offset_left = 64.0 +offset_top = 12.0 +offset_right = 164.0 +offset_bottom = -12.0 +text = "0:00 / 0:00" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Pause" type="TextureButton" parent="ReplayViewer" unique_id=1677045606] +texture_repeat = 1 +layout_mode = 1 +anchors_preset = -1 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 12.0 +offset_right = 52.0 +grow_vertical = 2 +texture_normal = ExtResource("23_7silw") +stretch_mode = 3 + +[node name="Seek" type="HSlider" parent="ReplayViewer" unique_id=1706750343] +layout_mode = 1 +anchors_preset = -1 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = 192.0 +offset_right = -32.0 +grow_vertical = 2 +theme = ExtResource("4_rvp5o") +max_value = 1.0 +step = 0.0 + +[node name="NotificationHolder" type="VBoxContainer" parent="." unique_id=1425635507] +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -210.0 +offset_top = -110.0 +offset_right = -10.0 +offset_bottom = -10.0 +grow_horizontal = 0 +grow_vertical = 0 +mouse_filter = 2 +alignment = 2 + +[node name="FPSCounter" parent="." unique_id=1955898342 instance=ExtResource("22_pl11u")] +anchors_preset = 2 +offset_top = -27.0 +offset_right = 72.0 + +[node name="Menu" type="Panel" parent="." unique_id=856970091] +visible = false +modulate = Color(1, 1, 1, 0) +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBoxEmpty_d5aou") + +[node name="Background" type="ColorRect" parent="Menu" unique_id=2094618318] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +color = Color(0, 0, 0, 0.25098) + +[node name="Button" type="Button" parent="Menu" unique_id=1826268412] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +button_mask = 3 +flat = true + +[node name="Holder" type="Panel" parent="Menu" unique_id=1204474678] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -220.0 +offset_top = -280.0 +offset_right = 220.0 +offset_bottom = 280.0 +mouse_filter = 1 +theme_override_styles/panel = SubResource("StyleBoxFlat_43mxh") + +[node name="Header" type="Label" parent="Menu/Holder" unique_id=544084605] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 1.0 +anchor_bottom = 0.2 +offset_top = 16.0 +text = "PAUSED" +label_settings = SubResource("LabelSettings_pwlqp") +horizontal_alignment = 1 + +[node name="Disclaimer" type="Label" parent="Menu/Holder" unique_id=1874627546] +layout_mode = 1 +anchors_preset = -1 +anchor_top = 0.8 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_bottom = -16.0 +text = "NOTE: Pausing disqualifies your pass" +label_settings = SubResource("LabelSettings_tjduq") +horizontal_alignment = 1 +vertical_alignment = 2 + +[node name="Resume" type="Button" parent="Menu/Holder" unique_id=616429602] +layout_mode = 1 +anchors_preset = -1 +anchor_top = 0.2 +anchor_right = 1.0 +anchor_bottom = 0.35 +offset_left = 32.0 +offset_right = -32.0 +mouse_default_cursor_shape = 2 +theme = SubResource("Theme_e1j6l") +theme_override_font_sizes/font_size = 28 +text = "RESUME" + +[node name="Restart" type="Button" parent="Menu/Holder" unique_id=865082248] +layout_mode = 1 +anchors_preset = -1 +anchor_top = 0.35 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = 32.0 +offset_right = -32.0 +mouse_default_cursor_shape = 2 +theme = SubResource("Theme_e1j6l") +theme_override_font_sizes/font_size = 28 +text = "RESTART" + +[node name="Settings" type="Button" parent="Menu/Holder" unique_id=730914507] +layout_mode = 1 +anchors_preset = -1 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.65 +offset_left = 32.0 +offset_right = -32.0 +mouse_default_cursor_shape = 2 +theme = SubResource("Theme_e1j6l") +theme_override_font_sizes/font_size = 28 +text = "SETTINGS" + +[node name="Quit" type="Button" parent="Menu/Holder" unique_id=2118605072] +layout_mode = 1 +anchors_preset = -1 +anchor_top = 0.65 +anchor_right = 1.0 +anchor_bottom = 0.8 +offset_left = 32.0 +offset_right = -32.0 +mouse_default_cursor_shape = 2 +theme = SubResource("Theme_e1j6l") +theme_override_font_sizes/font_size = 28 +text = "GIVE UP" + +[node name="Transition" type="ColorRect" parent="." unique_id=784178581] +self_modulate = Color(1, 1, 1, 0) +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +color = Color(0, 0, 0, 1) diff --git a/scripts/Rhythia.cs b/scripts/Rhythia.cs index dfb99ee6..d18c4189 100644 --- a/scripts/Rhythia.cs +++ b/scripts/Rhythia.cs @@ -156,7 +156,7 @@ public override async void _Ready() } } - LegacyRunner.Play(MapParser.Decode(matching[0].MapFilePath), matching[0].Speed, matching[0].StartFrom, matching[0].Modifiers, null, [.. matching]); + GameScene.Play(MapParser.Decode(matching[0].MapFilePath), matching[0].Speed, matching[0].StartFrom, matching[0].Modifiers, null, [.. matching]); } })); @@ -174,9 +174,9 @@ public static void Quit() Quitting = true; - if (!LegacyRunner.CurrentAttempt.IsReplay) + if (!GameScene.Attempt.IsReplay) { - LegacyRunner.CurrentAttempt.Stop(); + GameScene.Instance.Runner.Stop(); } Stats.TotalPlaytime += (Time.GetTicksUsec() - Constants.STARTED) / 1000000; @@ -196,8 +196,8 @@ public override void _Notification(int what) { if (what == NotificationWMCloseRequest) { - if (SceneManager.Scene != null && SceneManager.Scene is LegacyRunner) - { + if (SceneManager.Scene != null && SceneManager.Scene is GameScene) + Stats.RageQuits++; } diff --git a/scripts/SceneManager.cs b/scripts/SceneManager.cs index f85e716a..218557af 100644 --- a/scripts/SceneManager.cs +++ b/scripts/SceneManager.cs @@ -119,7 +119,6 @@ private static void addSpace(BaseSpace space, bool addToScene = false) } backgroundContainer.Visible = !addToScene; - Space = space; } diff --git a/scripts/game/Attempt.cs b/scripts/game/Attempt.cs index 84427c7b..395908a4 100644 --- a/scripts/game/Attempt.cs +++ b/scripts/game/Attempt.cs @@ -4,35 +4,95 @@ public partial class Attempt : GodotObject { - public bool IsReplay { get; set; } - - public bool Paused { get; set; } - - public CameraMode CameraMode { get; set; } = new CameraLock(); - - public Map Map { get; set; } - - public double Progress { get; set; } - - public Vector3 CameraPosition { get; set; } = new Vector3(0, 0, 3.75f); - - public Vector3 CameraRotation { get; set; } = Vector3.Zero; - - public Vector2 CursorPosition { get; set; } = new(); - - public Vector2 RawCursorPosition { get; set; } = new(); - - public Vector3 CameraBasisZ { get; set; } = new(); - - public int Speed { get; set; } - - public List Mods { get; set; } = new(); - - public Dictionary> Objects { get; set; } = new(); - - public SettingsProfile Settings { get; set; } = new(); - - public double DistanceMM { get; set; } - - public Replay? Replay { get; set; } + [Signal] public delegate void HitStateChangedEventHandler(HitObject hitObject, HitState newState); + + public ulong TimeStarted; + public double DeathTime = -1; + public string ID; + public Map Map; + public List Mods { get; set; } = new(); + public Dictionary> Objects { get; set; } = new(); + public SettingsProfile Settings; + public bool IsReplay = false; + public bool Stopped = false; + public bool Paused = false; + public bool Alive = true; + public bool CanSkip = false; + public bool Qualifies = false; + + public string[] Players = []; + + public CameraMode CameraMode { get; set; } = new CameraLock(); + public double Progress { get; set; } + public double Speed; + public double StartFrom; + public double MapLength; + public uint PassedNotes = 0; + + public double Accuracy = 100; + public double Health = 100; + public double HealthStep = 15; + + public uint Hits = 0; + public uint Misses = 0; + public uint Sum = 0; + public uint Score = 0; + public uint Combo = 0; + public uint ComboMultiplier = 1; + public uint ComboMultiplierProgress = 0; + public uint ComboMultiplierIncrement = 0; + public double ModsMultiplier = 1; + public float[] HitsInfo = []; + public Color LastHitColour = new Color(0.37254903f, 0.61960787f, 0.627451f, 1); + + public Vector3 CameraPosition { get; set; } = new Vector3(0, 0, 3.75f); + public Vector3 CameraRotation { get; set; } = Vector3.Zero; + public Vector3 CameraBasisZ { get; set; } = new(); + + public Vector2 CursorPosition = Vector2.Zero; + public Vector2 RawCursorPosition = Vector2.Zero; + public double DistanceMM = 0; + + public FileAccess ReplayFile; + public Replay? Replay { get; set; } + public Replay[] Replays; + public List ReplayFrames = []; + public List ReplaySkips = []; + public ulong LastReplayFrame = 0; + public uint ReplayFrameCountOffset = 0; + public uint ReplayAttemptStatusOffset = 0; + + public Attempt(Map map, double speed, double startFrom, Dictionary mods, string[] players = null, Replay[] replays = null) + { + ID = $"{map.Name}_{OS.GetUniqueId()}_{Time.GetDatetimeStringFromUnixTime((long)Time.GetUnixTimeFromSystem())}".Replace(":", "_"); + Settings = SettingsManager.Instance.Settings; + Replays = replays; + IsReplay = Replays != null; + Map = map; + Speed = speed; + StartFrom = startFrom; + Players = players ?? []; + Progress = Speed * -1000 - Settings.ApproachTime.Value * 1000 + StartFrom; + ComboMultiplierIncrement = Math.Max(2, (uint)Map.Notes.Length / 200); + Mods = []; + HitsInfo = IsReplay ? Replays[0].Notes : new float[Map.Notes.Length]; + + + // foreach (KeyValuePair mod in mods) + // { + // Mods[mod.Key] = mod.Value; + // } + // if (StartFrom > 0) + // { + // Qualifies = false; + // foreach (Note note in Map.Notes) + // { + // if (note.Millisecond < StartFrom) + // { + // FirstNote = (ulong)note.Index + 1; + // } + // } + // } + + } } diff --git a/scripts/game/GameComponent.cs b/scripts/game/GameComponent.cs index c58bc073..bd5e0c12 100644 --- a/scripts/game/GameComponent.cs +++ b/scripts/game/GameComponent.cs @@ -1,4 +1,4 @@ -using System.Collections; +/*using System.Collections; using System.Collections.Generic; using Godot; using Godot.Collections; @@ -112,3 +112,4 @@ public override void _Input(InputEvent @event) } } } +*/ \ No newline at end of file diff --git a/scripts/game/LegacyRenderer.cs b/scripts/game/LegacyRenderer.cs index 7f7f28b5..ff340cf5 100644 --- a/scripts/game/LegacyRenderer.cs +++ b/scripts/game/LegacyRenderer.cs @@ -1,9 +1,11 @@ using System; +using System.Linq; using Godot; public partial class LegacyRenderer : MultiMeshInstance3D { private SettingsProfile settings; + [Export] public Runner Runner; public override void _Ready() { @@ -12,45 +14,45 @@ public override void _Ready() public override void _Process(double delta) { - if (!LegacyRunner.Playing) + if (!Runner.Playing) { return; } - Multimesh.InstanceCount = LegacyRunner.ToProcess; + Multimesh.InstanceCount = Runner.ToProcess; - float ar = (float)(LegacyRunner.CurrentAttempt.IsReplay ? LegacyRunner.CurrentAttempt.Replays[0].ApproachRate : settings.ApproachRate.Value); - float ad = (float)(LegacyRunner.CurrentAttempt.IsReplay ? LegacyRunner.CurrentAttempt.Replays[0].ApproachDistance : settings.ApproachDistance.Value); + float ar = (float)(Runner.Attempt.IsReplay ? Runner.Attempt.Replays[0].ApproachRate : settings.ApproachRate.Value); + float ad = (float)(Runner.Attempt.IsReplay ? Runner.Attempt.Replays[0].ApproachDistance : settings.ApproachDistance.Value); float at = ad / ar; - float fadeIn = (float)(LegacyRunner.CurrentAttempt.IsReplay ? LegacyRunner.CurrentAttempt.Replays[0].FadeIn : settings.FadeIn.Value); - bool fadeOut = LegacyRunner.CurrentAttempt.IsReplay ? LegacyRunner.CurrentAttempt.Replays[0].FadeOut : settings.FadeOut.Value; - bool pushback = LegacyRunner.CurrentAttempt.IsReplay ? LegacyRunner.CurrentAttempt.Replays[0].Pushback : settings.Pushback.Value; + float fadeIn = (float)(Runner.Attempt.IsReplay ? Runner.Attempt.Replays[0].FadeIn : settings.FadeIn.Value); + bool fadeOut = Runner.Attempt.IsReplay ? Runner.Attempt.Replays[0].FadeOut : settings.FadeOut.Value; + bool pushback = Runner.Attempt.IsReplay ? Runner.Attempt.Replays[0].Pushback : settings.Pushback.Value; float hitWindowDepth = pushback ? (float)Constants.HIT_WINDOW * ar / 1000 : 0; - float noteSize = (float)(LegacyRunner.CurrentAttempt.IsReplay ? LegacyRunner.CurrentAttempt.Replays[0].NoteSize : settings.NoteSize.Value) / 4; + float noteSize = (float)(Runner.Attempt.IsReplay ? Runner.Attempt.Replays[0].NoteSize : settings.NoteSize.Value) / 4; Transform3D transform = new(Vector3.Right * noteSize, Vector3.Up * noteSize, Vector3.Back * noteSize, Vector3.Zero); - for (int i = 0; i < LegacyRunner.ToProcess; i++) + for (int i = 0; i < Runner.ToProcess; i++) { - Note note = LegacyRunner.ProcessNotes[i]; - float depth = (note.Millisecond - (float)LegacyRunner.CurrentAttempt.Progress) / (1000 * at) * ad / (float)LegacyRunner.CurrentAttempt.Speed; + Note note = Runner.ProcessNotes[i]; + float depth = (note.Millisecond - (float)Runner.Attempt.Progress) / (1000 * at) * ad / (float)Runner.Attempt.Speed; float alpha = Math.Clamp((1 - (float)depth / ad) / (fadeIn / 100), 0, 1); - if (LegacyRunner.CurrentAttempt.Mods["Ghost"]) + if (Runner.Attempt.Mods.Any(mod => mod.Name == "Ghost")) { alpha -= Math.Min(1, (ad - depth) / (ad / 2)); } else if (fadeOut) { - // alpha -= (ad - depth) / (ad + (float)Constants.HIT_WINDOW * ar / 1000); + //alpha -= (ad - depth) / (ad + (float)Constants.HIT_WINDOW * ar / 1000); alpha *= Math.Min(1, (depth + hitWindowDepth) / (ad + hitWindowDepth)); } - if (!pushback && note.Millisecond - LegacyRunner.CurrentAttempt.Progress <= 0) + if (!pushback && note.Millisecond - Runner.Attempt.Progress <= 0) { alpha = 0; } - int j = LegacyRunner.ToProcess - i - 1; + int j = Runner.ToProcess - i - 1; Color color = SkinManager.Instance.Skin.NoteColors[note.Index % SkinManager.Instance.Skin.NoteColors.Length]; diff --git a/scripts/game/Runner.cs b/scripts/game/Runner.cs new file mode 100644 index 00000000..62919ffb --- /dev/null +++ b/scripts/game/Runner.cs @@ -0,0 +1,301 @@ +using Godot; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; +using System.Linq; + +public partial class Runner : Node3D +{ + public Attempt Attempt; + public Map Map; + private SettingsProfile settings; + public double Speed = 1; + public bool Paused = false; + public bool Playing = false; + public bool StopQueued = false; + + public int ToProcess = 0; + public List ProcessNotes = []; + private double lastFrame = Time.GetTicksUsec(); + + public bool SpinCamera = false; + + [ExportCategory("Settings")] + [Export] public bool HideHUD = false; + + [ExportCategory("Nodes")] + [Export] public Camera3D Camera; + [Export] public MeshInstance3D Grid; + [Export] public MeshInstance3D Cursor; + [Export] public MultiMeshInstance3D Notes; + + public override void _Ready() + { + base._Ready(); + + // if null, assign them to nodes under Runner + Camera ??= GetNode("Camera3D"); + Grid ??= GetNode("Grid"); + Cursor ??= GetNode("Cursor"); + Notes ??= GetNode("Notes"); + } + + public override void _Process(double delta) + { + ulong now = Time.GetTicksUsec(); + delta = (now - lastFrame) / 1000000; // more reliable + lastFrame = now; + + if (!Playing) return; + Attempt.Progress += delta * 1000 * Attempt.Speed; + Attempt.CanSkip = false; + + if (Attempt.Map.AudioBuffer != null) + { + if (Attempt.Progress >= Attempt.MapLength - Constants.HIT_WINDOW) + { + if (SoundManager.Song.Playing) + { + SoundManager.Song.Stop(); + } + } + else if (!SoundManager.Song.Playing && Attempt.Progress >= 0) + { + SoundManager.Song.Play(); + SoundManager.Song.Seek((float)Attempt.Progress / 1000); + } + } + + int nextNoteMillisecond = Attempt.PassedNotes >= Attempt.Map.Notes.Length ? (int)Attempt.MapLength + Constants.BREAK_TIME : Attempt.Map.Notes[Attempt.PassedNotes].Millisecond; + + if (nextNoteMillisecond - Attempt.Progress >= Constants.BREAK_TIME * Attempt.Speed) + { + int lastNoteMillisecond = Attempt.PassedNotes > 0 ? Attempt.Map.Notes[Attempt.PassedNotes - 1].Millisecond : 0; + int skipWindow = nextNoteMillisecond - Constants.BREAK_TIME - lastNoteMillisecond; + + if (skipWindow >= 1000 * Attempt.Speed) // only allow skipping if i'm gonna allow it for at least 1 second + { + Attempt.CanSkip = true; + } + } + + ToProcess = 0; + ProcessNotes.Clear(); + + // note process check + double at = Attempt.IsReplay ? Attempt.Replays[0].ApproachTime : settings.ApproachTime; + + for (uint i = Attempt.PassedNotes; i < Attempt.Map.Notes.Length; i++) + { + Note note = Attempt.Map.Notes[i]; + + if (note.Millisecond < Attempt.StartFrom) + { + continue; + } + + if (note.Millisecond + Constants.HIT_WINDOW * Attempt.Speed < Attempt.Progress) // past hit window + { + if (i + 1 > Attempt.PassedNotes) + { + if (Attempt.IsReplay && Attempt.Replays.Length <= 1 && Attempt.Replays[0].Notes[note.Index] == -1 || !Attempt.IsReplay && note.HitState != HitState.HIT) + { + note.Miss(Attempt); + } + + Attempt.PassedNotes = i + 1; + } + + if (!Attempt.IsReplay) + { + continue; + } + } + else if (note.Millisecond > Attempt.Progress + at * 1000 * Attempt.Speed) // past approach distance + { + break; + } + else if (note.HitState == HitState.HIT) // no point + { + continue; + } + + if (settings.AlwaysPlayHitSound && !Attempt.Map.Notes[i].Hittable && note.Millisecond < Attempt.Progress) + { + Attempt.Map.Notes[i].Hittable = true; + + SoundManager.HitSound.Play(); + } + + ToProcess++; + ProcessNotes.Add(note); + } + + // hitreg check + for (int i = 0; i < ToProcess; i++) + { + Note note = ProcessNotes[i]; + if (note.HitState == HitState.HIT) continue; + + if (!Attempt.IsReplay) + { + if (note.Millisecond - Attempt.Progress > 0) + { + continue; + } + note.CheckHit(Attempt, note); + } + else if (Attempt.Replays.Length > 1 && note.Millisecond - Attempt.Progress <= 0 || Attempt.Replays[0].Notes[note.Index] != -1 && note.Millisecond - Attempt.Progress + Attempt.Replays[0].Notes[note.Index] * Attempt.Speed <= 0) + { + //Attempt.Hit(note.Index); + } + } + + if (Attempt.Progress >= Attempt.MapLength) + { + Stop(); + return; + } + + // if (Attempt.Skippable) + // { + // targetSkipLabelAlpha = 100f / 255f; + // progressLabel.Modulate = Color.Color8(255, 255, 255, (byte)(96 + (int)(140 * (Math.Sin(Math.PI * now / 750000) / 2 + 0.5)))); + // } + // else + // { + // targetSkipLabelAlpha = 0; + // progressLabel.Modulate = Color.Color8(255, 255, 255, 190); + // } + + // progressLabel.Text = $"{Util.String.FormatTime(Math.Max(0, Attempt.Progress) / 1000)} / {Util.String.FormatTime(MapLength / 1000)}"; + // healthTexture.Size = healthTexture.Size.Lerp(new Vector2(32 + (float)Attempt.Health * 10.24f, 80), Math.Min(1, (float)delta * 64)); + // progressBarTexture.Size = new Vector2(32 + (float)(Attempt.Progress / MapLength) * 1024, 80); + // skipLabel.Modulate = Color.Color8(255, 255, 255, (byte)(skipLabelAlpha * 255)); + + //Cursor.RotationDegrees += Vector3.Back * settings.CursorRotation * (float)delta; + } + + public void Set(Map map) => Map = map; + + public void Play() + { + if (Attempt == null) + { + return; + } + + Control focused = SceneManager.Root.GetViewport().GuiGetFocusOwner(); + focused?.ReleaseFocus(); + + Playing = true; + Attempt.TimeStarted = Time.GetTicksUsec(); + SpinCamera = Attempt.Mods.Any(mod => mod.Name == "Spin"); + + settings = SettingsManager.Instance.Settings; + Camera.Fov = settings.FoV.Value; + (Cursor.Mesh as QuadMesh).Size = new Vector2((float)(Constants.CURSOR_SIZE * settings.CursorScale.Value), (float)(Constants.CURSOR_SIZE * settings.CursorScale.Value)); + + (Cursor.GetActiveMaterial(0) as StandardMaterial3D).AlbedoTexture = SkinManager.Instance.Skin.CursorImage; + (Grid.GetActiveMaterial(0) as StandardMaterial3D).AlbedoTexture = SkinManager.Instance.Skin.GridImage; + Notes.Multimesh.Mesh = SkinManager.Instance.Skin.NoteMesh; + + if (Attempt.Map.AudioBuffer != null) + { + SoundManager.Song.Stream = Util.Audio.LoadStream(Attempt.Map.AudioBuffer); + SoundManager.Song.PitchScale = (float)Attempt.Speed; + Attempt.MapLength = (float)SoundManager.Song.Stream.GetLength() * 1000; + } + else + { + Attempt.MapLength = Attempt.Map.Length + 1000; + } + + Attempt.MapLength += Constants.HIT_WINDOW; + SoundManager.UpdateVolume(); + } + + public void Restart() + { + Attempt.Alive = false; + Attempt.Qualifies = false; + Stop(false); + + SceneManager.ReloadCurrentScene(); + GameScene.Play(MapParser.Decode(Attempt.Map.FilePath), Attempt.Speed, Attempt.StartFrom, null, Attempt.Players, Attempt.Replays); + } + + public void Pause() + { + + } + + public void QueueStop() + { + if (!Playing) + { + return; + } + + Playing = false; + StopQueued = true; + } + + + public void Stop(bool results = true) + { + if (Attempt.Stopped) + { + return; + } + + //Attempt.Stop(); + + if (!Attempt.IsReplay) + { + Stats.GamePlaytime += (Time.GetTicksUsec() - Attempt.TimeStarted) / 1000000; + Stats.TotalDistance += (ulong)Attempt.DistanceMM; + + if (Attempt.StartFrom == 0) + { + // if (!File.Exists($"{Constants.USER_FOLDER}/pbs/{Attempt.Map.Name}")) + // { + // List bytes = [0, 0, 0, 0]; + // bytes.AddRange(SHA256.HashData([0, 0, 0, 0])); + // File.WriteAllBytes($"{Constants.USER_FOLDER}/pbs/{Attempt.Map.Name}", [.. bytes]); + // } + + // Leaderboard leaderboard = new(Attempt.Map.Name, $"{Constants.USER_FOLDER}/pbs/{Attempt.Map.Name}"); + + // leaderboard.Add(new(Attempt.ID, "You", Attempt.Qualifies, Attempt.Score, Attempt.Accuracy, Time.GetUnixTimeFromSystem(), Attempt.Progress, Attempt.Map.Length, Attempt.Speed, Attempt.Mods)); + // leaderboard.Save(); + + if (Attempt.Qualifies) + { + Stats.Passes++; + Stats.TotalScore += Attempt.Score; + + if (Attempt.Accuracy == 100) + { + Stats.FullCombos++; + } + + if (Attempt.Score > Stats.HighestScore) + { + Stats.HighestScore = Attempt.Score; + } + + Stats.PassAccuracies.Add(Attempt.Accuracy); + } + } + } + + DisplayServer.WindowSetVsyncMode(DisplayServer.VSyncMode.Adaptive); + + if (results) + { + SceneManager.Load("res://scenes/results.tscn"); + } + } +} \ No newline at end of file diff --git a/scripts/game/Runner.cs.uid b/scripts/game/Runner.cs.uid new file mode 100644 index 00000000..082bc758 --- /dev/null +++ b/scripts/game/Runner.cs.uid @@ -0,0 +1 @@ +uid://dp8nga2aot1n2 diff --git a/scripts/game/managers/HudManager.cs b/scripts/game/managers/HudManager.cs new file mode 100644 index 00000000..f012ab61 --- /dev/null +++ b/scripts/game/managers/HudManager.cs @@ -0,0 +1,70 @@ +using Godot; +using System; +using System.Collections.Generic; + +public partial class HudManager : Node +{ + [Export] public Runner Runner; + [Export] public Node3D HUDContainer; + + public struct hudElements + { + public Panel MultiplierProgress; + public Label Score, MultiplierLabel, Hits, Misses, SimpleMisses, Sum, Accuracy; + public Label3D Progress, Title, Combo, Speed, Skip; + public TextureRect HealthBarTexture, ProgressBarTexture; + } + + public hudElements Hud = new hudElements(); + + public void Init() + { + Runner ??= GetParent(); + + var healthViewport = GetNode("%Health").GetNode("HealthViewport"); + var progressBarViewport = GetNode("%ProgressBar").GetNode("ProgressBarViewport"); + var panelLeftViewport = GetNode("%PanelLeft").GetNode("PanelLeftViewport"); + var panelRightViewport = GetNode("%PanelRight").GetNode("PanelRightViewport"); + + Hud.Score = panelLeftViewport.GetNode