aaa
This commit is contained in:
parent
f1c3af2b89
commit
2636d580a8
75 changed files with 3890 additions and 1084 deletions
|
|
@ -11,49 +11,88 @@
|
|||
"ball", "balloon", "fan", "genkotsu", "firecracker", "flame_firecracker", "sticky_bomb", "fire", "pushpin", "oshibyo",
|
||||
"plushie", "grass_bed", "zunchi", "robot_cleaner", "duplicator", "water", "trace", "splat", "ant_corpse", "food",
|
||||
"sweet", "love_mochi", "fight_mochi", "sleep_drug", "laxative", "protein", "niteropu", "ammo", "mystery_drug", "mercury", "giant_drug", "dwarf_drug", "zunda_juice",
|
||||
"stone", "bed", "nest_box", "pipe", "ant_nest", "signboard", "fence_v", "fence_h", "bounce_fence", "bounce_fence_v", "gate_fence", "rotator", "poison_block", "reciprocator", "rope", "rod",
|
||||
"stone", "bed", "nest_box", "pipe", "ant_nest", "signboard", "fence_v", "fence_h", "bounce_fence", "bounce_fence_v", "gate_fence", "one_way_fence", "rotator", "poison_block", "reciprocator", "rope", "rod", "spring", "wire", "insulated_wire", "pressure_switch",
|
||||
]);
|
||||
|
||||
function mobilePerfHint() {
|
||||
return Boolean(global.TarinaiInputMode.snapshot().touchFirst || (global.innerWidth || 9999) <= 760);
|
||||
|
||||
function itemSpeed(item) {
|
||||
if (!item) return 0;
|
||||
return Math.hypot(item.vx || 0, item.vy || 0, item.impulseVx || 0, item.impulseVy || 0);
|
||||
}
|
||||
|
||||
function itemRealtimeActive(item) {
|
||||
if (!item || item.dead) return false;
|
||||
if (!Number.isFinite(item._schedulerLastAt)) return true;
|
||||
const now = item.world?.time || 0;
|
||||
if (item.playerHeld || item._heldByPlayer || item.dragging || item.dropTimer > 0) return true;
|
||||
if (item.burning || (item.burnTimer || 0) > 0.02) return true;
|
||||
if (itemSpeed(item) > 0.08) return true;
|
||||
const activeUntil = Math.max(
|
||||
Number(item._activeUntil || -Infinity) || -Infinity,
|
||||
Number(item.awakeUntil || -Infinity) || -Infinity,
|
||||
Number(item.eatProtectedUntil || -Infinity) || -Infinity
|
||||
);
|
||||
if (activeUntil > now) return true;
|
||||
const lastActiveAt = Math.max(
|
||||
Number(item.lastKickedAt || -999) || -999,
|
||||
Number(item.lastShotAt || -999) || -999
|
||||
);
|
||||
if (now - lastActiveAt < 0.35) return true;
|
||||
// Fan wind is a continuous force. Scheduling it as an idle item turns the
|
||||
// accumulated dt into periodic gusts, so fans must remain in the realtime lane.
|
||||
if (item.type === "fan") return true;
|
||||
if (item.type === "firecracker" || item.type === "flame_firecracker" || item.type === "sticky_bomb") return Boolean(item.fuseTimer > 0 || item.armed || item.active);
|
||||
if (item.type === "robot_cleaner") return Boolean(item.active || item.cleanerActive || item.targetId || item.targetRef || item.state === "clean" || item.state === "return");
|
||||
if (PIN_ITEM_TYPES.has(item.type)) return Boolean(item.pinState && item.pinState !== "idle" && item.pinState !== "ground");
|
||||
if (item.type === "plushie") return Boolean(item.carriedById || item.onHead);
|
||||
return false;
|
||||
}
|
||||
|
||||
function idleRealtimeInterval(item) {
|
||||
if (!item) return Infinity;
|
||||
if (item.type === "ball" || item.type === "balloon") return 0.24;
|
||||
if (item.type === "fan") return 0.60;
|
||||
if (item.type === "genkotsu") return 0.45;
|
||||
if (item.type === "firecracker" || item.type === "flame_firecracker" || item.type === "sticky_bomb") return 0.35;
|
||||
if (item.type === "robot_cleaner") return 0.75;
|
||||
if (PIN_ITEM_TYPES.has(item.type)) return 0.80;
|
||||
if (item.isStructure && item.type === "plushie") return 0.95;
|
||||
return 0.80;
|
||||
}
|
||||
|
||||
function adjustedInterval(baseInterval) {
|
||||
if (!Number.isFinite(baseInterval) || baseInterval <= 0) return baseInterval;
|
||||
const profile = global.TarinaiPerf?.performanceProfile?.();
|
||||
if (profile?.simulationThrottled === false) return 0;
|
||||
return baseInterval * Math.max(1, Number(profile?.itemCadenceScale || 1));
|
||||
}
|
||||
|
||||
function itemUpdateInterval(item) {
|
||||
if (!item || item.dead) return Infinity;
|
||||
const mobile = mobilePerfHint();
|
||||
// Mechanical bodies and links are owned by the central physics step.
|
||||
// Keeping them out of the per-item scheduler prevents N independent
|
||||
// collision passes and makes future physics-format changes cheaper.
|
||||
if (item.type === "rotator" || item.type === "reciprocator" || item.type === "poison_block" || item.type === "rope" || item.type === "rod") return Infinity;
|
||||
if (REALTIME_ITEM_TYPES.has(item.type)) return 0;
|
||||
if (PIN_ITEM_TYPES.has(item.type)) return 0;
|
||||
if (item.isStructure && item.type === "plushie") return 0;
|
||||
if (item.isStructure && item.type === "grass_bed") return 3.0;
|
||||
if (item.type === "fire") {
|
||||
const fireCount = item.world?.itemsOfType?.("fire")?.length || 0;
|
||||
if (fireCount > 64) return mobile ? 0.55 : 0.35;
|
||||
if (fireCount > 36) return mobile ? 0.42 : 0.25;
|
||||
return mobile ? 0.30 : 0.18;
|
||||
}
|
||||
if (item.type === "nest_box" && global.TarinaiItemDynamicToolSystem?.nestBoxFireActive?.(item)) return mobile ? 0.30 : 0.18;
|
||||
if (item.type === "rotator" || item.type === "reciprocator" || item.type === "poison_block" || item.type === "rope" || item.type === "rod" || item.type === "spring" || item.type === "wire" || item.type === "insulated_wire" || item.type === "pressure_switch") return Infinity;
|
||||
if (REALTIME_ITEM_TYPES.has(item.type)) return itemRealtimeActive(item) ? 0 : adjustedInterval(idleRealtimeInterval(item));
|
||||
if (PIN_ITEM_TYPES.has(item.type)) return itemRealtimeActive(item) ? 0 : adjustedInterval(idleRealtimeInterval(item));
|
||||
if (item.isStructure && item.type === "plushie") return itemRealtimeActive(item) ? 0 : adjustedInterval(idleRealtimeInterval(item));
|
||||
if (item.isStructure && item.type === "grass_bed") return adjustedInterval(3.0);
|
||||
if (item.type === "fire") return adjustedInterval(0.18);
|
||||
if (item.type === "nest_box" && global.TarinaiItemDynamicToolSystem?.nestBoxFireActive?.(item)) return adjustedInterval(0.18);
|
||||
if ((item.dropTimer || 0) > 0 || Math.hypot(item.vx || 0, item.vy || 0) > 0.08) return 0;
|
||||
if (item.type === "zunchi" && (item.burning || (item.burnTimer || 0) > 0.02)) return mobile ? 0.30 : 0.18;
|
||||
if (item.type === "zunchi" && (item.burning || (item.burnTimer || 0) > 0.02)) return adjustedInterval(0.18);
|
||||
if (item.type === "zunchi") {
|
||||
const groundId = item.world?.groundType || (typeof world !== "undefined" ? world?.groundType : "") || "soil";
|
||||
const decayMul = Number(global.TarinaiGround?.zunchiDecayMultiplier?.(groundId) || 1) || 1;
|
||||
// High-decay grounds need a shorter update cadence; otherwise the amount
|
||||
// changes only once every few seconds and the laboratory effect looks idle.
|
||||
if (decayMul >= 100) return mobile ? 0.18 : 0.12;
|
||||
if (decayMul > 1.01) return mobile ? 0.42 : 0.28;
|
||||
return 2.4;
|
||||
if (decayMul >= 100) return adjustedInterval(0.12);
|
||||
if (decayMul > 1.01) return adjustedInterval(0.28);
|
||||
return adjustedInterval(2.4);
|
||||
}
|
||||
if (item.type === "grass") return Infinity;
|
||||
if (item.type === "duplicator") return mobile ? 0.8 : 0.5;
|
||||
if (item.type === "water") return mobile ? 2.4 : 1.8;
|
||||
if (item.type === "trace" || item.type === "splat") return mobile ? 1.8 : 1.2;
|
||||
if (item.type === "ant_corpse") return 3.5;
|
||||
if (typeof global.isServingFoodType === "function" && global.isServingFoodType(item.type)) return 5.0;
|
||||
if (isServingFoodType(item.type)) return 5.0;
|
||||
if (item.type === "duplicator") return adjustedInterval(0.5);
|
||||
if (item.type === "water") return adjustedInterval(1.8);
|
||||
if (item.type === "trace" || item.type === "splat") return adjustedInterval(1.2);
|
||||
if (item.type === "ant_corpse") return adjustedInterval(3.5);
|
||||
if (typeof global.isServingFoodType === "function" && global.isServingFoodType(item.type)) return adjustedInterval(5.0);
|
||||
if (isServingFoodType(item.type)) return adjustedInterval(5.0);
|
||||
return Infinity;
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +132,7 @@
|
|||
|
||||
global.TarinaiItemUpdatePolicy = Object.freeze({
|
||||
itemUpdateInterval,
|
||||
itemRealtimeActive,
|
||||
forScheduledItems,
|
||||
ensureBuckets,
|
||||
candidateItems,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue