Refactored code to be better separated (Rendering, Logic)

This commit is contained in:
=
2026-04-26 11:33:54 +02:00
parent 798fe23bb6
commit c80367dccd
9 changed files with 191 additions and 85 deletions
+48
View File
@@ -0,0 +1,48 @@
using Godot;
using System.Collections.Generic;
public class DecorationHandler
{
public static void Spawn(List<TileRenderData> tiles, Dictionary<string, MeshInstance3D> decorationMeshes)
{
foreach (var data in tiles)
{
Node3D tileNode = data.Tile.DecorationNode;
foreach (var placeholder in data.Placeholders)
{
string key = placeholder.name.ToLower();
var decoration = new MeshInstance3D();
if (decorationMeshes.ContainsKey(key))
{
decoration.Mesh = decorationMeshes[key].Mesh;
}
else
{
continue;
}
decoration.Position = placeholder.pos;
decoration.Rotate(Vector3.Up, Mathf.DegToRad(-90));
if (key == "light")
{
decoration.AddChild(new OmniLight3D()
{
OmniAttenuation = 2f,
LightColor = new Color("#eae7ad"),
ShadowEnabled = true,
LightEnergy = 5f,
LightIndirectEnergy = 1.5f,
Position = new Vector3(0.5f, 0, 0)
});
}
tileNode.AddChild(decoration);
}
}
}
}