Added basic light controls to the game and added more content spawnpoints. Adjusted values a bit.

This commit is contained in:
=
2026-04-27 19:35:21 +02:00
parent 6a7f4690f2
commit 92a86c13b7
8 changed files with 34 additions and 4 deletions
Binary file not shown.
Binary file not shown.
+7
View File
@@ -96,6 +96,11 @@ text = "19:20"
fit_content = true
autowrap_mode = 0
[node name="LightColor" type="ColorPickerButton" parent="Control/MainUI/HeaderContainer/Header" unique_id=395026790]
layout_mode = 2
theme_override_colors/font_color = Color(1, 1, 1, 1)
text = "Choose Color..."
[node name="Content" type="Control" parent="Control/MainUI" unique_id=45665557]
layout_mode = 2
size_flags_vertical = 3
@@ -138,3 +143,5 @@ layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/separation = 10
[connection signal="color_changed" from="Control/MainUI/HeaderContainer/Header/LightColor" to="Control" method="ChangeColor"]
+15
View File
@@ -0,0 +1,15 @@
using Godot;
using System.Collections.Generic;
public class LightHandler
{
public static List<OmniLight3D> lights = new ();
public static void RedrawLights(Color color)
{
foreach(OmniLight3D light in lights)
{
light.LightColor = color;
}
}
}
+1
View File
@@ -0,0 +1 @@
uid://b150nxl3cc3ck
+7 -1
View File
@@ -4,7 +4,7 @@ public partial class UIHandler : Control
{
public override void _Ready()
{
GetNode<ColorPickerButton>("./MainUI/HeaderContainer/Header/LightColor").Color = GameData.lightColor;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -13,4 +13,10 @@ public partial class UIHandler : Control
}
public void ChangeColor(Color color)
{
GameData.lightColor = color;
LightHandler.RedrawLights(color);
}
}
+3 -2
View File
@@ -104,6 +104,7 @@ public partial class Tile
Position = placeholder.transform.Origin
};
lightSource.Position.MoveToward(transform.Origin, 0.1f);
LightHandler.lights.Add(lightSource);
light.AddChild(lightSource);
ContentNode.AddChild(light);
light.LookAt(transform.Origin, Vector3.Up);
@@ -111,14 +112,13 @@ public partial class Tile
private void SpawnResource(MeshInstance3D resourceMesh, Placeholder placeholder, Transform3D transform)
{
Vector3 forward = (transform.Origin - placeholder.transform.Origin).Normalized();
MeshInstance3D resource = new MeshInstance3D
{
Mesh = resourceMesh.Mesh,
Position = placeholder.transform.Origin
};
ContentNode.AddChild(resource);
resource.LookAt(resource.Position + forward, Vector3.Up);
resource.LookAt(transform.Origin, Vector3.Up);
}
private void SpawnDecorations(Dictionary<string, MeshInstance3D> contentMeshes, Placeholder placeholder, Transform3D transform)
@@ -132,6 +132,7 @@ public partial class Tile
Position = placeholder.transform.Origin
};
ContentNode.AddChild(decoration);
decoration.LookAt(transform.Origin, Vector3.Up);
}
}
}
+1 -1
View File
@@ -141,7 +141,7 @@ public partial class World : Node3D
int posX, posY;
while(currentLight < layerSize * layerSize / 2)
while(currentLight < layerSize * layerSize / 4)
{
posX = rand.Next(layerSize);
posY = rand.Next(layerSize);