RuneHive-Game
Loading...
Searching...
No Matches
NpcDialogue.java
Go to the documentation of this file.
1package com.runehive.content.dialogue;
2
3/**
4 * The {@link Chainable} implementation that represents dialogue in which an NPC is talking.
5 *
6 * @author Seven
7 */
8public final class NpcDialogue implements Chainable {
9
10 /**
11 * The id of this npc.
12 */
13 private int id = -1;
14
15 /**
16 * The expression of this NPC.
17 */
18 private final Expression expression;
19
20 /**
21 * The text for this dialogue.
22 */
23 private final String[] lines;
24
25 /**
26 * Creates a new {@link NpcDialogue}
27 *
28 * @param id
29 * The id of this npc.
30 *
31 * @param lines
32 * The text for this dialogue.
33 */
34 public NpcDialogue(int id, String... lines) {
35 this(id, Expression.DEFAULT, lines);
36 }
37
38 /**
39 * Creates a new {@link NpcDialogue}
40 *
41 * @param id
42 * The id of this npc.
43 *
44 * @param expression
45 * The expression of this npc.
46 *
47 * @param lines
48 * The text for this dialogue.
49 */
50 public NpcDialogue(int id, Expression expression, String... lines) {
51 this.id = id;
52 this.expression = expression;
53 this.lines = lines;
54 }
55
56 /**
57 * Gets the id of this npc.
58 *
59 * @return The id of this npc.
60 */
61 public int getId() {
62 return id;
63 }
64
65 /**
66 * Gets the expression of this npc.
67 *
68 * @return The expression.
69 */
71 return expression;
72 }
73
74 /**
75 * Gets the text for this dialogue.
76 *
77 * @return The text.
78 */
79 public String[] getLines() {
80 return lines;
81 }
82
83 @Override
84 public void accept(DialogueFactory factory) {
85 factory.sendNpcChat(this);
86 }
87}
Represents a factory class that contains important functions for building dialogues.
final DialogueFactory sendNpcChat(int id, String... lines)
Appends an NpcDialogue to the current dialogue chain.
NpcDialogue(int id, Expression expression, String... lines)
Creates a new NpcDialogue.
int getId()
Gets the id of this npc.
void accept(DialogueFactory factory)
final String[] lines
The text for this dialogue.
NpcDialogue(int id, String... lines)
Creates a new NpcDialogue.
String[] getLines()
Gets the text for this dialogue.
final Expression expression
The expression of this NPC.
Expression getExpression()
Gets the expression of this npc.
Represents the expressions of entities for dialogue.
The chain-able itemcontainer that allows implementing dialogue factories the ability to chain togethe...