Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions scenes/game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
[ext_resource type="Texture2D" uid="uid://dmc5f6ajp8xv1" path="res://user/skins/default/game/progress_background.png" id="8_eu3ux"]
[ext_resource type="Script" uid="uid://dv0gni2j4t686" path="res://scripts/game/ui/PanelLeft.cs" id="8_qnb83"]
[ext_resource type="Texture2D" uid="uid://d3s17ehomjscd" path="res://user/skins/default/game/progress.png" id="9_nde5v"]
[ext_resource type="Texture2D" uid="uid://2qqfj6l0n8c4" path="res://user/skins/default/ui/flashlight.png" id="11_0sl42"]
[ext_resource type="Texture2D" uid="uid://80bitp5weqrb" path="res://user/skins/default/game/panel_left_background.png" id="11_sdncv"]
[ext_resource type="FontFile" uid="uid://b6hgjef6s6oly" path="res://fonts/Comfortaa/Comfortaa-Bold.ttf" id="12_axsek"]
[ext_resource type="Texture2D" uid="uid://ccdaf14yq65jf" path="res://user/skins/default/game/grid_guides.png" id="12_pr1ej"]
Expand Down Expand Up @@ -46,6 +47,7 @@

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_05nbr"]
resource_name = "Material"
render_priority = 2
transparency = 1
shading_mode = 0
albedo_texture = ExtResource("2_q78ea")
Expand All @@ -56,6 +58,7 @@ material = SubResource("StandardMaterial3D_05nbr")
size = Vector2(4, 4)

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0sl42"]
render_priority = 2
transparency = 1
shading_mode = 0
disable_ambient_light = true
Expand All @@ -70,6 +73,7 @@ material = SubResource("StandardMaterial3D_0sl42")
size = Vector2(0.263, 0.263)

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ssr8x"]
render_priority = 2
transparency = 1
cull_mode = 2
shading_mode = 0
Expand All @@ -87,6 +91,7 @@ mesh = SubResource("QuadMesh_458eo")

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_h3rex"]
resource_name = "Material"
render_priority = 2
transparency = 1
shading_mode = 0
albedo_texture = ExtResource("12_pr1ej")
Expand All @@ -97,6 +102,7 @@ material = SubResource("StandardMaterial3D_h3rex")
size = Vector2(4, 4)

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_fedci"]
render_priority = 2
transparency = 1
shading_mode = 0
albedo_texture = ExtResource("36_05nbr")
Expand All @@ -109,6 +115,7 @@ viewport_path = NodePath("Runner/HUD/Health/HealthViewport")

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4p8vu"]
resource_local_to_scene = true
render_priority = 2
transparency = 1
shading_mode = 0
disable_fog = true
Expand All @@ -125,6 +132,7 @@ viewport_path = NodePath("Runner/HUD/PanelLeft/PanelLeftViewport")

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nody0"]
resource_local_to_scene = true
render_priority = 2
transparency = 1
shading_mode = 0
disable_fog = true
Expand Down Expand Up @@ -163,6 +171,7 @@ viewport_path = NodePath("Runner/HUD/PanelRight/PanelRightViewport")

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ro5ir"]
resource_local_to_scene = true
render_priority = 2
transparency = 1
shading_mode = 0
disable_fog = true
Expand Down Expand Up @@ -194,6 +203,7 @@ viewport_path = NodePath("Runner/HUD/ProgressBar/ProgressBarViewport")

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_p1h21"]
resource_local_to_scene = true
render_priority = 2
transparency = 1
shading_mode = 0
disable_fog = true
Expand All @@ -210,6 +220,7 @@ viewport_path = NodePath("Runner/Video/VideoViewport")

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rj3ky"]
resource_local_to_scene = true
render_priority = 2
transparency = 1
no_depth_test = true
shading_mode = 0
Expand Down Expand Up @@ -305,15 +316,12 @@ Runner = NodePath("../Runner")
ReplayViewer = NodePath("../ReplayViewer")
CursorManager = NodePath("../CursorManager")

[node name="Runner" type="Node3D" parent="." unique_id=580620214 node_paths=PackedStringArray("HudManager", "Camera", "Renderers", "Grid", "GridGuides", "PanelLeft", "PanelRight", "Cursor")]
[node name="Runner" type="Node3D" parent="." unique_id=580620214 node_paths=PackedStringArray("HudManager", "Camera", "Renderers", "Grid", "Cursor")]
script = ExtResource("2_qnb83")
HudManager = NodePath("HUD")
Camera = NodePath("Camera3D")
Renderers = [NodePath("Renderers/Notes")]
Grid = NodePath("HUD/Grid")
GridGuides = NodePath("HUD/Grid/GridGuides")
PanelLeft = NodePath("HUD/PanelLeft")
PanelRight = NodePath("HUD/PanelRight")
Cursor = NodePath("HUD/Grid/Cursor")

[node name="HUD" type="Node3D" parent="Runner" unique_id=1234434255 node_paths=PackedStringArray("Runner")]
Expand All @@ -329,6 +337,17 @@ script = ExtResource("27_js0lu")
mesh = SubResource("QuadMesh_xij4d")
skeleton = NodePath("../../../..")

[node name="Flashlight" type="Node3D" parent="Runner/HUD/Grid/Cursor" unique_id=1514079469]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.015, -0.01, 0)
visible = false

[node name="FlashlightSprite" type="Sprite3D" parent="Runner/HUD/Grid/Cursor/Flashlight" unique_id=700151672]
pixel_size = 0.025
billboard = 1
no_depth_test = true
render_priority = 1
texture = ExtResource("11_0sl42")

[node name="BufferCursor" type="MeshInstance3D" parent="Runner/HUD/Grid" unique_id=703771191]
visible = false
transparency = 1.0
Expand Down Expand Up @@ -646,6 +665,7 @@ script = ExtResource("21_twgab")
[node name="Label" type="Label3D" parent="Runner/HUD/Progress" unique_id=496335082]
transform = Transform3D(3.5, 0, 0, 0, 3.38074, -0.905867, 0, 0.905867, 3.38074, 0, 7, -10)
pixel_size = 0.0025
render_priority = 2
modulate = Color(1, 1, 1, 0.74509805)
outline_modulate = Color(0, 0, 0, 0)
text = "0:00 / 0:00"
Expand All @@ -657,6 +677,7 @@ script = ExtResource("22_02fa5")

[node name="Label" type="Label3D" parent="Runner/HUD/Title" unique_id=841289409]
transform = Transform3D(2, 0, 0, 0, 1.93185, -0.517638, 0, 0.517638, 1.93185, 0, 8.25, -10)
render_priority = 2
outline_modulate = Color(0, 0, 0, 0)
text = "N/A - N/A"
font = ExtResource("20_pr1ej")
Expand All @@ -670,6 +691,8 @@ script = ExtResource("20_suyxu")
[node name="Label" type="Label3D" parent="Runner/HUD/Combo" unique_id=1330017059]
transform = Transform3D(7, 0, 0, 0, 6.89365, -1.21554, 0, 1.21554, 6.89365, 0, 3.5, -10)
pixel_size = 0.0025
render_priority = 2
outline_render_priority = 2
modulate = Color(1, 1, 1, 0)
outline_modulate = Color(1, 1, 1, 0.39215687)
text = "0"
Expand All @@ -684,6 +707,7 @@ script = ExtResource("28_gxtfn")
[node name="Label" type="Label3D" parent="Runner/HUD/Speed" unique_id=1294863906]
transform = Transform3D(0.99999994, 0, 0, 0, 0.99999994, 0, 0, 0, 0.99999994, 0, 0, 0)
pixel_size = 0.0025
render_priority = 2
modulate = Color(1, 1, 1, 0.39215687)
outline_modulate = Color(0, 0, 0, 0)
text = "1.00x"
Expand All @@ -695,6 +719,7 @@ script = ExtResource("25_nepv3")
[node name="Label" type="Label3D" parent="Runner/HUD/Skip" unique_id=1231864437]
transform = Transform3D(7, 0, 0, 0, 6.76148, 1.81173, 0, -1.81173, 6.76148, 0, -5, -10)
pixel_size = 0.0025
render_priority = 2
modulate = Color(1, 1, 1, 0)
outline_modulate = Color(0, 0, 0, 0)
text = "Press Space to skip"
Expand All @@ -706,6 +731,7 @@ visible = false
modulate = Color(1, 1, 1, 0.376471)
double_sided = false
no_depth_test = true
render_priority = 2
texture = ExtResource("34_8ool0")

[node name="Renderers" type="Node3D" parent="Runner" unique_id=561265512]
Expand Down
1 change: 1 addition & 0 deletions scripts/Rhythia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public static void RegisterModifiers()
new GhostModifier(),
new StrobeModifier(),
new FlickerModifier(),
new FlashlightModifier(),
new ChaosModifier(),
new VortexModifier(),
new EarthquakeModifier(),
Expand Down
7 changes: 6 additions & 1 deletion scripts/game/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,18 @@ private void syncSongPosition()
}

/// <summary>
/// Resets grid size and panels positions
/// Resets previous hud items' states
/// </summary>
private void resetHudItems()
{
PanelLeft.Translate(new Vector3(-(float)panelOffset, 0, 0));
PanelRight.Translate(new Vector3((float)panelOffset, 0, 0));
gridMesh.Size = gridOriginalSize;
gridGuidesMesh.Size = gridOriginalSize;

foreach (IHudObjectModifier mod in Attempt.Modifiers.Where(mod => mod is IHudObjectModifier))
{
mod.ResetGrid(Grid);
}
}
}
44 changes: 44 additions & 0 deletions scripts/game/modifiers/FlashlightModifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using Godot;

public class FlashlightModifier : Modifier, IModifier, IHudObjectModifier
{
public override string Name => "Flashlight";

public override Color Color => new(0xffffffff);

public override bool Rankable => true;

public override double ScoreMultiplier => 1.1;

private float minFlashlightSize = 0.015f;

private float maxFlashlightSize = 0.025f;

private float minFlashlightSpinSize = 0.01875f;

private float maxFlashlightSpinSize = 0.03125f;

public float GetFlashlightSize(Attempt attempt)
{
bool cameraLock = attempt.CameraMode is CameraLock;
long minFlashlightCombo = attempt.Map.Notes.Length / 100 * 25;

return cameraLock
? maxFlashlightSize - ((maxFlashlightSize - minFlashlightSize) / minFlashlightCombo * Math.Min(attempt.Combo, minFlashlightCombo))
: maxFlashlightSpinSize
- ((maxFlashlightSpinSize - minFlashlightSpinSize) / minFlashlightCombo * Math.Min(attempt.Combo, minFlashlightCombo));
}

public void ModifyGrid(MeshInstance3D grid)
{
Node3D flashlight = grid.GetNode<Node3D>("Cursor/Flashlight");
flashlight.Visible = true;
}

public void ResetGrid(MeshInstance3D grid)
{
Node3D flashlight = grid.GetNode<Node3D>("Cursor/Flashlight");
flashlight.Visible = false;
}
}
1 change: 1 addition & 0 deletions scripts/game/modifiers/FlashlightModifier.cs.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://bdjv4awfyrc1p
5 changes: 5 additions & 0 deletions scripts/game/modifiers/IHudObjectModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ void ModifyGrid(MeshInstance3D grid)
{
return;
}

void ResetGrid(MeshInstance3D grid)
{
return;
}
}
9 changes: 4 additions & 5 deletions scripts/game/renderers/NoteRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ public override void Setup(SettingsProfile settings, SkinProfile skin)
}
}

private bool doRender(Note note, float time, float approachTime, float speed)
private bool doRender(Note note, float time, float approachTime, float speed, bool pushback)
{
return note.Millisecond - time >= (Settings.Pushback ? -Constants.HIT_WINDOW * speed : 0)
&& note.Millisecond - time <= approachTime * 1000 * speed;
return note.Millisecond - time >= (pushback ? -Constants.HIT_WINDOW * speed : 0) && note.Millisecond - time <= approachTime * 1000 * speed;
}

public void Render(double delta, double time, IList<Note> notes)
Expand All @@ -73,7 +72,7 @@ public void Render(double delta, double time, IList<Note> notes)
float fadeOut = (float)(double)Settings.FadeOut / 100;
float noteOpacity = (float)(double)Settings.NoteOpacity;
float noteOpacityExponent = Math.Max(Mathf.Epsilon, (float)(double)Settings.NoteOpacityExponent);
bool pushback = Settings.Pushback;
bool pushback = attempt.Modifiers.Any(mod => mod is FlashlightModifier) ? false : Settings.Pushback;
float hitWindowDepth = pushback ? (float)Constants.HIT_WINDOW * ar / 1000 : 0;
var transform = new Transform3D(new(noteSize / 2, 0, 0), new(0, noteSize / 2, 0), new(0, 0, noteSize / 2), Vector3.Zero);

Expand All @@ -91,7 +90,7 @@ public void Render(double delta, double time, IList<Note> notes)
{
var note = notes[i];

if (!doRender(note, (float)time, at, (float)attempt.Speed) || note.LastResult == HitResult.Hit)
if (!doRender(note, (float)time, at, (float)attempt.Speed, pushback) || note.LastResult == HitResult.Hit)
{
NoteMultiMesh.Multimesh.SetInstanceColor(i, transparent);
continue;
Expand Down
12 changes: 12 additions & 0 deletions scripts/game/ui/Grid.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using System.Linq;
using Godot;

public partial class Grid : MeshInstance3D, IUIComponent
Expand All @@ -11,6 +12,7 @@ public partial class Grid : MeshInstance3D, IUIComponent
public MultiMeshInstance3D CursorTrail { get; set; }
public MeshInstance3D GridGuides { get; set; }
public MeshInstance3D VisibilityAssist { get; set; }
public Sprite3D FlashlightSprite { get; set; }

private static readonly PackedScene hit_feedback = GD.Load<PackedScene>("res://prefabs/hit_popup.tscn");
private static readonly PackedScene miss_feedback = GD.Load<PackedScene>("res://prefabs/miss_icon.tscn");
Expand Down Expand Up @@ -66,9 +68,19 @@ public void Init()

(GetActiveMaterial(0) as StandardMaterial3D).AlbedoTexture = SkinManager.Instance.Skin.GridImage;

FlashlightSprite = GetNode<Sprite3D>("Cursor/Flashlight/FlashlightSprite");

Runner.HitResultChanged += onHitResultChanged;
}

public void Process(double delta, Attempt attempt)
{
foreach (FlashlightModifier mod in attempt.Modifiers.Where(mod => mod is FlashlightModifier))
{
FlashlightSprite.PixelSize = (float)Mathf.Lerp(FlashlightSprite.PixelSize, mod.GetFlashlightSize(attempt), 0.0125);
}
}

private void onHitResultChanged(int noteIndex, HitResult result)
{
float lateness = Runner.Attempt.IsReplay
Expand Down
3 changes: 3 additions & 0 deletions scripts/map/Replay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ public Replay(string path)
case "Flicker":
Modifiers.Add(new FlickerModifier());
break;
case "Flashlight":
Modifiers.Add(new FlashlightModifier());
break;
case "Earthquake":
Modifiers.Add(new EarthquakeModifier());
break;
Expand Down
1 change: 1 addition & 0 deletions scripts/skinning/SkinManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public static void Load()
skin.ModGhostImage = loadTexture("modifiers/ghost.png");
skin.ModStrobeImage = loadTexture("modifiers/strobe.png");
skin.ModFlickerImage = loadTexture("modifiers/flicker.png");
skin.ModFlashlightImage = loadTexture("modifiers/flashlight.png");
skin.ModChaosImage = loadTexture("modifiers/chaos.png");
skin.ModVortexImage = loadTexture("modifiers/vortex.png");
skin.ModEarthquakeImage = loadTexture("modifiers/earthquake.png");
Expand Down
2 changes: 2 additions & 0 deletions scripts/skinning/SkinProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public partial class SkinProfile : RefCounted

public ImageTexture ModFlickerImage { get; set; } = new();

public ImageTexture ModFlashlightImage { get; set; } = new();

public ImageTexture ModChaosImage { get; set; } = new();

public ImageTexture ModVortexImage { get; set; } = new();
Expand Down
15 changes: 9 additions & 6 deletions scripts/util/Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public static Texture2D GetModIcon(string mod)
case "Flicker":
tex = skin.ModFlickerImage;
break;
case "Flashlight":
tex = skin.ModFlashlightImage;
break;
case "Chaos":
tex = skin.ModChaosImage;
break;
Expand Down Expand Up @@ -143,12 +146,12 @@ public static Image LoadImageFromBuffer(byte[] buffer)
$"""
Couldn't load image from buffer
Type: {(
isPng ? "PNG"
: isJpeg ? "JPG"
: isBmp ? "BMP"
: isWebp ? "WEBP"
: "Unknown"
)};
isPng ? "PNG"
: isJpeg ? "JPG"
: isBmp ? "BMP"
: isWebp ? "WEBP"
: "Unknown"
)};
Size: {buffer.Length}
"""
);
Expand Down
Binary file added user/skins/default/modifiers/flashlight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading