auto-git:

[add] src/runtime-three/runtime-npc-presence.ts
This commit is contained in:
2026-04-13 23:48:38 +02:00
parent e5b23e882c
commit b711e0f10f

View File

@@ -0,0 +1,49 @@
import type { NpcPresence } from "../entities/entity-instances";
import {
hasTimeWindowJustEnded,
hasTimeWindowJustStarted,
isWithinTimeWindow
} from "./runtime-project-time";
export function resolveNpcPresenceActive(
presence: NpcPresence,
timeOfDayHours: number
): boolean {
switch (presence.mode) {
case "always":
return true;
case "timeWindow":
return isWithinTimeWindow(
presence.startHour,
presence.endHour,
timeOfDayHours
);
}
}
export function hasNpcPresenceActivityChanged(
presence: NpcPresence,
previousTimeOfDayHours: number,
currentTimeOfDayHours: number
): boolean {
switch (presence.mode) {
case "always":
return false;
case "timeWindow":
return (
hasTimeWindowJustStarted(
previousTimeOfDayHours,
currentTimeOfDayHours,
presence.startHour,
presence.endHour
) ||
hasTimeWindowJustEnded(
previousTimeOfDayHours,
currentTimeOfDayHours,
presence.startHour,
presence.endHour
)
);
}
}