feat: conditional NPC dialogue
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -113,10 +113,15 @@ public class ReferenceResolver {
|
||||
*/
|
||||
public void resolveNpcs(List<NpcDto> npcDtos) {
|
||||
for (NpcDto dto : npcDtos) {
|
||||
Npc npc = npcs.get(dto.id());
|
||||
if (dto.dialogue() != null) {
|
||||
for (DialogueLineDto dl : dto.dialogue()) {
|
||||
npc.addDialogue(new DialogueLine(ConditionDto.toModelList(dl.when()), dl.text()));
|
||||
}
|
||||
}
|
||||
if (dto.reactions() == null) {
|
||||
continue;
|
||||
}
|
||||
Npc npc = npcs.get(dto.id());
|
||||
for (ReactionDto r : dto.reactions()) {
|
||||
if (r.onReceive() == null) {
|
||||
throw new WorldLoadException(
|
||||
|
||||
@@ -10,12 +10,18 @@ import java.util.List;
|
||||
* @param description examine description
|
||||
* @param greeting text the NPC says on {@code talk}
|
||||
* @param reactions list of trigger/response definitions; may be null
|
||||
* @param dialogue optional condition-gated dialogue lines; may be null
|
||||
*/
|
||||
public record NpcDto(
|
||||
String id,
|
||||
String name,
|
||||
String description,
|
||||
String greeting,
|
||||
List<ReactionDto> reactions
|
||||
List<ReactionDto> reactions,
|
||||
List<DialogueLineDto> dialogue
|
||||
) {
|
||||
/** Backward-compatible constructor without dialogue. */
|
||||
public NpcDto(String id, String name, String description, String greeting, List<ReactionDto> reactions) {
|
||||
this(id, name, description, greeting, reactions, null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user