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:
Binary file not shown.
@@ -0,0 +1,42 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://bccs6xik7xv8s"
|
||||
path="res://.godot/imported/Robot.glb-0808b8534e7a8abc9f0bb2bb7f5abb78.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Assets/Objects/Robot.glb"
|
||||
dest_files=["res://.godot/imported/Robot.glb-0808b8534e7a8abc9f0bb2bb7f5abb78.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/root_script=null
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_name_suffixes=true
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
materials/extract=0
|
||||
materials/extract_format=0
|
||||
materials/extract_path=""
|
||||
_subresources={}
|
||||
gltf/naming_version=2
|
||||
gltf/embedded_image_handling=1
|
||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
[gd_scene format=3 uid="uid://cjae60v4c60vb"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bccs6xik7xv8s" path="res://Assets/Objects/Robot.glb" id="1_8peeh"]
|
||||
|
||||
[node name="Robot" unique_id=1113392384 instance=ExtResource("1_8peeh")]
|
||||
@@ -0,0 +1,13 @@
|
||||
using Godot;
|
||||
|
||||
public class Placeholder
|
||||
{
|
||||
string name;
|
||||
public Vector3 pos;
|
||||
|
||||
public Placeholder(string name, Vector3 pos){
|
||||
this.name = name;
|
||||
this.pos = pos;
|
||||
GD.Print($"Generated placeholder {this.name}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cng1pe6j20vrr
|
||||
@@ -9,6 +9,11 @@ public partial class ResourceLoader
|
||||
{
|
||||
return GD.Load<PackedScene>($"res://Prefabs/Layer.tscn");
|
||||
}
|
||||
|
||||
public static PackedScene LoadRobotPrefab()
|
||||
{
|
||||
return GD.Load<PackedScene>($"res://Prefabs/Robot.tscn");
|
||||
}
|
||||
|
||||
public static Dictionary<string, MeshInstance3D> LoadTiles()
|
||||
{
|
||||
|
||||
@@ -53,6 +53,7 @@ public class WFC
|
||||
["corner_down_right"] = new() { Direction.Down, Direction.Right },
|
||||
|
||||
["junction"] = new() { Direction.Up, Direction.Down, Direction.Left, Direction.Right },
|
||||
["gate"] = new() { Direction.Up, Direction.Down, Direction.Left, Direction.Right },
|
||||
|
||||
["border"] = new() { }
|
||||
};
|
||||
@@ -78,6 +79,8 @@ public class WFC
|
||||
["end_left"] = 0.2f,
|
||||
["end_right"] = 0.3f,
|
||||
|
||||
["gate"] = 0.1f,
|
||||
|
||||
["border"] = 0.0f
|
||||
};
|
||||
|
||||
|
||||
+18
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user