a few more adjustments on editor

This commit is contained in:
Nilton Constantino 2026-06-17 10:58:41 +01:00
parent 2a23d4cf9c
commit 575cef61a9
No known key found for this signature in database
16 changed files with 23501 additions and 11061 deletions

View File

@ -16,3 +16,7 @@ MonoBehaviour:
groundRampFrontPrefab: {fileID: 116909126457648545, guid: 321f39f98806c4db7a3deff6d508bde1, type: 3}
groundRampLeftPrefab: {fileID: 1762350532007512996, guid: 378324f09bdf84db99e602efb4b23fa3, type: 3}
groundRampRightPrefab: {fileID: 778490509801794073, guid: d5e0f7c6e96fe4425a061863751bc639, type: 3}
groundStairFrontPrefab: {fileID: 2575929596551944822, guid: da66eef8ff1ce4c3eaf46c09ad26e70b, type: 3}
groundStairLeftPrefab: {fileID: 958614158403849092, guid: c11973af2c21642658a917c1253a53f4, type: 3}
groundStairRightPrefab: {fileID: 6846527267379064316, guid: 3e0d56cfe99b4417a8f7c924adc9581e, type: 3}
obstacleWallPrefab: {fileID: 7180750725527117791, guid: 8c7930f2bdde349c8a3ae496a29eecd8, type: 3}

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3020532133659471693, guid: 64620cfd283d648b5b4d9c9a4fac7751, type: 3}
propertyPath: m_Size.x
value: 3
value: 2
objectReference: {fileID: 0}
- target: {fileID: 3020532133659471693, guid: 64620cfd283d648b5b4d9c9a4fac7751, type: 3}
propertyPath: m_Size.y
@ -22,7 +22,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3020532133659471693, guid: 64620cfd283d648b5b4d9c9a4fac7751, type: 3}
propertyPath: m_Size.z
value: 3.5
value: 2.25
objectReference: {fileID: 0}
- target: {fileID: 3020532133659471693, guid: 64620cfd283d648b5b4d9c9a4fac7751, type: 3}
propertyPath: m_Center.x
@ -30,7 +30,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3020532133659471693, guid: 64620cfd283d648b5b4d9c9a4fac7751, type: 3}
propertyPath: m_Center.z
value: 0.25
value: 0.125
objectReference: {fileID: 0}
- target: {fileID: 5094209182163755379, guid: 64620cfd283d648b5b4d9c9a4fac7751, type: 3}
propertyPath: m_Enabled
@ -114,13 +114,13 @@ MonoBehaviour:
sizeX: 1
sizeY: 3
sizeZ: 1
offset_x: {x: 1, y: 1}
offset_y: {x: 1.5, y: 1}
offset_x: {x: 0.5, y: 0.5}
offset_y: {x: 0.75, y: 0.5}
x: 1
y: 3
z: 1
contact_offset_x: {x: 1, y: 1}
contact_offset_y: {x: 1.5, y: 1}
contact_offset_x: {x: 0.5, y: 0.5}
contact_offset_y: {x: 0.75, y: 0.5}
--- !u!114 &8402728050198132523 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3563105585321411375, guid: 64620cfd283d648b5b4d9c9a4fac7751, type: 3}

File diff suppressed because one or more lines are too long

View File

@ -21,10 +21,14 @@ namespace Editor.GardensStageEditor.Baker
{
foreach (var stageFloorDefinition in request.Stage.floors)
{
var cellsGS = new HashSet<Vector2Int>();
var cellsGRF = new HashSet<Vector2Int>();
var cellsGRR = new HashSet<Vector2Int>();
var cellsGRL = new HashSet<Vector2Int>();
var cellsG = new HashSet<Vector2Int>();
var cellsRF = new HashSet<Vector2Int>();
var cellsRR = new HashSet<Vector2Int>();
var cellsRL = new HashSet<Vector2Int>();
var cellsSF = new HashSet<Vector2Int>();
var cellsSR = new HashSet<Vector2Int>();
var cellsSL = new HashSet<Vector2Int>();
var cellsOW = new HashSet<Vector2Int>();
foreach (var logicalCell in stageFloorDefinition.Cells)
{
@ -32,19 +36,29 @@ namespace Editor.GardensStageEditor.Baker
{
case StructuralCellKind.Empty:
break;
case StructuralCellKind.Ground_Slab:
cellsGS.Add(new Vector2Int(logicalCell.x, logicalCell.y));
case StructuralCellKind.Ground:
cellsG.Add(new Vector2Int(logicalCell.x, logicalCell.y));
break;
case StructuralCellKind.Ground_Ramp_Front:
cellsGRF.Add(new Vector2Int(logicalCell.x, logicalCell.y));
case StructuralCellKind.Ramp_Front:
cellsRF.Add(new Vector2Int(logicalCell.x, logicalCell.y));
break;
case StructuralCellKind.Ground_Ramp_Left:
cellsGRL.Add(new Vector2Int(logicalCell.x, logicalCell.y));
case StructuralCellKind.Ramp_Left:
cellsRL.Add(new Vector2Int(logicalCell.x, logicalCell.y));
break;
case StructuralCellKind.Ground_Ramp_Right:
cellsGRR.Add(new Vector2Int(logicalCell.x, logicalCell.y));
case StructuralCellKind.Ramp_Right:
cellsRR.Add(new Vector2Int(logicalCell.x, logicalCell.y));
break;
case StructuralCellKind.Stair_Front:
cellsSF.Add(new Vector2Int(logicalCell.x, logicalCell.y));
break;
case StructuralCellKind.Stair_Left:
cellsSL.Add(new Vector2Int(logicalCell.x, logicalCell.y));
break;
case StructuralCellKind.Stair_Right:
cellsSR.Add(new Vector2Int(logicalCell.x, logicalCell.y));
break;
case StructuralCellKind.Wall:
cellsOW.Add(new Vector2Int(logicalCell.x, logicalCell.y));
break;
default:
throw new ArgumentOutOfRangeException();
@ -63,27 +77,51 @@ namespace Editor.GardensStageEditor.Baker
InstantiateGround(
request.PrefabTable.GroundSlabPrefab,
floorRootTransform,
cellsGS,
cellsG,
StraightAddressSize
);
);
InstantiateGround(
request.PrefabTable.GroundRampFrontPrefab,
floorRootTransform,
cellsGRF,
cellsRF,
StraightAddressSize
);
);
InstantiateGround(
request.PrefabTable.GroundRampLeftPrefab,
floorRootTransform,
cellsGRL,
cellsRL,
InverseAddressSize
);
);
InstantiateGround(
request.PrefabTable.GroundRampRightPrefab,
floorRootTransform,
cellsGRR,
cellsRR,
InverseAddressSize
);
);
InstantiateGround(
request.PrefabTable.GroundStairFrontPrefab,
floorRootTransform,
cellsSF,
StraightAddressSize
);
InstantiateGround(
request.PrefabTable.GroundStairLeftPrefab,
floorRootTransform,
cellsSL,
InverseAddressSize
);
InstantiateGround(
request.PrefabTable.GroundStairRightPrefab,
floorRootTransform,
cellsSR,
InverseAddressSize
);
InstantiateObstacle(
request.PrefabTable.ObstacleWallPrefab,
floorRootTransform,
cellsOW,
StraightAddressSize
);
}
}
@ -97,9 +135,9 @@ namespace Editor.GardensStageEditor.Baker
return new Vector2Int(rect.height, rect.width);
}
private static void InstantiateGround<G>(
G prefab, Transform parent,
G prefab,
Transform parent,
HashSet<Vector2Int> set,
Func<RectInt, Vector2Int> addressSize
) where G: GroundModelPrototype
@ -131,5 +169,40 @@ namespace Editor.GardensStageEditor.Baker
g.SetSize(addressSize(rect));
}
}
private static void InstantiateObstacle<O>(
O prefab,
Transform parent,
HashSet<Vector2Int> set,
Func<RectInt, Vector2Int> addressSize
) where O: ObstacleModelPrototype
{
var releaseName = new string(typeof(O).Name.Where(char.IsUpper).ToArray());
if (prefab.IsNull())
{
DLogger.LogError($"Prefab is not configured in PrefabTable: {releaseName}");
return;
}
foreach (var rect in StageBuilderHelpers.BuildRectanglesFromCellsBest(set))
{
if (PrefabUtility.InstantiatePrefab(prefab, parent) is not O o)
{
DLogger.LogError($"Failed to instantiate prefab: {prefab.name}");
continue;
}
StageBuilderHelpers.ResetTransform(o.transform);
o.name = $"{releaseName} ({rect.x}, {rect.y}) {rect.width}x{rect.height}";
o.transform.localPosition = new Vector3(
rect.x + (rect.width - 1) * 0.5f,
0,
-(rect.y + (rect.height - 1) * 0.5f)
);
o.SetSize(addressSize(rect));
}
}
}
}

View File

@ -11,10 +11,18 @@ namespace Editor.GardensStageEditor
[GroupInjections, SerializeField] private GroundRampModelPrototype groundRampFrontPrefab;
[GroupInjections, SerializeField] private GroundRampModelPrototype groundRampLeftPrefab;
[GroupInjections, SerializeField] private GroundRampModelPrototype groundRampRightPrefab;
[GroupInjections, SerializeField] private GroundStairModelPrototype groundStairFrontPrefab;
[GroupInjections, SerializeField] private GroundStairModelPrototype groundStairLeftPrefab;
[GroupInjections, SerializeField] private GroundStairModelPrototype groundStairRightPrefab;
[GroupInjections, SerializeField] private ObstacleWallModelPrototype obstacleWallPrefab;
public GroundSlabModelPrototype GroundSlabPrefab => groundSlabPrefab;
public GroundRampModelPrototype GroundRampFrontPrefab => groundRampFrontPrefab;
public GroundRampModelPrototype GroundRampLeftPrefab => groundRampLeftPrefab;
public GroundRampModelPrototype GroundRampRightPrefab => groundRampRightPrefab;
public GroundStairModelPrototype GroundStairFrontPrefab => groundStairFrontPrefab;
public GroundStairModelPrototype GroundStairLeftPrefab => groundStairLeftPrefab;
public GroundStairModelPrototype GroundStairRightPrefab => groundStairRightPrefab;
public ObstacleWallModelPrototype ObstacleWallPrefab => obstacleWallPrefab;
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using Intrepid.Utilities;
using UnityEditor.ShaderGraph.Internal;
using UnityEngine;
namespace Editor.GardensStageEditor
@ -17,12 +16,18 @@ namespace Editor.GardensStageEditor
public enum StructuralCellKind
{
Empty = 0,
Ground_Slab = 10,
Ground_Ramp_Front = 11,
Ground_Ramp_Left = 12,
Ground_Ramp_Right = 13,
Wall = 20,
Ground = 10,
Ramp_Front = 11,
Ramp_Left = 12,
Ramp_Right = 13,
Stair_Front = 14,
Stair_Left = 15,
Stair_Right = 16,
Wall = 50,
}
public enum StageObjectKind

View File

@ -28,10 +28,13 @@ namespace Editor.GardensStageEditor
{
return kind switch
{
StructuralCellKind.Ground_Slab => FromHtml("55E0FF"),
StructuralCellKind.Ground_Ramp_Front => FromHtml("55E0FF"),
StructuralCellKind.Ground_Ramp_Left => FromHtml("55E0FF"),
StructuralCellKind.Ground_Ramp_Right => FromHtml("55E0FF"),
StructuralCellKind.Ground => FromHtml("55E0FF"),
StructuralCellKind.Ramp_Front => FromHtml("55E0FF"),
StructuralCellKind.Ramp_Left => FromHtml("55E0FF"),
StructuralCellKind.Ramp_Right => FromHtml("55E0FF"),
StructuralCellKind.Stair_Front => FromHtml("668B93"),
StructuralCellKind.Stair_Left => FromHtml("668B93"),
StructuralCellKind.Stair_Right => FromHtml("668B93"),
StructuralCellKind.Wall => FromHtml("668B93"),
_ => new Color(0f, 0f, 0f, 0f)
};

View File

@ -595,13 +595,13 @@ namespace Editor.GardensStageEditor
switch (kind)
{
case StructuralCellKind.Ground_Slab:
case StructuralCellKind.Ground:
StrokeRect(p, inner, ink, line);
DrawLine(p, new Vector2(inner.xMin, inner.center.y), new Vector2(inner.xMax, inner.center.y), light,
line);
break;
case StructuralCellKind.Ground_Ramp_Front:
case StructuralCellKind.Ramp_Front:
FillTriangle(
p,
new Vector2(inner.xMin, inner.yMax),
@ -619,7 +619,7 @@ namespace Editor.GardensStageEditor
);
break;
case StructuralCellKind.Ground_Ramp_Left:
case StructuralCellKind.Ramp_Left:
FillTriangle(
p,
new Vector2(inner.xMax, inner.yMin),
@ -637,7 +637,61 @@ namespace Editor.GardensStageEditor
);
break;
case StructuralCellKind.Ground_Ramp_Right:
case StructuralCellKind.Ramp_Right:
FillTriangle(
p,
new Vector2(inner.xMin, inner.yMin),
new Vector2(inner.xMax, inner.center.y),
new Vector2(inner.xMin, inner.yMax),
light
);
StrokeTriangle(
p,
new Vector2(inner.xMin, inner.yMin),
new Vector2(inner.xMax, inner.center.y),
new Vector2(inner.xMin, inner.yMax),
ink,
line
);
break;
case StructuralCellKind.Stair_Front:
FillTriangle(
p,
new Vector2(inner.xMin, inner.yMax),
new Vector2(inner.xMax, inner.yMax),
new Vector2(inner.center.x, inner.yMin),
light
);
StrokeTriangle(
p,
new Vector2(inner.xMin, inner.yMax),
new Vector2(inner.xMax, inner.yMax),
new Vector2(inner.center.x, inner.yMin),
ink,
line
);
break;
case StructuralCellKind.Stair_Left:
FillTriangle(
p,
new Vector2(inner.xMax, inner.yMin),
new Vector2(inner.xMin, inner.center.y),
new Vector2(inner.xMax, inner.yMax),
light
);
StrokeTriangle(
p,
new Vector2(inner.xMax, inner.yMin),
new Vector2(inner.xMin, inner.center.y),
new Vector2(inner.xMax, inner.yMax),
ink,
line
);
break;
case StructuralCellKind.Stair_Right:
FillTriangle(
p,
new Vector2(inner.xMin, inner.yMin),

View File

@ -73,10 +73,16 @@ namespace Editor.GardensStageEditor
{
var entries = new List<StagePaletteEntry>
{
Structural("struct_ground_slab", "Ground - Slab", StructuralCellKind.Ground_Slab),
Structural("struct_ground_ramp_front", "Ground - RF", StructuralCellKind.Ground_Ramp_Front),
Structural("struct_ground_ramp_left", "Ground - RL", StructuralCellKind.Ground_Ramp_Left),
Structural("struct_ground_ramp_right", "Ground - RR", StructuralCellKind.Ground_Ramp_Right),
Structural("struct_ground_slab", "Ground", StructuralCellKind.Ground),
Structural("struct_ramp_front", "Ramp (Front)", StructuralCellKind.Ramp_Front),
Structural("struct_ramp_left", "Ramp (Left)", StructuralCellKind.Ramp_Left),
Structural("struct_ramp_right", "Ramp (Right)", StructuralCellKind.Ramp_Right),
Structural("struct_stair_front", "Stair (Front)", StructuralCellKind.Stair_Front),
Structural("struct_stair_left", "Stair (Left)", StructuralCellKind.Stair_Left),
Structural("struct_stair_right", "Stair (Right)", StructuralCellKind.Stair_Right),
Structural("struct_wall", "Wall", StructuralCellKind.Wall),
// leave it as last as possible

View File

@ -1,6 +0,0 @@
namespace Intrepid.Gameplay.Prototyping
{
public abstract class ContactModelPrototype : ModelPrototype
{
}
}

View File

@ -0,0 +1,9 @@
using UnityEngine;
namespace Intrepid.Gameplay.Prototyping
{
public abstract class ObstacleModelPrototype : ModelPrototype
{
public abstract void SetSize(Vector2Int size);
}
}

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Intrepid.Utilities;
using Sirenix.OdinInspector;
@ -7,7 +6,7 @@ using UnityEngine;
namespace Intrepid.Gameplay.Prototyping
{
[ExecuteAlways]
public class ContactCubeModelPrototype : ContactModelPrototype
public class ObstacleWallModelPrototype : ObstacleModelPrototype
{
[GroupConfigurations, SerializeField, ReadOnly] private int sizeX = 1;
[GroupConfigurations, SerializeField, ReadOnly] private int sizeY = 1;
@ -21,11 +20,21 @@ namespace Intrepid.Gameplay.Prototyping
[GroupDebug, SerializeField] private Vector2 contact_offset_x = new(1f, 1.5f);
[GroupDebug, SerializeField] private Vector2 contact_offset_y = new(1f, 1.5f);
public override void SetSize(Vector2Int size)
{
x = size.x;
z = size.y;
SizeFitting();
}
protected override void DebugResize()
{
sizeX = Mathf.Max(1, x);
sizeY = Mathf.Max(1, y);
sizeZ = Mathf.Max(1, z);
x = Mathf.Max(1, x);
y = Mathf.Max(1, y);
z = Mathf.Max(1, z);
sizeX = x;
sizeY = y;
sizeZ = z;
offset_x.x = Mathf.Clamp(contact_offset_x.x, 0f, 2f);
offset_x.y = Mathf.Clamp(contact_offset_x.y, 0f, 2f);
offset_y.x = Mathf.Clamp(contact_offset_y.x, 0f, 2f);

View File

@ -61,6 +61,26 @@
"key": "ShapeComponent.SettingsEnabled",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.showEditorNotifications",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.showSceneInfo",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.stripProBuilderScriptsOnBuild",
"value": "{\"m_Value\":true}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.autoUpdatePreview",
"value": "{\"m_Value\":false}"
},
{
"type": "UnityEngine.Material, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "mesh.userMaterial",
@ -105,6 +125,11 @@
"type": "UnityEngine.ProBuilder.SelectMode, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "s_SelectMode",
"value": "{\"m_Value\":4}"
},
{
"type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "uv.uvEditorGridSnapIncrement",
"value": "{\"m_Value\":0.125}"
}
]
}