diff --git a/prefabs/spaces/solid.tscn b/prefabs/spaces/solid.tscn new file mode 100644 index 0000000..885a366 --- /dev/null +++ b/prefabs/spaces/solid.tscn @@ -0,0 +1,20 @@ +[gd_scene format=3 uid="uid://bloah4i51wdsj"] + +[ext_resource type="Script" uid="uid://2onud88s5nkr" path="res://scripts/spaces/Solid.cs" id="1_rw8lf"] + +[sub_resource type="Environment" id="Environment_n6lso"] +background_mode = 1 +background_color = Color(0.011764706, 0, 0.09019608, 1) +background_energy_multiplier = 1.2 +glow_intensity = 1.5 +glow_bloom = 0.15 + +[node name="Squircles" type="Node3D" unique_id=1958332010] +script = ExtResource("1_rw8lf") + +[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=495103429] +environment = SubResource("Environment_n6lso") + +[node name="Camera3D" type="Camera3D" parent="." unique_id=1770879942] +fov = 50.0 +size = 1.25 diff --git a/scripts/database/settings/SettingsProfile.cs b/scripts/database/settings/SettingsProfile.cs index 2473076..830594b 100644 --- a/scripts/database/settings/SettingsProfile.cs +++ b/scripts/database/settings/SettingsProfile.cs @@ -537,7 +537,7 @@ public SettingsProfile() UpdateAction = (_, init) => { if (!init) { SkinManager.Load(); } }, List = new("skin") { - Values = ["skin", "void", "grid", "squircles", "waves", "galaxy", "tunnel", "vortex"] + Values = ["skin", "void", "grid", "squircles", "waves", "galaxy", "tunnel", "vortex", "solid"] } }; @@ -550,7 +550,7 @@ public SettingsProfile() UpdateAction = (_, init) => { if (!init) { SkinManager.Load(); } }, List = new("skin") { - Values = ["skin", "void", "grid", "squircles", "waves", "galaxy", "tunnel", "vortex"] + Values = ["skin", "void", "grid", "squircles", "waves", "galaxy", "tunnel", "vortex", "solid"] } }; diff --git a/scripts/spaces/Solid.cs b/scripts/spaces/Solid.cs new file mode 100644 index 0000000..364eb66 --- /dev/null +++ b/scripts/spaces/Solid.cs @@ -0,0 +1,81 @@ +using Godot; + +namespace Spaces; + +public partial class Solid : BaseSpace +{ + private Color defaultEnvironmentColor; + + public override void _Ready() + { + base._Ready(); + + + defaultEnvironmentColor = WorldEnvironment.Environment.BackgroundColor; + } + + public override void _Process(double delta) + { + base._Process(delta); + + if (Playing) + { + updateColor(NoteHitColor); + } + else + { + Viewport viewport = GetViewport(); + Vector2 centerOffset = viewport.GetMousePosition() - viewport.GetVisibleRect().Size / 2; + + Camera.Position = new Vector3(centerOffset.X, centerOffset.Y, 0) / 40000; + } + } + + public override void UpdateMap(Map map) + { + base.UpdateMap(map); + + Color color = defaultEnvironmentColor; + + if (!Playing && Cover != null) + { + Image coverImage = Cover.GetImage(); + + if (coverImage.IsCompressed()) + { + return; + } + + Vector3 avg = Vector3.Zero; + int pixelCount = 0; + + for (int x = 0; x < coverImage.GetWidth(); x++) + { + for (int y = 0; y < coverImage.GetHeight(); y++) + { + Color pixel = coverImage.GetPixel(x, y); + + if (pixel.A == 0) + { + continue; + } + + avg += new Vector3(pixel.R, pixel.G, pixel.B); + pixelCount++; + } + } + + avg /= pixelCount; + color = new(avg.X, avg.Y, avg.Z); + } + + updateColor(color); + } + + private void updateColor(Color color) + { + Color darkened = color.Darkened(0.9f); + + WorldEnvironment.Environment.BackgroundColor = Playing ? darkened : (Cover != null ? darkened : defaultEnvironmentColor); + } +} diff --git a/scripts/spaces/Solid.cs.uid b/scripts/spaces/Solid.cs.uid new file mode 100644 index 0000000..af28d34 --- /dev/null +++ b/scripts/spaces/Solid.cs.uid @@ -0,0 +1 @@ +uid://2onud88s5nkr