Merge branch 'feature/editor-equip-icons-spawner-preview'
@@ -14,10 +14,11 @@ import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";
14
14
import { SPELL_DEFINITIONS, spellMinMagicLevel } from "/shared/definitions/spells.js";
15
15
import { spellDifficultyFromTier } from "/shared/spells/constants.js";
16
16
import { centralExchangeStaffCount } from "/shared/market/exchange.js";
17
import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries } from "/shared/definitions/items.js";
17
import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries, itemAssetPathForStack } from "/shared/definitions/items.js";
18
18
import { listRawFishPickerEntries, normalizeFishingSpotConfig, fishTierRankFromItemId } from "/shared/definitions/fishItems.js";
19
19
import { EQUIPMENT_SLOTS } from "/shared/items/inventory.js";
20
20
import { normalizeRgb } from "/shared/render/tint.js";
21
import { applyItemIcon } from "/src/render/potionIcon.js";
21
22
import { createDimensionCombobox } from "./dimensionCombobox.js";
22
23
import { OVERWORLD_ID, normalizeDimensionId } from "/shared/world/dimensions.js";
23
24
import { renderConditionSet, emptyConditionSet, normalizeConditionSet } from "./conditionSetEditor.js";
@@ -80,6 +81,35 @@ function equipConfigFromDraft (draft)
80
81
return id;
81
82
}
82
83
84
/** Stack shape for applyItemIcon, including optional clothing dye. */
85
function stackFromEquipDraft (draft)
86
{
87
const itemId = draft?.itemId;
88
if (itemId == null)
89
{ return null; }
90
const stack = { itemId, quantity: 1 };
91
if (draft.dyeColor && isDyeableClothing(itemId))
92
{ stack.instance = { kind: "clothing", dyeColor: normalizeRgb(draft.dyeColor) }; }
93
return stack;
94
}
95
96
function applyEquipIcon (img, draft)
97
{
98
if (!img)
99
{ return; }
100
const stack = stackFromEquipDraft(draft);
101
if (!stack)
102
{
103
img.removeAttribute("src");
104
img.alt = "";
105
img.hidden = true;
106
return;
107
}
108
img.hidden = false;
109
img.alt = itemDefinition(stack.itemId)?.displayName ?? "";
110
applyItemIcon(img, stack, itemAssetPathForStack(stack));
111
}
112
83
113
function rgbToCss (color)
84
114
{
85
115
const c = normalizeRgb(color, { r: 0.78, g: 0.31, b: 0.47 });
@@ -285,6 +315,15 @@ export function initTileConfigModal ({
285
315
const row = document.createElement("button");
286
316
row.type = "button";
287
317
row.className = "shop-item-search-row";
318
const icon = document.createElement("img");
319
icon.className = "shop-item-search-row-icon equip-stats-icon";
320
icon.width = 16;
321
icon.height = 16;
322
icon.alt = "";
323
const stack = { itemId: item.itemId, quantity: 1 };
324
applyItemIcon(icon, stack, itemAssetPathForStack(stack));
325
const text = document.createElement("span");
326
text.className = "shop-item-search-row-text";
288
327
const name = document.createElement("span");
289
328
name.className = "shop-item-search-row-name";
290
329
name.textContent = item.displayName;
@@ -293,7 +332,8 @@ export function initTileConfigModal ({
293
332
key.textContent = itemSearchMode?.kind === "fishes"
294
333
? `${item.key} · tier ${item.tier} · #${item.itemId}`
295
334
: `${item.key} · #${item.itemId}`;
296
row.append(name, key);
335
text.append(name, key);
336
row.append(icon, text);
297
337
row.addEventListener("click", () =>
298
338
{
299
339
if (itemSearchMode?.kind === "equip")
@@ -604,6 +644,12 @@ export function initTileConfigModal ({
604
644
const label = document.createElement("span");
605
645
label.className = "spawner-equip-slot";
606
646
label.textContent = slot;
647
const icon = document.createElement("img");
648
icon.className = "spawner-equip-icon equip-stats-icon";
649
icon.width = 16;
650
icon.height = 16;
651
icon.alt = "";
652
applyEquipIcon(icon, draft);
607
653
const name = document.createElement("span");
608
654
name.className = "spawner-equip-name";
609
655
if (def && draft.dyeColor)
@@ -636,7 +682,7 @@ export function initTileConfigModal ({
636
682
equipmentDraft[slot] = emptyEquipDraft();
637
683
renderEquipmentRows();
638
684
});
639
row.append(label, name, pick, dyeBtn, clear);
685
row.append(label, icon, name, pick, dyeBtn, clear);
640
686
list.append(row);
641
687
}
642
688
}
@@ -14,10 +14,11 @@ import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";14
import { SPELL_DEFINITIONS, spellMinMagicLevel } from "/shared/definitions/spells.js";14
import { SPELL_DEFINITIONS, spellMinMagicLevel } from "/shared/definitions/spells.js";15
import { spellDifficultyFromTier } from "/shared/spells/constants.js";15
import { spellDifficultyFromTier } from "/shared/spells/constants.js";16
import { centralExchangeStaffCount } from "/shared/market/exchange.js";16
import { centralExchangeStaffCount } from "/shared/market/exchange.js";17
import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries } from "/shared/definitions/items.js";17
import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries, itemAssetPathForStack } from "/shared/definitions/items.js";18
import { listRawFishPickerEntries, normalizeFishingSpotConfig, fishTierRankFromItemId } from "/shared/definitions/fishItems.js";18
import { listRawFishPickerEntries, normalizeFishingSpotConfig, fishTierRankFromItemId } from "/shared/definitions/fishItems.js";19
import { EQUIPMENT_SLOTS } from "/shared/items/inventory.js";19
import { EQUIPMENT_SLOTS } from "/shared/items/inventory.js";20
import { normalizeRgb } from "/shared/render/tint.js";20
import { normalizeRgb } from "/shared/render/tint.js";21
import { applyItemIcon } from "/src/render/potionIcon.js";21
import { createDimensionCombobox } from "./dimensionCombobox.js";22
import { createDimensionCombobox } from "./dimensionCombobox.js";22
import { OVERWORLD_ID, normalizeDimensionId } from "/shared/world/dimensions.js";23
import { OVERWORLD_ID, normalizeDimensionId } from "/shared/world/dimensions.js";23
import { renderConditionSet, emptyConditionSet, normalizeConditionSet } from "./conditionSetEditor.js";24
import { renderConditionSet, emptyConditionSet, normalizeConditionSet } from "./conditionSetEditor.js";@@ -80,6 +81,35 @@ function equipConfigFromDraft (draft)80
return id;81
return id;81
}82
}82
83
84
/** Stack shape for applyItemIcon, including optional clothing dye. */85
function stackFromEquipDraft (draft)86
{87
const itemId = draft?.itemId;88
if (itemId == null)89
{ return null; }90
const stack = { itemId, quantity: 1 };91
if (draft.dyeColor && isDyeableClothing(itemId))92
{ stack.instance = { kind: "clothing", dyeColor: normalizeRgb(draft.dyeColor) }; }93
return stack;94
}95
96
function applyEquipIcon (img, draft)97
{98
if (!img)99
{ return; }100
const stack = stackFromEquipDraft(draft);101
if (!stack)102
{103
img.removeAttribute("src");104
img.alt = "";105
img.hidden = true;106
return;107
}108
img.hidden = false;109
img.alt = itemDefinition(stack.itemId)?.displayName ?? "";110
applyItemIcon(img, stack, itemAssetPathForStack(stack));111
}112
83
function rgbToCss (color)113
function rgbToCss (color)84
{114
{85
const c = normalizeRgb(color, { r: 0.78, g: 0.31, b: 0.47 });115
const c = normalizeRgb(color, { r: 0.78, g: 0.31, b: 0.47 });@@ -285,6 +315,15 @@ export function initTileConfigModal ({285
const row = document.createElement("button");315
const row = document.createElement("button");286
row.type = "button";316
row.type = "button";287
row.className = "shop-item-search-row";317
row.className = "shop-item-search-row";318
const icon = document.createElement("img");319
icon.className = "shop-item-search-row-icon equip-stats-icon";320
icon.width = 16;321
icon.height = 16;322
icon.alt = "";323
const stack = { itemId: item.itemId, quantity: 1 };324
applyItemIcon(icon, stack, itemAssetPathForStack(stack));325
const text = document.createElement("span");326
text.className = "shop-item-search-row-text";288
const name = document.createElement("span");327
const name = document.createElement("span");289
name.className = "shop-item-search-row-name";328
name.className = "shop-item-search-row-name";290
name.textContent = item.displayName;329
name.textContent = item.displayName;@@ -293,7 +332,8 @@ export function initTileConfigModal ({293
key.textContent = itemSearchMode?.kind === "fishes"332
key.textContent = itemSearchMode?.kind === "fishes"294
? `${item.key} · tier ${item.tier} · #${item.itemId}`333
? `${item.key} · tier ${item.tier} · #${item.itemId}`295
: `${item.key} · #${item.itemId}`;334
: `${item.key} · #${item.itemId}`;296
row.append(name, key);335
text.append(name, key);336
row.append(icon, text);297
row.addEventListener("click", () =>337
row.addEventListener("click", () =>298
{338
{299
if (itemSearchMode?.kind === "equip")339
if (itemSearchMode?.kind === "equip")@@ -604,6 +644,12 @@ export function initTileConfigModal ({604
const label = document.createElement("span");644
const label = document.createElement("span");605
label.className = "spawner-equip-slot";645
label.className = "spawner-equip-slot";606
label.textContent = slot;646
label.textContent = slot;647
const icon = document.createElement("img");648
icon.className = "spawner-equip-icon equip-stats-icon";649
icon.width = 16;650
icon.height = 16;651
icon.alt = "";652
applyEquipIcon(icon, draft);607
const name = document.createElement("span");653
const name = document.createElement("span");608
name.className = "spawner-equip-name";654
name.className = "spawner-equip-name";609
if (def && draft.dyeColor)655
if (def && draft.dyeColor)@@ -636,7 +682,7 @@ export function initTileConfigModal ({636
equipmentDraft[slot] = emptyEquipDraft();682
equipmentDraft[slot] = emptyEquipDraft();637
renderEquipmentRows();683
renderEquipmentRows();638
});684
});639
row.append(label, name, pick, dyeBtn, clear);685
row.append(label, icon, name, pick, dyeBtn, clear);640
list.append(row);686
list.append(row);641
}687
}642
}688
}@@ -15,6 +15,7 @@ import
15
15
normalizeRgb
16
16
} from "/shared/render/tint.js";
17
17
import { layersFromSpawnerConfig } from "/shared/appearance/layers.js";
18
import { normalizeSpawnerConfig } from "/shared/definitions/mobs.js";
18
19
import { chargeSpriteFrameIndex, itemMaxCharges } from "/shared/items/charges.js";
19
20
import { normalizeGround, normalizeBlock, isWadeGroundInSeason, isWaterGround, isLavaGround, isLiquidWaterGround, isGroundPassable, groundLightOcclusion, LightOcclusion, blockDefinition, blockLightOcclusionForBlock, GroundType, GROUND_DEFINITIONS, fluidCoastContinues } from "/shared/definitions/tiles.js";
20
21
import { doorSortSubOrder, doorRestingState } from "/shared/world/doors.js";
@@ -2677,6 +2678,7 @@ export class WorldView
2677
2678
/**
2678
2679
* Editor-only mob markers for authored spawners (invisible during play).
2679
2680
* Humanoid / town guard / CE show body + equipment overlays.
2681
* Previews up to 10 bodies using the same stack circle as play.
2680
2682
* @param {number} chunkX
2681
2683
* @param {number} chunkY
2682
2684
* @param {Array<{ localX: number, localY: number, config?: object }>} spawners
@@ -2697,56 +2699,61 @@ export class WorldView
2697
2699
{
2698
2700
const tileX = chunkX * CHUNK_SIZE + spawner.localX;
2699
2701
const tileY = chunkY * CHUNK_SIZE + spawner.localY;
2700
const layers = layersFromSpawnerConfig(spawner.config);
2702
const config = normalizeSpawnerConfig(spawner.config ?? {});
2703
const layers = layersFromSpawnerConfig(config);
2701
2704
const bodySpriteName = layers?.[0]?.sprite
2702
?? resolveSprite?.(spawner.config?.mobTypeId)
2705
?? resolveSprite?.(config.mobTypeId)
2703
2706
?? null;
2704
2707
if (!bodySpriteName)
2705
2708
{ continue; }
2706
const key = `${prefix}${spawner.localX},${spawner.localY}`;
2707
const object = this.#ensureSprite(null, bodySpriteName, SORT_ENTITY);
2708
if (!object)
2709
{ continue; }
2710
object.renderer.alpha = 0.85;
2711
const bodyTint = layers?.[0]?.tint ? normalizeRgb(layers[0].tint) : null;
2712
if (bodyTint)
2713
{ this.#syncUnlitTintSprite(object, bodyTint); }
2714
else
2715
{ this.#markUnlit(object); }
2716
const overlays = [];
2717
for (const layer of layers?.slice(1) ?? [])
2709
const previewCount = Math.min(10, Math.max(1, config.maxAlive | 0));
2710
const instances = [];
2711
for (let n = 0; n < previewCount; n++)
2718
2712
{
2719
const overlay = this.#ensureSprite(null, layer.sprite, SORT_ENTITY);
2720
if (!overlay)
2713
const object = this.#ensureSprite(null, bodySpriteName, SORT_ENTITY);
2714
if (!object)
2721
2715
{ continue; }
2722
overlay.renderer.alpha = 0.85;
2723
this.#applyEditorSpawnerOverlayLook(overlay, layer);
2724
overlays.push(overlay);
2725
}
2726
const pivot = tilePivot(tileX, tileY, size);
2727
this.#placePivoted(object, pivot.x, pivot.y, pivot.y + 0.05, SORT_ENTITY);
2728
for (let i = 0; i < overlays.length; i++)
2729
{
2730
this.#placePivoted(
2731
overlays[i],
2732
pivot.x,
2733
pivot.y,
2734
pivot.y + 0.05 + 0.001 * (i + 1),
2735
SORT_ENTITY
2736
);
2716
object.renderer.alpha = 0.85;
2717
const bodyTint = layers?.[0]?.tint ? normalizeRgb(layers[0].tint) : null;
2718
if (bodyTint)
2719
{ this.#syncUnlitTintSprite(object, bodyTint); }
2720
else
2721
{ this.#markUnlit(object); }
2722
const overlays = [];
2723
for (const layer of layers?.slice(1) ?? [])
2724
{
2725
const overlay = this.#ensureSprite(null, layer.sprite, SORT_ENTITY);
2726
if (!overlay)
2727
{ continue; }
2728
overlay.renderer.alpha = 0.85;
2729
this.#applyEditorSpawnerOverlayLook(overlay, layer);
2730
overlays.push(overlay);
2731
}
2732
instances.push({ object, overlays });
2737
2733
}
2738
this.editorSpawners.set(key, {
2739
object,
2740
overlays,
2734
if (!instances.length)
2735
{ continue; }
2736
const key = `${prefix}${spawner.localX},${spawner.localY}`;
2737
const entry = {
2738
instances,
2741
2739
tileX,
2742
2740
tileY,
2743
2741
spriteName: bodySpriteName
2744
});
2742
};
2743
this.#placeEditorSpawnerEntry(entry, size);
2744
this.editorSpawners.set(key, entry);
2745
2745
}
2746
2746
}
2747
2747
2748
2748
#destroyEditorSpawnerEntry (entry)
2749
2749
{
2750
for (const instance of entry?.instances ?? [])
2751
{
2752
instance?.object?.destroy();
2753
for (const overlay of instance?.overlays ?? [])
2754
{ overlay?.destroy(); }
2755
}
2756
// Legacy single-body shape (pre multi-preview).
2750
2757
entry?.object?.destroy();
2751
2758
for (const overlay of entry?.overlays ?? [])
2752
2759
{ overlay?.destroy(); }
@@ -2788,29 +2795,43 @@ export class WorldView
2788
2795
this.editorSpawners.clear();
2789
2796
}
2790
2797
2791
#relayoutEditorSpawners ()
2798
#placeEditorSpawnerEntry (entry, size = this.tileSize())
2792
2799
{
2793
const size = this.tileSize();
2794
for (const entry of this.editorSpawners.values())
2795
{
2796
if (!entry.object)
2797
{ continue; }
2798
const pivot = tilePivot(entry.tileX, entry.tileY, size);
2799
this.#placePivoted(entry.object, pivot.x, pivot.y, pivot.y + 0.05, SORT_ENTITY);
2800
const overlays = entry.overlays ?? [];
2801
for (let i = 0; i < overlays.length; i++)
2800
const instances = entry?.instances ?? [];
2801
if (!instances.length)
2802
{ return; }
2803
const pivot = tilePivot(entry.tileX, entry.tileY, size);
2804
const n = instances.length;
2805
const radius = n <= 1 ? 0 : (ENTITY_STACK_SPREAD_DIAMETER_PX * this.zoom) / 2;
2806
for (let i = 0; i < n; i++)
2807
{
2808
const angle = -Math.PI / 2 + (Math.PI * 2 * i) / n;
2809
const x = pivot.x + Math.cos(angle) * radius;
2810
const y = pivot.y + Math.sin(angle) * radius;
2811
const instance = instances[i];
2812
const depthBase = y + 0.05 + 0.0001 * i;
2813
this.#placePivoted(instance.object, x, y, depthBase, SORT_ENTITY);
2814
const overlays = instance.overlays ?? [];
2815
for (let o = 0; o < overlays.length; o++)
2802
2816
{
2803
2817
this.#placePivoted(
2804
overlays[i],
2805
pivot.x,
2806
pivot.y,
2807
pivot.y + 0.05 + 0.001 * (i + 1),
2818
overlays[o],
2819
x,
2820
y,
2821
depthBase + 0.001 * (o + 1),
2808
2822
SORT_ENTITY
2809
2823
);
2810
2824
}
2811
2825
}
2812
2826
}
2813
2827
2828
#relayoutEditorSpawners ()
2829
{
2830
const size = this.tileSize();
2831
for (const entry of this.editorSpawners.values())
2832
{ this.#placeEditorSpawnerEntry(entry, size); }
2833
}
2834
2814
2835
/**
2815
2836
* Editor-only range overlays: spawn (inner) and wander (outer, Chebyshev squares).
2816
2837
*/
@@ -15,6 +15,7 @@ import15
normalizeRgb15
normalizeRgb16
} from "/shared/render/tint.js";16
} from "/shared/render/tint.js";17
import { layersFromSpawnerConfig } from "/shared/appearance/layers.js";17
import { layersFromSpawnerConfig } from "/shared/appearance/layers.js";18
import { normalizeSpawnerConfig } from "/shared/definitions/mobs.js";18
import { chargeSpriteFrameIndex, itemMaxCharges } from "/shared/items/charges.js";19
import { chargeSpriteFrameIndex, itemMaxCharges } from "/shared/items/charges.js";19
import { normalizeGround, normalizeBlock, isWadeGroundInSeason, isWaterGround, isLavaGround, isLiquidWaterGround, isGroundPassable, groundLightOcclusion, LightOcclusion, blockDefinition, blockLightOcclusionForBlock, GroundType, GROUND_DEFINITIONS, fluidCoastContinues } from "/shared/definitions/tiles.js";20
import { normalizeGround, normalizeBlock, isWadeGroundInSeason, isWaterGround, isLavaGround, isLiquidWaterGround, isGroundPassable, groundLightOcclusion, LightOcclusion, blockDefinition, blockLightOcclusionForBlock, GroundType, GROUND_DEFINITIONS, fluidCoastContinues } from "/shared/definitions/tiles.js";20
import { doorSortSubOrder, doorRestingState } from "/shared/world/doors.js";21
import { doorSortSubOrder, doorRestingState } from "/shared/world/doors.js";@@ -2677,6 +2678,7 @@ export class WorldView2677
/**2678
/**2678
* Editor-only mob markers for authored spawners (invisible during play).2679
* Editor-only mob markers for authored spawners (invisible during play).2679
* Humanoid / town guard / CE show body + equipment overlays.2680
* Humanoid / town guard / CE show body + equipment overlays.2681
* Previews up to 10 bodies using the same stack circle as play.2680
* @param {number} chunkX2682
* @param {number} chunkX2681
* @param {number} chunkY2683
* @param {number} chunkY2682
* @param {Array<{ localX: number, localY: number, config?: object }>} spawners2684
* @param {Array<{ localX: number, localY: number, config?: object }>} spawners@@ -2697,56 +2699,61 @@ export class WorldView2697
{2699
{2698
const tileX = chunkX * CHUNK_SIZE + spawner.localX;2700
const tileX = chunkX * CHUNK_SIZE + spawner.localX;2699
const tileY = chunkY * CHUNK_SIZE + spawner.localY;2701
const tileY = chunkY * CHUNK_SIZE + spawner.localY;2700
const layers = layersFromSpawnerConfig(spawner.config);2702
const config = normalizeSpawnerConfig(spawner.config ?? {});2703
const layers = layersFromSpawnerConfig(config);2701
const bodySpriteName = layers?.[0]?.sprite2704
const bodySpriteName = layers?.[0]?.sprite2702
?? resolveSprite?.(spawner.config?.mobTypeId)2705
?? resolveSprite?.(config.mobTypeId)2703
?? null;2706
?? null;2704
if (!bodySpriteName)2707
if (!bodySpriteName)2705
{ continue; }2708
{ continue; }2706
const key = `${prefix}${spawner.localX},${spawner.localY}`;2709
const previewCount = Math.min(10, Math.max(1, config.maxAlive | 0));2707
const object = this.#ensureSprite(null, bodySpriteName, SORT_ENTITY);2710
const instances = [];2708
if (!object)2711
for (let n = 0; n < previewCount; n++)2709
{ continue; }2710
object.renderer.alpha = 0.85;2711
const bodyTint = layers?.[0]?.tint ? normalizeRgb(layers[0].tint) : null;2712
if (bodyTint)2713
{ this.#syncUnlitTintSprite(object, bodyTint); }2714
else2715
{ this.#markUnlit(object); }2716
const overlays = [];2717
for (const layer of layers?.slice(1) ?? [])2718
{2712
{2719
const overlay = this.#ensureSprite(null, layer.sprite, SORT_ENTITY);2713
const object = this.#ensureSprite(null, bodySpriteName, SORT_ENTITY);2720
if (!overlay)2714
if (!object)2721
{ continue; }2715
{ continue; }2722
overlay.renderer.alpha = 0.85;2716
object.renderer.alpha = 0.85;2723
this.#applyEditorSpawnerOverlayLook(overlay, layer);2717
const bodyTint = layers?.[0]?.tint ? normalizeRgb(layers[0].tint) : null;2724
overlays.push(overlay);2718
if (bodyTint)2725
}2719
{ this.#syncUnlitTintSprite(object, bodyTint); }2726
const pivot = tilePivot(tileX, tileY, size);2720
else2727
this.#placePivoted(object, pivot.x, pivot.y, pivot.y + 0.05, SORT_ENTITY);2721
{ this.#markUnlit(object); }2728
for (let i = 0; i < overlays.length; i++)2722
const overlays = [];2729
{2723
for (const layer of layers?.slice(1) ?? [])2730
this.#placePivoted(2724
{2731
overlays[i],2725
const overlay = this.#ensureSprite(null, layer.sprite, SORT_ENTITY);2732
pivot.x,2726
if (!overlay)2733
pivot.y,2727
{ continue; }2734
pivot.y + 0.05 + 0.001 * (i + 1),2728
overlay.renderer.alpha = 0.85;2735
SORT_ENTITY2729
this.#applyEditorSpawnerOverlayLook(overlay, layer);2736
);2730
overlays.push(overlay);2731
}2732
instances.push({ object, overlays });2737
}2733
}2738
this.editorSpawners.set(key, {2734
if (!instances.length)2739
object,2735
{ continue; }2740
overlays,2736
const key = `${prefix}${spawner.localX},${spawner.localY}`;2737
const entry = {2738
instances,2741
tileX,2739
tileX,2742
tileY,2740
tileY,2743
spriteName: bodySpriteName2741
spriteName: bodySpriteName2744
});2742
};2743
this.#placeEditorSpawnerEntry(entry, size);2744
this.editorSpawners.set(key, entry);2745
}2745
}2746
}2746
}2747
2747
2748
#destroyEditorSpawnerEntry (entry)2748
#destroyEditorSpawnerEntry (entry)2749
{2749
{2750
for (const instance of entry?.instances ?? [])2751
{2752
instance?.object?.destroy();2753
for (const overlay of instance?.overlays ?? [])2754
{ overlay?.destroy(); }2755
}2756
// Legacy single-body shape (pre multi-preview).2750
entry?.object?.destroy();2757
entry?.object?.destroy();2751
for (const overlay of entry?.overlays ?? [])2758
for (const overlay of entry?.overlays ?? [])2752
{ overlay?.destroy(); }2759
{ overlay?.destroy(); }@@ -2788,29 +2795,43 @@ export class WorldView2788
this.editorSpawners.clear();2795
this.editorSpawners.clear();2789
}2796
}2790
2797
2791
#relayoutEditorSpawners ()2798
#placeEditorSpawnerEntry (entry, size = this.tileSize())2792
{2799
{2793
const size = this.tileSize();2800
const instances = entry?.instances ?? [];2794
for (const entry of this.editorSpawners.values())2801
if (!instances.length)2795
{2802
{ return; }2796
if (!entry.object)2803
const pivot = tilePivot(entry.tileX, entry.tileY, size);2797
{ continue; }2804
const n = instances.length;2798
const pivot = tilePivot(entry.tileX, entry.tileY, size);2805
const radius = n <= 1 ? 0 : (ENTITY_STACK_SPREAD_DIAMETER_PX * this.zoom) / 2;2799
this.#placePivoted(entry.object, pivot.x, pivot.y, pivot.y + 0.05, SORT_ENTITY);2806
for (let i = 0; i < n; i++)2800
const overlays = entry.overlays ?? [];2807
{2801
for (let i = 0; i < overlays.length; i++)2808
const angle = -Math.PI / 2 + (Math.PI * 2 * i) / n;2809
const x = pivot.x + Math.cos(angle) * radius;2810
const y = pivot.y + Math.sin(angle) * radius;2811
const instance = instances[i];2812
const depthBase = y + 0.05 + 0.0001 * i;2813
this.#placePivoted(instance.object, x, y, depthBase, SORT_ENTITY);2814
const overlays = instance.overlays ?? [];2815
for (let o = 0; o < overlays.length; o++)2802
{2816
{2803
this.#placePivoted(2817
this.#placePivoted(2804
overlays[i],2818
overlays[o],2805
pivot.x,2819
x,2806
pivot.y,2820
y,2807
pivot.y + 0.05 + 0.001 * (i + 1),2821
depthBase + 0.001 * (o + 1),2808
SORT_ENTITY2822
SORT_ENTITY2809
);2823
);2810
}2824
}2811
}2825
}2812
}2826
}2813
2827
2828
#relayoutEditorSpawners ()2829
{2830
const size = this.tileSize();2831
for (const entry of this.editorSpawners.values())2832
{ this.#placeEditorSpawnerEntry(entry, size); }2833
}2834
2814
/**2835
/**2815
* Editor-only range overlays: spawn (inner) and wander (outer, Chebyshev squares).2836
* Editor-only range overlays: spawn (inner) and wander (outer, Chebyshev squares).2816
*/2837
*/@@ -1188,7 +1188,7 @@ label {
1188
1188
1189
1189
.spawner-equip-row {
1190
1190
display: grid;
1191
grid-template-columns: 4.5rem 1fr auto auto auto;
1191
grid-template-columns: 4.5rem 1.1rem 1fr auto auto auto;
1192
1192
gap: 0.35rem;
1193
1193
align-items: center;
1194
1194
}
@@ -1199,6 +1199,15 @@ label {
1199
1199
font-size: 0.85rem;
1200
1200
}
1201
1201
1202
.spawner-equip-icon {
1203
width: 16px;
1204
height: 16px;
1205
}
1206
1207
.spawner-equip-icon[hidden] {
1208
visibility: hidden;
1209
}
1210
1202
1211
.spawner-equip-name {
1203
1212
overflow: hidden;
1204
1213
text-overflow: ellipsis;
@@ -1347,10 +1356,24 @@ label {
1347
1356
.shop-item-search-row {
1348
1357
text-align: left;
1349
1358
padding: 0.4rem 0.5rem;
1359
display: flex;
1360
flex-direction: row;
1361
align-items: center;
1362
gap: 0.45rem;
1363
}
1364
1365
.shop-item-search-row-icon {
1366
width: 16px;
1367
height: 16px;
1368
flex-shrink: 0;
1369
}
1370
1371
.shop-item-search-row-text {
1350
1372
display: flex;
1351
1373
flex-direction: column;
1352
1374
align-items: flex-start;
1353
1375
gap: 0.1rem;
1376
min-width: 0;
1354
1377
}
1355
1378
1356
1379
.shop-item-search-row-name {
@@ -1188,7 +1188,7 @@ label {1188
1188
1189
.spawner-equip-row {1189
.spawner-equip-row {1190
display: grid;1190
display: grid;1191
grid-template-columns: 4.5rem 1fr auto auto auto;1191
grid-template-columns: 4.5rem 1.1rem 1fr auto auto auto;1192
gap: 0.35rem;1192
gap: 0.35rem;1193
align-items: center;1193
align-items: center;1194
}1194
}@@ -1199,6 +1199,15 @@ label {1199
font-size: 0.85rem;1199
font-size: 0.85rem;1200
}1200
}1201
1201
1202
.spawner-equip-icon {1203
width: 16px;1204
height: 16px;1205
}1206
1207
.spawner-equip-icon[hidden] {1208
visibility: hidden;1209
}1210
1202
.spawner-equip-name {1211
.spawner-equip-name {1203
overflow: hidden;1212
overflow: hidden;1204
text-overflow: ellipsis;1213
text-overflow: ellipsis;@@ -1347,10 +1356,24 @@ label {1347
.shop-item-search-row {1356
.shop-item-search-row {1348
text-align: left;1357
text-align: left;1349
padding: 0.4rem 0.5rem;1358
padding: 0.4rem 0.5rem;1359
display: flex;1360
flex-direction: row;1361
align-items: center;1362
gap: 0.45rem;1363
}1364
1365
.shop-item-search-row-icon {1366
width: 16px;1367
height: 16px;1368
flex-shrink: 0;1369
}1370
1371
.shop-item-search-row-text {1350
display: flex;1372
display: flex;1351
flex-direction: column;1373
flex-direction: column;1352
align-items: flex-start;1374
align-items: flex-start;1353
gap: 0.1rem;1375
gap: 0.1rem;1376
min-width: 0;1354
}1377
}1355
1378
1356
.shop-item-search-row-name {1379
.shop-item-search-row-name {