Added robot asset and worked on placeholders. Placeholders are now able to be added to the game and later replaced by objects (Tested with Robot for now)

This commit is contained in:
=
2026-04-24 18:02:21 +02:00
parent 53361ba637
commit f7f5a637d5
9 changed files with 87 additions and 1 deletions
+18 -1
View File
@@ -1,12 +1,12 @@
using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
using static GameData;
public partial class World : Node3D
{
public Dictionary<string, MeshInstance3D> tileMeshes;
public Dictionary<string, List<Placeholder>> tilePlaceholders;
PackedScene layerPrefab = ResourceLoader.LoadLayerPrefab();
private Dictionary<string, MultiMeshInstance3D> multiMeshes = new();
private Dictionary<string, Mesh> meshLibrary = new();
@@ -17,8 +17,14 @@ public partial class World : Node3D
{
WFC.FillAdjacencies();
tileMeshes = ResourceLoader.LoadTiles();
tilePlaceholders = new Dictionary<string, List<Placeholder>>();
foreach (var kvp in tileMeshes)
{
tilePlaceholders.Add(kvp.Key, new List<Placeholder>());
foreach (MeshInstance3D child in kvp.Value.GetChildren())
{
tilePlaceholders[kvp.Key].Add(new Placeholder(child.Name, child.Transform.Origin));
}
var temp = kvp.Value;
meshLibrary[kvp.Key] = temp.Mesh;
temp.QueueFree();
@@ -97,6 +103,7 @@ public partial class World : Node3D
foreach (var kvp in batches)
{
MultiMesh mm = multiMeshes[kvp.Key].Multimesh;
List<Placeholder> placeholders = tilePlaceholders[kvp.Key];
List<Transform3D> list = kvp.Value;
mm.InstanceCount = list.Count;
@@ -104,6 +111,16 @@ public partial class World : Node3D
for (int i = 0; i < list.Count; i++)
{
mm.SetInstanceTransform(i, list[i]);
if (placeholders.Count > 0)
{
Node3D robot;
foreach (Placeholder placeholder in placeholders)
{
robot = ResourceLoader.LoadRobotPrefab().Instantiate<Node3D>();
robot.Position = placeholder.pos + list[i].Origin;
AddChild(robot);
}
}
}
}
}