Added new Tileset (Better walls and floors) and reworked layer generation. Working on placeholders next again (Need to fix rotation)

This commit is contained in:
=
2026-04-27 15:17:08 +02:00
parent b3645b80f0
commit 3060d3d6f7
11 changed files with 184 additions and 105 deletions
+62 -1
View File
@@ -10,7 +10,10 @@ public partial class Tile
Random rand = new Random();
public Vector3 Position;
public Vector2I GridPosition;
public Node3D DecorationNode;
public Node3D ContentNode;
public bool containsLight, containsDecoration, containsResource;
public void SetMeshes(Dictionary<string, MeshInstance3D> tileMeshes)
{
@@ -71,4 +74,62 @@ public partial class Tile
collapsedMesh = null;
SetMeshes(tileMeshes);
}
public void SpawnContent(Dictionary<string, MeshInstance3D> contentMeshes, Transform3D transform, List<Placeholder> placeholders)
{
foreach (Placeholder placeholder in placeholders)
{
if (containsLight && placeholder.name.ToLower() == "light") SpawnLight(contentMeshes["light"], placeholder, transform);
else if (containsResource && placeholder.name.ToLower() == "resource") SpawnResource(contentMeshes["resource"], placeholder, transform);
else if (containsDecoration) SpawnDecorations(contentMeshes, placeholder, transform);
}
}
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()
{
OmniAttenuation = 2f,
LightColor = new Color("#eae7ad"),
ShadowEnabled = true,
LightEnergy = 5f,
LightIndirectEnergy = 1.5f,
Position = new Vector3(0.5f, 0, 0)
});
ContentNode.AddChild(light);
light.LookAt(light.Position + forward, Vector3.Up);
}
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);
}
private void SpawnDecorations(Dictionary<string, MeshInstance3D> contentMeshes, Placeholder placeholder, Transform3D transform)
{
foreach (string key in contentMeshes.Keys)
{
if (key.ToLower() != placeholder.name.ToLower()) continue;
MeshInstance3D decoration = new MeshInstance3D
{
Mesh = contentMeshes[key].Mesh,
Position = placeholder.transform.Origin
};
ContentNode.AddChild(decoration);
}
}
}