add world position properties to LdtkLevel and update scene builder
This commit is contained in:
@@ -52,10 +52,6 @@ public partial class LdtkResourceImporter : EditorImportPlugin
|
||||
var scene = new PackedScene();
|
||||
scene.Pack(rootNode);
|
||||
|
||||
var newSceneNodeCount = scene.GetState().GetNodeCount();
|
||||
|
||||
GD.Print($"New scene node count: {newSceneNodeCount}, expected: {rootNode.GetChildCount() + 1} (including root)");
|
||||
|
||||
// 4. Save the generated scene
|
||||
var destinationPath = $"{savePath}.{_GetSaveExtension()}";
|
||||
var error = ResourceSaver.Save(scene, destinationPath);
|
||||
|
@@ -34,7 +34,6 @@ public class LdtkSceneBuilder
|
||||
return root;
|
||||
}
|
||||
|
||||
// A helper function to recursively set the owner on all children.
|
||||
private void SetOwnerRecursive(Node node, Node owner)
|
||||
{
|
||||
foreach (var child in node.GetChildren())
|
||||
@@ -47,6 +46,7 @@ public class LdtkSceneBuilder
|
||||
private Node2D BuildLevel(LdtkLevel level)
|
||||
{
|
||||
var levelRoot = new Node2D { Name = level.Identifier };
|
||||
levelRoot.Position = new Vector2(level.WorldX, level.WorldY);
|
||||
|
||||
foreach (var layer in level.LayerInstances.Reverse())
|
||||
{
|
||||
|
@@ -6,6 +6,12 @@ public class LdtkLevel
|
||||
{
|
||||
[JsonPropertyName("identifier")]
|
||||
public string Identifier { get; set; }
|
||||
|
||||
[JsonPropertyName("worldX")]
|
||||
public int WorldX { get; set; }
|
||||
|
||||
[JsonPropertyName("worldY")]
|
||||
public int WorldY { get; set; }
|
||||
|
||||
[JsonPropertyName("layerInstances")]
|
||||
public LdtkLayerInstance[] LayerInstances { get; set; }
|
||||
|
Reference in New Issue
Block a user