-
Notifications
You must be signed in to change notification settings - Fork 4
/
text-packet.ts
71 lines (66 loc) · 1.69 KB
/
text-packet.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { Writer } from '../../writer';
import { Reader } from '../../reader';
import { PacketType } from '../../packet-type';
import { Packet } from '../../packet';
/**
* Received when a chat message is sent by another player or NPC.
*/
export class TextPacket implements Packet {
type = PacketType.TEXT;
propagate = true;
//#region packet-specific members
/**
* The sender of the message.
*/
name: string;
/**
* The object id of the sender.
*/
objectId: number;
/**
* The number of stars of the sender.
*/
numStars: number;
/**
* The length of time to display the chat bubble for.
*/
bubbleTime: number;
/**
* The recipient of the message. This is only used if the
* message is a private message.
*/
recipient: string;
/**
* The content of the message.
*/
text: string;
/**
* > Unknown.
*/
cleanText: string;
/**
* Whether or not the sender of the message is a supporter.
*/
isSupporter: boolean;
//#endregion
read(reader: Reader): void {
this.name = reader.readString();
this.objectId = reader.readInt32();
this.numStars = reader.readInt32();
this.bubbleTime = reader.readUnsignedByte();
this.recipient = reader.readString();
this.text = reader.readString();
this.cleanText = reader.readString();
this.isSupporter = reader.readBoolean();
}
write(writer: Writer): void {
writer.writeString(this.name);
writer.writeInt32(this.objectId);
writer.writeInt32(this.numStars);
writer.writeUnsignedByte(this.bubbleTime);
writer.writeString(this.recipient);
writer.writeString(this.text);
writer.writeString(this.cleanText);
writer.writeBoolean(this.isSupporter);
}
}