Fixed light and object placement.

This commit is contained in:
=
2026-04-27 17:46:56 +02:00
parent 3060d3d6f7
commit 6a7f4690f2
8 changed files with 67 additions and 16 deletions
+11 -4
View File
@@ -1,14 +1,21 @@
using Godot;
public partial class GameData
{
//Amount of layers generated
public static int ruinSize = 10;
//Width+Height of layers
public static int layerSize = 20;
//Current layer the player wants to see
public static int currentLayer = 0;
//The layer that is currently visible
public static int visibleLayer = 0;
//Determines if the player can move the camera or not (Necessary for input and options menu)
public static bool canMove = true;
//--- PLAYER ADJUSTABLE VALUES ---
//Color used in primary objects (e.g. Robots)
public static Color primaryColor = new Color("#276ac2");
//Color used in lights
public static Color lightColor = new Color("#7efff5");
//Amount of layers generated
public static int ruinSize = 10;
//Width+Height of layers
public static int layerSize = 20;
}
+9 -7
View File
@@ -88,23 +88,25 @@ public partial class Tile
private void SpawnLight(MeshInstance3D lightMesh, Placeholder placeholder, Transform3D transform)
{
Vector3 forward = (transform.Origin - placeholder.transform.Origin).Normalized();
MeshInstance3D light = new MeshInstance3D
{
Mesh = lightMesh.Mesh,
Position = placeholder.transform.Origin
};
light.AddChild(new OmniLight3D()
OmniLight3D lightSource = new OmniLight3D()
{
OmniAttenuation = 2f,
LightColor = new Color("#eae7ad"),
LightColor = GameData.lightColor,
ShadowEnabled = true,
LightEnergy = 5f,
LightEnergy = 100f,
LightIndirectEnergy = 1.5f,
Position = new Vector3(0.5f, 0, 0)
});
OmniRange = 20f,
Position = placeholder.transform.Origin
};
lightSource.Position.MoveToward(transform.Origin, 0.1f);
light.AddChild(lightSource);
ContentNode.AddChild(light);
light.LookAt(light.Position + forward, Vector3.Up);
light.LookAt(transform.Origin, Vector3.Up);
}
private void SpawnResource(MeshInstance3D resourceMesh, Placeholder placeholder, Transform3D transform)
+2 -2
View File
@@ -30,7 +30,7 @@ public partial class World : Node3D
foreach (var kvp in tileMeshes)
{
tilePlaceholders[kvp.Key] = new List<Placeholder>();
foreach (MeshInstance3D child in kvp.Value.GetChildren())
foreach (Node3D child in kvp.Value.GetChildren())
{
tilePlaceholders[kvp.Key].Add(new Placeholder(child.Name, child.Transform));
}
@@ -141,7 +141,7 @@ public partial class World : Node3D
int posX, posY;
while(currentLight < layerSize * 2)
while(currentLight < layerSize * layerSize / 2)
{
posX = rand.Next(layerSize);
posY = rand.Next(layerSize);