Draw free-flight pigeons above all blocks.
Flight sprites use a dedicated y-sort bias so they never tuck under walls or trees while flying.
@@ -8,7 +8,7 @@ import { resolveItemTint, resolveEquipTint, resolveItemDualTint, normalizeRgb }
8
8
import { layersFromSpawnerConfig } from "/shared/appearance/layers.js";
9
9
import { chargeSpriteFrameIndex, itemMaxCharges } from "/shared/items/charges.js";
10
10
import { normalizeGround, isWadeGroundInSeason, isWaterGround, isLiquidWaterGround, isGroundPassable, isBlockOccludingLight, LightOcclusion } from "/shared/definitions/tiles.js";
11
import { spriteCenterFromPivot, spriteDrawSize, tilePivot, ySortLayer } from "/shared/render/pivot.js";
11
import { spriteCenterFromPivot, spriteDrawSize, tilePivot, ySortLayer, flightSortLayer } from "/shared/render/pivot.js";
12
12
import { bakeChunkAtlases, tileBlockSpriteEntry } from "./chunkBake.js";
13
13
import { createChunkAtlasCache } from "./chunkAtlasCache.js";
14
14
import
@@ -2441,7 +2441,8 @@ export class WorldView
2441
2441
2442
2442
entity.object.transform.rotation = walkTilt;
2443
2443
this.#syncLitSprite(entity.object, tileShade, flashStrength, wade, entity.bodyTint ?? null, flashColor);
2444
this.#placePivoted(entity.object, pivotX, pivotY, pivotY, SORT_ENTITY, entity.visualScale ?? 1);
2444
const flight = !!entity.freeFlight;
2445
this.#placePivoted(entity.object, pivotX, pivotY, pivotY, SORT_ENTITY, entity.visualScale ?? 1, flight);
2445
2446
for (let index = 0; index < (entity.overlays ?? []).length; index++)
2446
2447
{
2447
2448
const overlay = entity.overlays[index];
@@ -2468,7 +2469,7 @@ export class WorldView
2468
2469
{
2469
2470
this.#syncLitSprite(overlay, tileShade, flashStrength, wade, entity.overlayTints?.[index] ?? null, flashColor);
2470
2471
}
2471
this.#placePivoted(overlay, pivotX, pivotY, overlaySortY, SORT_ENTITY, entity.visualScale ?? 1);
2472
this.#placePivoted(overlay, pivotX, pivotY, overlaySortY, SORT_ENTITY, entity.visualScale ?? 1, flight);
2472
2473
}
2473
2474
for (let index = 0; index < (entity.bloomOverlays ?? []).length; index++)
2474
2475
{
@@ -2488,7 +2489,7 @@ export class WorldView
2488
2489
{ this.#syncUnlitTintSprite(overlay, bloomTint); }
2489
2490
else
2490
2491
{ this.#syncLitSprite(overlay, tileShade, flashStrength, wade, null, flashColor); }
2491
this.#placePivoted(overlay, pivotX, pivotY, pivotY + 0.002, SORT_ENTITY, entity.visualScale ?? 1);
2492
this.#placePivoted(overlay, pivotX, pivotY, pivotY + 0.002, SORT_ENTITY, entity.visualScale ?? 1, flight);
2492
2493
}
2493
2494
this.#placeHpBar(entity, pivotX, pivotY);
2494
2495
this.#placeSkullMarker(entity, pivotX, pivotY, tileShade);
@@ -3549,7 +3550,7 @@ export class WorldView
3549
3550
return object;
3550
3551
}
3551
3552
3552
#placePivoted (object, pivotX, pivotY, sortY, subOrder, scale = 1)
3553
#placePivoted (object, pivotX, pivotY, sortY, subOrder, scale = 1, flight = false)
3553
3554
{
3554
3555
const sprite = object?.renderer?.sprite;
3555
3556
if (!sprite)
@@ -3561,7 +3562,9 @@ export class WorldView
3561
3562
object.transform.position.x = center.x;
3562
3563
object.transform.position.y = center.y;
3563
3564
object.transform.size = new vector(draw.w * factor, draw.h * factor);
3564
object.layer = ySortLayer(sortY, subOrder);
3565
object.layer = flight
3566
? flightSortLayer(sortY, subOrder)
3567
: ySortLayer(sortY, subOrder);
3565
3568
this.#markSortDirty();
3566
3569
}
3567
3570
@@ -8,7 +8,7 @@ import { resolveItemTint, resolveEquipTint, resolveItemDualTint, normalizeRgb }8
import { layersFromSpawnerConfig } from "/shared/appearance/layers.js";8
import { layersFromSpawnerConfig } from "/shared/appearance/layers.js";9
import { chargeSpriteFrameIndex, itemMaxCharges } from "/shared/items/charges.js";9
import { chargeSpriteFrameIndex, itemMaxCharges } from "/shared/items/charges.js";10
import { normalizeGround, isWadeGroundInSeason, isWaterGround, isLiquidWaterGround, isGroundPassable, isBlockOccludingLight, LightOcclusion } from "/shared/definitions/tiles.js";10
import { normalizeGround, isWadeGroundInSeason, isWaterGround, isLiquidWaterGround, isGroundPassable, isBlockOccludingLight, LightOcclusion } from "/shared/definitions/tiles.js";11
import { spriteCenterFromPivot, spriteDrawSize, tilePivot, ySortLayer } from "/shared/render/pivot.js";11
import { spriteCenterFromPivot, spriteDrawSize, tilePivot, ySortLayer, flightSortLayer } from "/shared/render/pivot.js";12
import { bakeChunkAtlases, tileBlockSpriteEntry } from "./chunkBake.js";12
import { bakeChunkAtlases, tileBlockSpriteEntry } from "./chunkBake.js";13
import { createChunkAtlasCache } from "./chunkAtlasCache.js";13
import { createChunkAtlasCache } from "./chunkAtlasCache.js";14
import14
import@@ -2441,7 +2441,8 @@ export class WorldView2441
2441
2442
entity.object.transform.rotation = walkTilt;2442
entity.object.transform.rotation = walkTilt;2443
this.#syncLitSprite(entity.object, tileShade, flashStrength, wade, entity.bodyTint ?? null, flashColor);2443
this.#syncLitSprite(entity.object, tileShade, flashStrength, wade, entity.bodyTint ?? null, flashColor);2444
this.#placePivoted(entity.object, pivotX, pivotY, pivotY, SORT_ENTITY, entity.visualScale ?? 1);2444
const flight = !!entity.freeFlight;2445
this.#placePivoted(entity.object, pivotX, pivotY, pivotY, SORT_ENTITY, entity.visualScale ?? 1, flight);2445
for (let index = 0; index < (entity.overlays ?? []).length; index++)2446
for (let index = 0; index < (entity.overlays ?? []).length; index++)2446
{2447
{2447
const overlay = entity.overlays[index];2448
const overlay = entity.overlays[index];@@ -2468,7 +2469,7 @@ export class WorldView2468
{2469
{2469
this.#syncLitSprite(overlay, tileShade, flashStrength, wade, entity.overlayTints?.[index] ?? null, flashColor);2470
this.#syncLitSprite(overlay, tileShade, flashStrength, wade, entity.overlayTints?.[index] ?? null, flashColor);2470
}2471
}2471
this.#placePivoted(overlay, pivotX, pivotY, overlaySortY, SORT_ENTITY, entity.visualScale ?? 1);2472
this.#placePivoted(overlay, pivotX, pivotY, overlaySortY, SORT_ENTITY, entity.visualScale ?? 1, flight);2472
}2473
}2473
for (let index = 0; index < (entity.bloomOverlays ?? []).length; index++)2474
for (let index = 0; index < (entity.bloomOverlays ?? []).length; index++)2474
{2475
{@@ -2488,7 +2489,7 @@ export class WorldView2488
{ this.#syncUnlitTintSprite(overlay, bloomTint); }2489
{ this.#syncUnlitTintSprite(overlay, bloomTint); }2489
else2490
else2490
{ this.#syncLitSprite(overlay, tileShade, flashStrength, wade, null, flashColor); }2491
{ this.#syncLitSprite(overlay, tileShade, flashStrength, wade, null, flashColor); }2491
this.#placePivoted(overlay, pivotX, pivotY, pivotY + 0.002, SORT_ENTITY, entity.visualScale ?? 1);2492
this.#placePivoted(overlay, pivotX, pivotY, pivotY + 0.002, SORT_ENTITY, entity.visualScale ?? 1, flight);2492
}2493
}2493
this.#placeHpBar(entity, pivotX, pivotY);2494
this.#placeHpBar(entity, pivotX, pivotY);2494
this.#placeSkullMarker(entity, pivotX, pivotY, tileShade);2495
this.#placeSkullMarker(entity, pivotX, pivotY, tileShade);@@ -3549,7 +3550,7 @@ export class WorldView3549
return object;3550
return object;3550
}3551
}3551
3552
3552
#placePivoted (object, pivotX, pivotY, sortY, subOrder, scale = 1)3553
#placePivoted (object, pivotX, pivotY, sortY, subOrder, scale = 1, flight = false)3553
{3554
{3554
const sprite = object?.renderer?.sprite;3555
const sprite = object?.renderer?.sprite;3555
if (!sprite)3556
if (!sprite)@@ -3561,7 +3562,9 @@ export class WorldView3561
object.transform.position.x = center.x;3562
object.transform.position.x = center.x;3562
object.transform.position.y = center.y;3563
object.transform.position.y = center.y;3563
object.transform.size = new vector(draw.w * factor, draw.h * factor);3564
object.transform.size = new vector(draw.w * factor, draw.h * factor);3564
object.layer = ySortLayer(sortY, subOrder);3565
object.layer = flight3566
? flightSortLayer(sortY, subOrder)3567
: ySortLayer(sortY, subOrder);3565
this.#markSortDirty();3568
this.#markSortDirty();3566
}3569
}3567
3570
@@ -1,6 +1,6 @@
1
1
import test from "node:test";
2
2
import assert from "node:assert/strict";
3
import { spriteCenterFromPivot, tilePivot, ySortLayer } from "../../shared/render/pivot.js";
3
import { spriteCenterFromPivot, tilePivot, ySortLayer, flightSortLayer } from "../../shared/render/pivot.js";
4
4
5
5
test("a 16×16 sprite pivot sits on the tile centre", () =>
6
6
{
@@ -32,3 +32,10 @@ test("Y-sort puts a southern tile in front of a northern tile", () =>
32
32
{
33
33
assert.ok(ySortLayer(16, 1) > ySortLayer(0, 1));
34
34
});
35
36
test("flight sort stays above any ground y-sort in view", () =>
37
{
38
const farSouthBlock = ySortLayer(50_000, 3);
39
assert.ok(flightSortLayer(0, 0) > farSouthBlock);
40
assert.ok(flightSortLayer(16, 1) > flightSortLayer(0, 1));
41
});
@@ -1,6 +1,6 @@1
import test from "node:test";1
import test from "node:test";2
import assert from "node:assert/strict";2
import assert from "node:assert/strict";3
import { spriteCenterFromPivot, tilePivot, ySortLayer } from "../../shared/render/pivot.js";3
import { spriteCenterFromPivot, tilePivot, ySortLayer, flightSortLayer } from "../../shared/render/pivot.js";4
4
5
test("a 16×16 sprite pivot sits on the tile centre", () =>5
test("a 16×16 sprite pivot sits on the tile centre", () =>6
{6
{@@ -32,3 +32,10 @@ test("Y-sort puts a southern tile in front of a northern tile", () =>32
{32
{33
assert.ok(ySortLayer(16, 1) > ySortLayer(0, 1));33
assert.ok(ySortLayer(16, 1) > ySortLayer(0, 1));34
});34
});35
36
test("flight sort stays above any ground y-sort in view", () =>37
{38
const farSouthBlock = ySortLayer(50_000, 3);39
assert.ok(flightSortLayer(0, 0) > farSouthBlock);40
assert.ok(flightSortLayer(16, 1) > flightSortLayer(0, 1));41
});