From da79d61e9fb1d98c5be5256cbf291f7e511b218c Mon Sep 17 00:00:00 2001 From: Nilton Constantino Date: Sun, 21 Jun 2026 08:27:44 +0100 Subject: [PATCH] implements PLN-0005 --- .../Editor/GON/StageEditor/StageDefinition.cs | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/Assets/Scripts/Editor/GON/StageEditor/StageDefinition.cs b/Assets/Scripts/Editor/GON/StageEditor/StageDefinition.cs index 213a571..f0e3eae 100644 --- a/Assets/Scripts/Editor/GON/StageEditor/StageDefinition.cs +++ b/Assets/Scripts/Editor/GON/StageEditor/StageDefinition.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using Editor.GON.WorldEditor; +using Intrepid.Gameplay.Journey; using Intrepid.Utilities; using UnityEngine; @@ -55,6 +57,8 @@ namespace Editor.GON.StageEditor public float floorHeight = 6f; public int activeFloorIndex; + public StageWorldSyncData worldSync = new(); + public List floors = new(); public List objects = new(); @@ -71,6 +75,9 @@ namespace Editor.GON.StageEditor public void EnsureDefaults() { + worldSync ??= new StageWorldSyncData(); + worldSync.EnsureDefaults(); + floors ??= new List(); objects ??= new List(); @@ -141,6 +148,86 @@ namespace Editor.GON.StageEditor } } + [Serializable] + public sealed class StageWorldSyncData + { + public string worldLayoutId; + public string worldStageId; + public string worldStageDisplayName; + public WorldStageKind worldStageKind; + public int worldLayer; + public float worldTileSize = 24f; + public float worldLayerHeight = 24f; + public List worldTiles = new(); + public List expectedEndpoints = new(); + public string syncedAt; + public int contractVersion = 1; + public string contractHash; + + public bool HasSync => !string.IsNullOrEmpty(worldStageId); + + public void EnsureDefaults() + { + worldTiles ??= new List(); + expectedEndpoints ??= new List(); + + if (worldTileSize <= 0f) + { + worldTileSize = 24f; + } + + if (worldLayerHeight <= 0f) + { + worldLayerHeight = 24f; + } + + if (contractVersion <= 0) + { + contractVersion = 1; + } + } + + public bool TryGetWorldBounds(out RectInt bounds) + { + EnsureDefaults(); + if (worldTiles.Count == 0) + { + bounds = default; + return false; + } + + var minX = worldTiles[0].x; + var maxX = worldTiles[0].x; + var minY = worldTiles[0].y; + var maxY = worldTiles[0].y; + + for (var i = 1; i < worldTiles.Count; i++) + { + var tile = worldTiles[i]; + minX = Mathf.Min(minX, tile.x); + maxX = Mathf.Max(maxX, tile.x); + minY = Mathf.Min(minY, tile.y); + maxY = Mathf.Max(maxY, tile.y); + } + + bounds = new RectInt(minX, minY, maxX - minX + 1, maxY - minY + 1); + return true; + } + } + + [Serializable] + public sealed class StageWorldSyncEndpoint + { + public string endpointId; + public JEndpointKind kind; + public JWorldTile worldTile; + public JSocketFace socketFace; + public bool required; + public string connectionId; + public string connectedEndpointId; + public string debugLabel; + } + [Serializable] public sealed class StageFloorDefinition {