not bad
This commit is contained in:
parent
2741b93dea
commit
434f07cc4e
103 changed files with 8387 additions and 8152 deletions
75
js/world_event_effects.js
Normal file
75
js/world_event_effects.js
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
"use strict";
|
||||
|
||||
(function (global) {
|
||||
const events = global.TarinaiEvents;
|
||||
if (!events || events.__worldEventEffectsBound) return;
|
||||
events.__worldEventEffectsBound = true;
|
||||
|
||||
events.on("world:phase", () => {
|
||||
global.audio?.phase?.();
|
||||
});
|
||||
|
||||
function playLogSoundForEntry(entry = {}) {
|
||||
if (!entry || entry.hiddenFromObservation || entry.sound === false || entry.silentAudio) return;
|
||||
const audio = global.audio;
|
||||
if (!audio) return;
|
||||
const kind = entry.kind || "note";
|
||||
const text = String(entry.text || "");
|
||||
if (kind === "death") return audio.death?.();
|
||||
if (kind === "birth") return audio.birth?.();
|
||||
if (kind === "fight") return /決着|勝|負|覚え/.test(text) ? audio.fightFinish?.() : audio.fight?.();
|
||||
if (kind === "food") return audio.eat?.();
|
||||
if (kind === "grass") return audio.play?.("sfx_grass", { category: "ops", minGap: 0.25 });
|
||||
if (kind === "weather") return audio.phase?.();
|
||||
if (kind === "relation") return audio.notify?.();
|
||||
if (kind === "accident") {
|
||||
if (/配置|置いた|設置/.test(text)) return audio.place?.(/爆竹/.test(text) ? "firecracker" : "");
|
||||
if (/げんこつ/.test(text)) return audio.genkotsuImpact?.();
|
||||
if (/爆竹|爆発/.test(text)) return audio.explode?.();
|
||||
if (/石/.test(text)) return audio.stoneImpact?.();
|
||||
if (/ボール/.test(text)) return audio.ballHit?.();
|
||||
return audio.damage?.(18);
|
||||
}
|
||||
if (kind === "event") {
|
||||
if (/女王アリ/.test(text)) return audio.queenAnt?.();
|
||||
if (/アリ|巣/.test(text)) return audio.antNest?.();
|
||||
if (/病|発病/.test(text)) return audio.disease?.();
|
||||
if (/回復|治/.test(text)) return audio.heal?.();
|
||||
}
|
||||
}
|
||||
|
||||
function renderFreezePanel(worldRef) {
|
||||
if (global.TarinaiFreezePanel?.render && global.TarinaiFreezeStore?.frozenList) {
|
||||
global.TarinaiFreezePanel.render(global.TarinaiFreezeStore.frozenList(worldRef));
|
||||
return;
|
||||
}
|
||||
global.TarinaiFreezeSystem?.renderFrozenPanel?.(worldRef);
|
||||
}
|
||||
|
||||
|
||||
events.on("log:entry", (event) => {
|
||||
const detail = event.detail || {};
|
||||
const worldRef = detail.world || global.world;
|
||||
const entry = detail.entry;
|
||||
if (!entry) return;
|
||||
playLogSoundForEntry(entry);
|
||||
if (typeof renderLog === "function") renderLog(worldRef?.logs || []);
|
||||
if (typeof pushLogNotification === "function") pushLogNotification(entry);
|
||||
});
|
||||
|
||||
events.on("tool:placed", (event) => {
|
||||
const detail = event.detail || {};
|
||||
if (detail.dropped) global.audio?.place?.(detail.type || detail.item?.type || "");
|
||||
});
|
||||
|
||||
events.on("freeze:changed", (event) => {
|
||||
const detail = event.detail || {};
|
||||
const worldRef = detail.world || global.world;
|
||||
renderFreezePanel(worldRef);
|
||||
if (detail.renderWorld !== false) {
|
||||
if (typeof renderSelected === "function") renderSelected();
|
||||
if (typeof renderStats === "function") renderStats();
|
||||
if (typeof render === "function") render();
|
||||
}
|
||||
});
|
||||
})(typeof window !== "undefined" ? window : globalThis);
|
||||
Loading…
Add table
Add a link
Reference in a new issue