e
This commit is contained in:
parent
f657b6a4a4
commit
d163ceb291
76 changed files with 1385 additions and 524 deletions
|
|
@ -143,6 +143,53 @@ function inheritedChampionPersonality(seed = "", parents = [], opts = {}) {
|
|||
return ["\u304b\u3093\u305f\u3093\u30d9\u30c3\u30c9", `\u6301\u3061\u4e3b: ${owner?.name || "\u4e0d\u660e"}`, worldRef.temperatureTooltipLineFor?.(bed, "\u5468\u8fba\u6c17\u6e29")].filter(Boolean);
|
||||
}
|
||||
|
||||
|
||||
function pointerObjectTooltipInfoLocal(worldRef) {
|
||||
const p = worldRef?.pointer;
|
||||
if (!p?.inside) return null;
|
||||
const nearby = worldRef.nearbyItems?.(p.x, p.y, 150) || worldRef.nearbyNonGrassItems?.(p.x, p.y, 150) || [];
|
||||
let best = null;
|
||||
let bestDistance = Infinity;
|
||||
const sleepFurniture = global.TarinaiItemToolMetadata?.ITEM_TRAITS?.sleepFurniture || null;
|
||||
for (const item of nearby) {
|
||||
if (!item || item.dead || item.type === "trace" || item.type === "splat") continue;
|
||||
const isSleepFurniture = sleepFurniture?.has?.(item.type) || ["bed", "nest_box", "pipe", "grass_bed"].includes(item.type);
|
||||
if (!isSleepFurniture) continue;
|
||||
const isNest = global.TarinaiToolRuntime?.isNestContainerItem?.(item);
|
||||
const isOwnedBed = item.type === "grass_bed";
|
||||
const fallbackDistance = distXY(p.x, p.y, Number(item.x || 0), Number(item.y || 0));
|
||||
let hit = false;
|
||||
let hitDistance = fallbackDistance;
|
||||
const hitTest = global.TarinaiCollisionFootprints?.hitTestItem;
|
||||
if (typeof hitTest === "function") {
|
||||
const result = hitTest(worldRef, item, p.x, p.y, {
|
||||
padding: worldRef.screenSizeToWorld ? worldRef.screenSizeToWorld(5) : 5,
|
||||
radiusMultiplier: 1.15,
|
||||
}) || null;
|
||||
hit = Boolean(result?.hit);
|
||||
if (Number.isFinite(Number(result?.distance))) hitDistance = Number(result.distance);
|
||||
} else {
|
||||
hit = fallbackDistance <= Math.max(30, (Number(item.r) || 18) * 1.35);
|
||||
}
|
||||
if (!hit || hitDistance >= bestDistance) continue;
|
||||
best = item;
|
||||
bestDistance = hitDistance;
|
||||
}
|
||||
if (!best) return null;
|
||||
if (global.TarinaiToolRuntime?.isNestContainerItem?.(best)) {
|
||||
return { target: best, lines: worldRef.nestBoxTooltipLines?.(best) || [], kind: best.type === "pipe" ? "pipe" : "nest_box" };
|
||||
}
|
||||
if (best.type === "grass_bed") {
|
||||
return { target: best, lines: ownedBedTooltipLinesLocal(worldRef, best), kind: "grass_bed" };
|
||||
}
|
||||
const definition = global.TarinaiToolRuntime?.itemDefinition?.(best.type) || null;
|
||||
const lines = [definition?.label || String(best.type || "\u30aa\u30d6\u30b8\u30a7\u30af\u30c8")];
|
||||
if (definition?.tooltip) lines.push(definition.tooltip);
|
||||
const temperatureLine = worldRef.temperatureTooltipLineFor?.(best, "\u5468\u8fba\u6c17\u6e29");
|
||||
if (temperatureLine && (best.isStructure || best.type === "toilet" || best.type === "rain_shelter")) lines.push(temperatureLine);
|
||||
return { target: best, lines: lines.filter(Boolean), kind: "object" };
|
||||
}
|
||||
|
||||
Object.defineProperties(World.prototype, Object.getOwnPropertyDescriptors({
|
||||
reset(seedPopulation = null, fieldType = this.fieldType || "garden", presetId = "default") {
|
||||
const field = FIELD_TYPES?.[fieldType] || FIELD_TYPES.garden;
|
||||
|
|
@ -690,17 +737,18 @@ function inheritedChampionPersonality(seed = "", parents = [], opts = {}) {
|
|||
},
|
||||
|
||||
pointerItemTooltipInfo() {
|
||||
// Precise object hit-testing comes first; only if no object is actually
|
||||
// under the pointer do we fall back to the Tarinai tooltip.
|
||||
const objectInfo = pointerObjectTooltipInfoLocal(this);
|
||||
if (objectInfo?.target) return objectInfo;
|
||||
const tarinaiInfo = pointerTarinaiTooltipInfoLocal(this);
|
||||
if (tarinaiInfo?.target) return tarinaiInfo;
|
||||
const nest = this.pointerNestBoxInfo?.();
|
||||
if (nest?.box) return { target: nest.box, lines: this.nestBoxTooltipLines(nest.box), kind: nest.box?.type === "pipe" ? "pipe" : "nest_box" };
|
||||
const bedInfo = pointerOwnedBedInfoLocal(this);
|
||||
if (bedInfo?.bed) return { target: bedInfo.bed, lines: ownedBedTooltipLinesLocal(this, bedInfo.bed), kind: "grass_bed" };
|
||||
return null;
|
||||
},
|
||||
|
||||
startBirthRitual(a, b) {
|
||||
if (!a || !b || a.dead || b.dead) return false;
|
||||
if (a.juvenile || b.juvenile) return false;
|
||||
if (!(this.canAddTarinai?.(1) ?? true)) return false;
|
||||
if (!this.tarinai?.includes?.(a) || !this.tarinai?.includes?.(b)) return false;
|
||||
if (!!a.isZunchiSlave !== !!b.isZunchiSlave) return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue