-
Notifications
You must be signed in to change notification settings - Fork 4
/
player-shoot-packet.ts
54 lines (49 loc) · 1.3 KB
/
player-shoot-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
import { Writer } from '../../writer';
import { Reader } from '../../reader';
import { PacketType } from '../../packet-type';
import { Packet } from '../../packet';
import { WorldPosData } from '../../data/world-pos-data';
/**
* Sent when the player shoots a projectile.
*/
export class PlayerShootPacket implements Packet {
type = PacketType.PLAYERSHOOT;
propagate = true;
//#region packet-specific members
/**
* The current client time.
*/
time: number;
/**
* The id of the bullet which was fired.
*/
bulletId: number;
/**
* The item id of the weapon used to fire the projectile.
*/
containerType: number;
/**
* The position at which the projectile was fired.
*/
startingPos: WorldPosData;
/**
* The angle at which the projectile was fired.
*/
angle: number;
//#endregion
write(writer: Writer): void {
writer.writeInt32(this.time);
writer.writeByte(this.bulletId);
writer.writeShort(this.containerType);
this.startingPos.write(writer);
writer.writeFloat(this.angle);
}
read(reader: Reader): void {
this.time = reader.readInt32();
this.bulletId = reader.readByte();
this.containerType = reader.readShort();
this.startingPos = new WorldPosData();
this.startingPos.read(reader);
this.angle = reader.readFloat();
}
}