Skip to content

Commit 27c65b0

Browse files
committed
feat: solid space
.
1 parent bc22496 commit 27c65b0

4 files changed

Lines changed: 104 additions & 2 deletions

File tree

prefabs/spaces/solid.tscn

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[gd_scene format=3 uid="uid://bloah4i51wdsj"]
2+
3+
[ext_resource type="Script" uid="uid://2onud88s5nkr" path="res://scripts/spaces/Solid.cs" id="1_rw8lf"]
4+
5+
[sub_resource type="Environment" id="Environment_n6lso"]
6+
background_mode = 1
7+
background_color = Color(0.011764706, 0, 0.09019608, 1)
8+
background_energy_multiplier = 1.2
9+
glow_intensity = 1.5
10+
glow_bloom = 0.15
11+
12+
[node name="Squircles" type="Node3D" unique_id=1958332010]
13+
script = ExtResource("1_rw8lf")
14+
15+
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=495103429]
16+
environment = SubResource("Environment_n6lso")
17+
18+
[node name="Camera3D" type="Camera3D" parent="." unique_id=1770879942]
19+
fov = 50.0
20+
size = 1.25

scripts/database/settings/SettingsProfile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ public SettingsProfile()
537537
UpdateAction = (_, init) => { if (!init) { SkinManager.Load(); } },
538538
List = new("skin")
539539
{
540-
Values = ["skin", "void", "grid", "squircles", "waves", "galaxy", "tunnel", "vortex"]
540+
Values = ["skin", "void", "grid", "squircles", "waves", "galaxy", "tunnel", "vortex", "solid"]
541541
}
542542
};
543543

@@ -550,7 +550,7 @@ public SettingsProfile()
550550
UpdateAction = (_, init) => { if (!init) { SkinManager.Load(); } },
551551
List = new("skin")
552552
{
553-
Values = ["skin", "void", "grid", "squircles", "waves", "galaxy", "tunnel", "vortex"]
553+
Values = ["skin", "void", "grid", "squircles", "waves", "galaxy", "tunnel", "vortex", "solid"]
554554
}
555555
};
556556

scripts/spaces/Solid.cs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using Godot;
2+
3+
namespace Spaces;
4+
5+
public partial class Solid : BaseSpace
6+
{
7+
private Color defaultEnvironmentColor;
8+
9+
public override void _Ready()
10+
{
11+
base._Ready();
12+
13+
14+
defaultEnvironmentColor = WorldEnvironment.Environment.BackgroundColor;
15+
}
16+
17+
public override void _Process(double delta)
18+
{
19+
base._Process(delta);
20+
21+
if (Playing)
22+
{
23+
updateColor(NoteHitColor);
24+
}
25+
else
26+
{
27+
Viewport viewport = GetViewport();
28+
Vector2 centerOffset = viewport.GetMousePosition() - viewport.GetVisibleRect().Size / 2;
29+
30+
Camera.Position = new Vector3(centerOffset.X, centerOffset.Y, 0) / 40000;
31+
}
32+
}
33+
34+
public override void UpdateMap(Map map)
35+
{
36+
base.UpdateMap(map);
37+
38+
Color color = defaultEnvironmentColor;
39+
40+
if (!Playing && Cover != null)
41+
{
42+
Image coverImage = Cover.GetImage();
43+
44+
if (coverImage.IsCompressed())
45+
{
46+
return;
47+
}
48+
49+
Vector3 avg = Vector3.Zero;
50+
int pixelCount = 0;
51+
52+
for (int x = 0; x < coverImage.GetWidth(); x++)
53+
{
54+
for (int y = 0; y < coverImage.GetHeight(); y++)
55+
{
56+
Color pixel = coverImage.GetPixel(x, y);
57+
58+
if (pixel.A == 0)
59+
{
60+
continue;
61+
}
62+
63+
avg += new Vector3(pixel.R, pixel.G, pixel.B);
64+
pixelCount++;
65+
}
66+
}
67+
68+
avg /= pixelCount;
69+
color = new(avg.X, avg.Y, avg.Z);
70+
}
71+
72+
updateColor(color);
73+
}
74+
75+
private void updateColor(Color color)
76+
{
77+
Color darkened = color.Darkened(0.9f);
78+
79+
WorldEnvironment.Environment.BackgroundColor = Playing ? darkened : (Cover != null ? darkened : defaultEnvironmentColor);
80+
}
81+
}

scripts/spaces/Solid.cs.uid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://2onud88s5nkr

0 commit comments

Comments
 (0)