1
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-04-20 11:30:19 +08:00
parent 50759f3c1e
commit 8a7bd90458
85 changed files with 7290 additions and 1903 deletions

View File

@@ -15,6 +15,10 @@ import {
getSceneHostileNpcs,
getWorldCampScenePreset,
} from './scenePresets';
import {
canUseLimitedPrimaryNpcChat,
resolveActiveSceneActEncounterNpcIds,
} from '../services/customWorldSceneActRuntime';
export const EXPLORE_APPROACH_DURATION_MS = 4000;
export const PREVIEW_ENTITY_X_METERS = 12;
@@ -33,6 +37,18 @@ function getResolvedNpcState(state: GameState, encounter: Encounter) {
function shouldAutoStartBattleForEncounter(state: GameState, encounter: Encounter) {
if (encounter.kind !== 'npc') return false;
const npcState = getResolvedNpcState(state, encounter);
const npcId = getNpcEncounterKey(encounter);
if (
canUseLimitedPrimaryNpcChat({
profile: state.customWorldProfile,
sceneId: state.currentScenePreset?.id ?? null,
storyEngineMemory: state.storyEngineMemory,
npcId,
affinity: npcState.affinity,
})
) {
return false;
}
return npcState.affinity < 0 || (npcState.relationState?.affinity ?? npcState.affinity) < 0;
}
@@ -91,11 +107,23 @@ function getAvailableFriendlySceneNpcs(state: GameState) {
&& state.currentScenePreset?.id
&& getWorldCampScenePreset(state.worldType)?.id === state.currentScenePreset.id,
);
const activeActNpcIds = resolveActiveSceneActEncounterNpcIds({
profile: state.customWorldProfile,
sceneId: state.currentScenePreset?.id ?? null,
storyEngineMemory: state.storyEngineMemory,
});
const activeActNpcIdSet = new Set(activeActNpcIds);
return getSceneFriendlyNpcs(state.currentScenePreset)
.filter(candidate => !isCampScene || Boolean(candidate.characterId))
.filter(candidate => candidate.characterId !== state.playerCharacter?.id)
.filter(candidate => !recruitedNpcIds.has(candidate.id));
.filter(candidate => !recruitedNpcIds.has(candidate.id))
.filter(candidate =>
activeActNpcIdSet.size === 0
? true
: activeActNpcIdSet.has(candidate.id)
|| (candidate.characterId ? activeActNpcIdSet.has(candidate.characterId) : false),
);
}
function getAvailableHostileSceneNpcs(state: GameState) {