Refactored code to be better separated (Rendering, Logic)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user