diff --git a/Assets/Objects/Robot.glb b/Assets/Objects/Robot.glb new file mode 100644 index 0000000..943d273 Binary files /dev/null and b/Assets/Objects/Robot.glb differ diff --git a/Assets/Objects/Robot.glb.import b/Assets/Objects/Robot.glb.import new file mode 100644 index 0000000..ff18b2b --- /dev/null +++ b/Assets/Objects/Robot.glb.import @@ -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 diff --git a/Assets/Objects/Tiles.glb b/Assets/Objects/Tiles.glb index 8bd83f4..37cb6f3 100644 Binary files a/Assets/Objects/Tiles.glb and b/Assets/Objects/Tiles.glb differ diff --git a/Prefabs/Robot.tscn b/Prefabs/Robot.tscn new file mode 100644 index 0000000..a1faeac --- /dev/null +++ b/Prefabs/Robot.tscn @@ -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")] diff --git a/Scripts/Helpers/Placeholder.cs b/Scripts/Helpers/Placeholder.cs new file mode 100644 index 0000000..1923ac0 --- /dev/null +++ b/Scripts/Helpers/Placeholder.cs @@ -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}"); + } +} \ No newline at end of file diff --git a/Scripts/Helpers/Placeholder.cs.uid b/Scripts/Helpers/Placeholder.cs.uid new file mode 100644 index 0000000..f977150 --- /dev/null +++ b/Scripts/Helpers/Placeholder.cs.uid @@ -0,0 +1 @@ +uid://cng1pe6j20vrr diff --git a/Scripts/Helpers/ResourceLoader.cs b/Scripts/Helpers/ResourceLoader.cs index 802bc76..e6a395c 100644 --- a/Scripts/Helpers/ResourceLoader.cs +++ b/Scripts/Helpers/ResourceLoader.cs @@ -9,6 +9,11 @@ public partial class ResourceLoader { return GD.Load($"res://Prefabs/Layer.tscn"); } + + public static PackedScene LoadRobotPrefab() + { + return GD.Load($"res://Prefabs/Robot.tscn"); + } public static Dictionary LoadTiles() { diff --git a/Scripts/Helpers/WFC.cs b/Scripts/Helpers/WFC.cs index a15f6a3..ee13d75 100644 --- a/Scripts/Helpers/WFC.cs +++ b/Scripts/Helpers/WFC.cs @@ -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 }; diff --git a/Scripts/World.cs b/Scripts/World.cs index 859f4b7..1be8cef 100644 --- a/Scripts/World.cs +++ b/Scripts/World.cs @@ -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 tileMeshes; + public Dictionary> tilePlaceholders; PackedScene layerPrefab = ResourceLoader.LoadLayerPrefab(); private Dictionary multiMeshes = new(); private Dictionary meshLibrary = new(); @@ -17,8 +17,14 @@ public partial class World : Node3D { WFC.FillAdjacencies(); tileMeshes = ResourceLoader.LoadTiles(); + tilePlaceholders = new Dictionary>(); foreach (var kvp in tileMeshes) { + tilePlaceholders.Add(kvp.Key, new List()); + 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 placeholders = tilePlaceholders[kvp.Key]; List 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(); + robot.Position = placeholder.pos + list[i].Origin; + AddChild(robot); + } + } } } }