47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using Godot;
|
|
using System;
|
|
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;
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
} |