Adding 9 Player level

This commit is contained in:
Matt F 2026-05-21 23:36:19 -07:00
parent fdada6f132
commit a7be12fa9b
30 changed files with 45984 additions and 300 deletions

View file

@ -1231,12 +1231,13 @@ namespace TD.Levels.Editor
private static bool RenderThumbnail(BakeContext ctx, string thumbnailAssetPath)
{
// Compute world-space bounds of the map's tile region.
float halfTile = GridCoordinates.TILE_SIZE * 0.5f;
float minX = ctx.MapMinTile.x - halfTile;
float maxX = ctx.MapMaxTile.x + halfTile;
float minZ = ctx.MapMinTile.y - halfTile;
float maxZ = ctx.MapMaxTile.y + halfTile;
// Compute world-space bounds of the map's tile region. Tile N spans world [N, N+1]
// (edge-aligned), so the rect spans from MapMinTile to MapMaxTile + 1 on each axis.
float tileSize = GridCoordinates.TILE_SIZE;
float minX = ctx.MapMinTile.x * tileSize;
float maxX = (ctx.MapMaxTile.x + 1) * tileSize;
float minZ = ctx.MapMinTile.y * tileSize;
float maxZ = (ctx.MapMaxTile.y + 1) * tileSize;
float worldW = maxX - minX;
float worldH = maxZ - minZ;

View file

@ -156,7 +156,6 @@ namespace TD.Levels.Editor
float outwardDelta = edgeIsPositive ? worldDeltaSnapped : -worldDeltaSnapped;
Vector3 size = col.size;
Vector3 center = col.center;
float currentSize = axisIsX ? size.x : size.z;
float newSize = currentSize + outwardDelta;
@ -165,29 +164,44 @@ namespace TD.Levels.Editor
// (don't move the edge at all). This is more predictable than partially honoring it.
if (newSize < MinSize) return;
// Apply the change. The edge that's NOT being dragged should stay put. To keep the
// opposite edge fixed, the center must shift by half the size change in the direction
// of the edge being dragged.
// Apply the change. The edge that's NOT being dragged should stay put. We achieve this
// by adjusting transform.position rather than BoxCollider.center, so the collider's
// center stays locked at (0, 0, 0) — the "center" of the volume's local frame is always
// the geometric center of the box. The position shifts by half the size change in the
// direction of the edge being dragged.
//
// Example (east edge dragged outward by 2 tiles): size.x += 2; center.x += 1.
// Example (west edge dragged outward by 1 tile): size.x += 1; center.x -= 0.5.
float centerShift = (edgeIsPositive ? 1f : -1f) * (outwardDelta * 0.5f);
// Example (east edge dragged outward by 2 tiles): size.x += 2; transform.position.x += 1.
// Example (west edge dragged outward by 1 tile): size.x += 1; transform.position.x -= 0.5.
//
// Note: positions may land at half-integer values when the size is odd. That's correct
// under the edge-aligned tile convention — bounds align with tile edges when
// (position - size/2) and (position + size/2) are both integers,
// which requires position to have the same fractional part as size/2.
float positionShift = (edgeIsPositive ? 1f : -1f) * (outwardDelta * 0.5f);
if (axisIsX)
{
size.x = newSize;
center.x += centerShift;
}
else
{
size.z = newSize;
center.z += centerShift;
}
Vector3 newPosition = col.transform.position;
if (axisIsX) newPosition.x += positionShift;
else newPosition.z += positionShift;
Undo.RecordObject(col.transform, "Resize Volume Edge");
Undo.RecordObject(col, "Resize Volume Edge");
col.transform.position = newPosition;
col.size = size;
col.center = center;
// Force-lock collider center to zero in case it had drifted from prior edits made
// before this behavior change. Safe to do unconditionally — by design, this tool now
// never wants a non-zero center.
col.center = Vector3.zero;
EditorUtility.SetDirty(col);
EditorUtility.SetDirty(col.transform);
}
private static Vector3 WithY(Vector3 v, float y)