2026-06-25 14:51:58 +09:00
|
|
|
"use strict";
|
|
|
|
|
|
2026-06-28 23:07:40 +09:00
|
|
|
// Public facade joining the split item registry sources.
|
2026-06-25 14:51:58 +09:00
|
|
|
(function (global) {
|
|
|
|
|
function itemTypeDefinition(type = "") {
|
|
|
|
|
const id = String(type || "");
|
2026-06-28 23:07:40 +09:00
|
|
|
const tool = typeof global.itemDefinition === "function" ? global.itemDefinition(id) : null;
|
|
|
|
|
const foodDefinitions = global.TarinaiFoodDefinitions || {};
|
|
|
|
|
const effectDefinitions = global.TarinaiEffectDefinitions || {};
|
|
|
|
|
const visualDefinitions = global.TarinaiItemVisualDefinitions || {};
|
|
|
|
|
const traits = global.ITEM_TRAITS || global.TarinaiToolRegistry?.traits || {};
|
|
|
|
|
const food = foodDefinitions[id] || null;
|
|
|
|
|
const effectId = food?.effectId || (effectDefinitions[id] ? id : "");
|
|
|
|
|
const effect = effectId ? (effectDefinitions[effectId] || null) : null;
|
|
|
|
|
const visual = visualDefinitions[id] || null;
|
2026-06-25 14:51:58 +09:00
|
|
|
return {
|
|
|
|
|
id,
|
|
|
|
|
tool,
|
|
|
|
|
food,
|
|
|
|
|
effect,
|
|
|
|
|
effectId,
|
|
|
|
|
visual,
|
|
|
|
|
label: tool?.label || food?.label || effect?.label || id,
|
|
|
|
|
radius: tool?.radius,
|
|
|
|
|
amount: tool?.amount,
|
|
|
|
|
placeable: Boolean(tool?.placeable),
|
|
|
|
|
scalable: Boolean(tool?.scalable),
|
2026-06-28 23:07:40 +09:00
|
|
|
traits: Object.fromEntries(Object.keys(traits).map(trait => [trait, typeof global.itemHasTrait === "function" ? global.itemHasTrait(id, trait) : false])),
|
2026-06-25 14:51:58 +09:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function itemTypeLabel(type = "") {
|
|
|
|
|
return itemTypeDefinition(type).label;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function itemTypeDebugSnapshot() {
|
2026-06-28 23:07:40 +09:00
|
|
|
const toolDefinitions = global.TOOL_DEFINITIONS || global.TarinaiToolRegistry?.definitions || {};
|
|
|
|
|
const foodDefinitions = global.TarinaiFoodDefinitions || {};
|
|
|
|
|
const effectDefinitions = global.TarinaiEffectDefinitions || {};
|
|
|
|
|
const visualDefinitions = global.TarinaiItemVisualDefinitions || {};
|
2026-06-25 14:51:58 +09:00
|
|
|
const ids = new Set([
|
2026-06-28 23:07:40 +09:00
|
|
|
...Object.values(toolDefinitions).map(def => def.itemType || def.id),
|
|
|
|
|
...Object.keys(foodDefinitions),
|
|
|
|
|
...Object.keys(effectDefinitions),
|
|
|
|
|
...Object.keys(visualDefinitions),
|
2026-06-25 14:51:58 +09:00
|
|
|
]);
|
|
|
|
|
return [...ids].sort().map(id => itemTypeDefinition(id));
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-28 23:07:40 +09:00
|
|
|
global.itemTypeDefinition = itemTypeDefinition;
|
|
|
|
|
global.itemTypeLabel = itemTypeLabel;
|
|
|
|
|
global.itemTypeDebugSnapshot = itemTypeDebugSnapshot;
|
|
|
|
|
|
2026-06-25 14:51:58 +09:00
|
|
|
global.TarinaiItemRegistry = Object.freeze({
|
|
|
|
|
definition: itemTypeDefinition,
|
|
|
|
|
label: itemTypeLabel,
|
|
|
|
|
debugSnapshot: itemTypeDebugSnapshot,
|
2026-06-28 23:07:40 +09:00
|
|
|
tool: global.toolDefinition,
|
|
|
|
|
item: global.itemDefinition,
|
|
|
|
|
food: global.TarinaiFoodRegistry,
|
|
|
|
|
effect: global.TarinaiEffectRegistry,
|
|
|
|
|
visual: global.itemVisualDefinition,
|
|
|
|
|
hasTrait: global.itemHasTrait,
|
|
|
|
|
radius: global.itemRadiusFor,
|
|
|
|
|
amount: global.itemAmountFor,
|
|
|
|
|
categories: global.toolCategories,
|
|
|
|
|
physicsToolIds: () => [...(global.PHYSICS_TOOL_IDS || [])],
|
|
|
|
|
isFence: global.isFenceItemType,
|
|
|
|
|
isMechanical: global.isMechanicalItemType,
|
|
|
|
|
isLink: global.isLinkItemType,
|
|
|
|
|
scalableToolIds: global.scalableToolIds,
|
|
|
|
|
pinBehavior: global.pinBehaviorFor,
|
2026-06-25 14:51:58 +09:00
|
|
|
});
|
|
|
|
|
})(typeof window !== "undefined" ? window : globalThis);
|