Added decoration assets and placement. Currently all placeholders are replaced, need to implement a chance based system.
This commit is contained in:
+23
-6
@@ -1,11 +1,13 @@
|
||||
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, MeshInstance3D> decorationMeshes;
|
||||
public Dictionary<string, List<Placeholder>> tilePlaceholders;
|
||||
PackedScene layerPrefab = ResourceLoader.LoadLayerPrefab();
|
||||
private Dictionary<string, MultiMeshInstance3D> multiMeshes = new();
|
||||
@@ -17,6 +19,7 @@ public partial class World : Node3D
|
||||
{
|
||||
WFC.FillAdjacencies();
|
||||
tileMeshes = ResourceLoader.LoadTiles();
|
||||
decorationMeshes = ResourceLoader.LoadDecorations();
|
||||
tilePlaceholders = new Dictionary<string, List<Placeholder>>();
|
||||
foreach (var kvp in tileMeshes)
|
||||
{
|
||||
@@ -113,13 +116,27 @@ public partial class World : Node3D
|
||||
mm.SetInstanceTransform(i, list[i]);
|
||||
if (placeholders.Count > 0)
|
||||
{
|
||||
Node3D robot;
|
||||
foreach (Placeholder placeholder in placeholders)
|
||||
Node3D decoration;
|
||||
|
||||
Mesh mesh = decorationMeshes.Values.ToList()[0].Mesh;
|
||||
for(int j = 0; j < placeholders.Count; j++)
|
||||
{
|
||||
robot = ResourceLoader.LoadRobotPrefab().Instantiate<Node3D>();
|
||||
robot.Position = placeholder.pos + list[i].Origin;
|
||||
AddChild(robot);
|
||||
}
|
||||
foreach (MeshInstance3D meshes in decorationMeshes.Values)
|
||||
{
|
||||
if (meshes.Name.ToString().ToLower() == placeholders[j].name.ToLower())
|
||||
{
|
||||
mesh = meshes.Mesh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
decoration = new MeshInstance3D();
|
||||
(decoration as MeshInstance3D).Mesh = mesh;
|
||||
decoration.Transform = list[i];
|
||||
decoration.Position += placeholders[j].pos;
|
||||
decoration.Name = placeholders[j].name + j;
|
||||
decoration.Rotate(Vector3.Up, Mathf.DegToRad(-90));
|
||||
layer.AddChild(decoration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user