implements PLN-0005
This commit is contained in:
parent
d0777cf2ba
commit
da79d61e9f
@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Editor.GON.WorldEditor;
|
||||||
|
using Intrepid.Gameplay.Journey;
|
||||||
using Intrepid.Utilities;
|
using Intrepid.Utilities;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -55,6 +57,8 @@ namespace Editor.GON.StageEditor
|
|||||||
public float floorHeight = 6f;
|
public float floorHeight = 6f;
|
||||||
public int activeFloorIndex;
|
public int activeFloorIndex;
|
||||||
|
|
||||||
|
public StageWorldSyncData worldSync = new();
|
||||||
|
|
||||||
public List<StageFloorDefinition> floors = new();
|
public List<StageFloorDefinition> floors = new();
|
||||||
public List<StageObjectDefinition> objects = new();
|
public List<StageObjectDefinition> objects = new();
|
||||||
|
|
||||||
@ -71,6 +75,9 @@ namespace Editor.GON.StageEditor
|
|||||||
|
|
||||||
public void EnsureDefaults()
|
public void EnsureDefaults()
|
||||||
{
|
{
|
||||||
|
worldSync ??= new StageWorldSyncData();
|
||||||
|
worldSync.EnsureDefaults();
|
||||||
|
|
||||||
floors ??= new List<StageFloorDefinition>();
|
floors ??= new List<StageFloorDefinition>();
|
||||||
objects ??= new List<StageObjectDefinition>();
|
objects ??= new List<StageObjectDefinition>();
|
||||||
|
|
||||||
@ -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<JWorldTile> worldTiles = new();
|
||||||
|
public List<StageWorldSyncEndpoint> expectedEndpoints = new();
|
||||||
|
public string syncedAt;
|
||||||
|
public int contractVersion = 1;
|
||||||
|
public string contractHash;
|
||||||
|
|
||||||
|
public bool HasSync => !string.IsNullOrEmpty(worldStageId);
|
||||||
|
|
||||||
|
public void EnsureDefaults()
|
||||||
|
{
|
||||||
|
worldTiles ??= new List<JWorldTile>();
|
||||||
|
expectedEndpoints ??= new List<StageWorldSyncEndpoint>();
|
||||||
|
|
||||||
|
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]
|
[Serializable]
|
||||||
public sealed class StageFloorDefinition
|
public sealed class StageFloorDefinition
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user