stable
This commit is contained in:
parent
8bd4405fe8
commit
d5c661bc22
53 changed files with 4264 additions and 950 deletions
|
|
@ -24,13 +24,13 @@
|
|||
},
|
||||
|
||||
beginEating(item = null, reason = "") {
|
||||
const text = reason || (item?.type && typeof toolLabel === "function" ? `${toolLabel(item.type)}を食べている` : "食べている");
|
||||
const text = reason || (item?.type && typeof toolLabel === "function" ? `${toolLabel(item.type)}\u3092\u98df\u3079\u3066\u3044\u308b` : "\u98df\u3079\u3066\u3044\u308b");
|
||||
const ok = this.setActionState("eat", {
|
||||
target: item || null,
|
||||
reason: text,
|
||||
sleeping: false,
|
||||
});
|
||||
if (typeof setLiveActionText === "function") setLiveActionText(this, { need: "food", actionId: "eat_food", actionLabel: "食べている", reasonText: text, target: item || null, phase: "perform", source: "behavior" });
|
||||
if (typeof setLiveActionText === "function") setLiveActionText(this, { need: "food", actionId: "eat_food", actionLabel: "\u98df\u3079\u3066\u3044\u308b", reasonText: text, target: item || null, phase: "perform", source: "behavior" });
|
||||
return ok;
|
||||
},
|
||||
|
||||
|
|
@ -48,8 +48,8 @@
|
|||
},
|
||||
|
||||
goIdle(reason = "") {
|
||||
if (typeof clearActiveBehavior === "function") clearActiveBehavior(this, reason || this.thought || "待っている");
|
||||
return this.setActionState("idle", { target: null, reason: reason || this.thought || "待っている", sleeping: false });
|
||||
if (typeof clearActiveBehavior === "function") clearActiveBehavior(this, reason || this.thought || "\u5f85\u3063\u3066\u3044\u308b");
|
||||
return this.setActionState("idle", { target: null, reason: reason || this.thought || "\u5f85\u3063\u3066\u3044\u308b", sleeping: false });
|
||||
},
|
||||
|
||||
startSleeping(target = null, reason = "") {
|
||||
|
|
@ -64,10 +64,8 @@
|
|||
targetId: target?.id || null,
|
||||
};
|
||||
}
|
||||
this.intent = this.intent || { need: "sleep", tiedNeeds: ["sleep"], actionId: target ? "sleep_in_bed" : "sleep_anywhere", actionLabel: reason || "眠っている", reasonText: "ねむいので、眠っている。", startedAt: now };
|
||||
this.currentAction = this.currentAction || { id: this.intent.actionId || "sleep", need: "sleep", startedAt: this.sleepSession.startedAt, minDuration: this.sleepSession.minDuration, lockSeconds: this.sleepSession.minDuration };
|
||||
const text = reason || (target?.type === "nest_box" ? "巣箱の中で眠っている" : "眠っている");
|
||||
if (typeof setLiveActionText === "function") setLiveActionText(this, { need: "sleep", actionId: target ? "sleep_in_bed" : "sleep_anywhere", actionLabel: "眠っている", reasonText: text, target, phase: "perform", source: "behavior" });
|
||||
const text = reason || (target?.type === "nest_box" ? "\u5de3\u7bb1\u306e\u4e2d\u3067\u7720\u3063\u3066\u3044\u308b" : "\u7720\u3063\u3066\u3044\u308b");
|
||||
if (typeof setLiveActionText === "function") setLiveActionText(this, { need: "sleep", actionId: target ? "sleep_in_bed" : "sleep_anywhere", actionLabel: "\u7720\u3063\u3066\u3044\u308b", reasonText: text, target, phase: "perform", source: "behavior" });
|
||||
return this.setActionState("sleep", { target, reason: text, sleeping: true });
|
||||
},
|
||||
|
||||
|
|
@ -82,7 +80,7 @@
|
|||
|
||||
currentBehaviorText() {
|
||||
if (typeof activeBehaviorText === "function") return activeBehaviorText(this);
|
||||
return String(this.activeBehavior?.presentText || this.activeBehavior?.reasonText || this.thought || "").trim();
|
||||
return String((typeof getTarinaiBehaviorText === "function" ? getTarinaiBehaviorText(this) : "") || this.thought || "").trim();
|
||||
},
|
||||
|
||||
enterPanic(opts = {}) {
|
||||
|
|
@ -100,18 +98,23 @@
|
|||
if (healthShock > 0) this.needShock.health = Math.max(this.needShock.health || 0, healthShock);
|
||||
}
|
||||
let handled = false;
|
||||
if (typeof triggerNeedShockReaction === "function") handled = triggerNeedShockReaction(this, threat, opts.reason || "パニックになっている");
|
||||
if (typeof triggerNeedShockReaction === "function") handled = triggerNeedShockReaction(this, threat, opts.reason || "\u30d1\u30cb\u30c3\u30af\u306b\u306a\u3063\u3066\u3044\u308b");
|
||||
if (!handled) {
|
||||
let target = null;
|
||||
if ("target" in opts) target = opts.target;
|
||||
else if (opts.destination) target = opts.destination;
|
||||
else if (this.panicDestination) target = this.panicDestination(threat, !!opts.forceDestination);
|
||||
const panicReason = opts.reason || this.thought || "\u30d1\u30cb\u30c3\u30af\u306b\u306a\u3063\u3066\u3044\u308b";
|
||||
this.setActionState("panic", {
|
||||
target,
|
||||
reason: opts.reason || this.thought || "パニックになっている",
|
||||
reason: panicReason,
|
||||
wake: opts.wake !== false,
|
||||
sleeping: false,
|
||||
});
|
||||
if (typeof setLiveActionText === "function") {
|
||||
const causeText = this.lastPanicDetail || (String(panicReason).includes("\u3001") ? String(panicReason).split("\u3001")[0].replace(/\u3066$/, "\u305f") : "\u6016\u3044");
|
||||
setLiveActionText(this, { need: "safety", actionId: "panic_escape", actionLabel: "\u30d1\u30cb\u30c3\u30af\u306b\u306a\u3063\u3066\u3044\u308b", reasonText: panicReason, causeText, target, phase: "perform", source: "behavior" });
|
||||
}
|
||||
this.fearTimer = Math.max(this.fearTimer || 0, 2.4);
|
||||
}
|
||||
if (Number.isFinite(opts.surpriseTimer)) this.surpriseTimer = Math.max(this.surpriseTimer || 0, opts.surpriseTimer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue