forked from marcosvf132/TibiaAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImpactTracking.cs
More file actions
57 lines (49 loc) · 1.93 KB
/
ImpactTracking.cs
File metadata and controls
57 lines (49 loc) · 1.93 KB
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
using OXGaming.TibiaAPI.Constants;
using System;
namespace OXGaming.TibiaAPI.Network.ServerPackets
{
public class ImpactTracking : ServerPacket
{
public uint Amount { get; set; }
public string Target { get; set; }
public bool IsDamage { get; set; }
public ElementType Element { get; set; }
public byte Type { get; set; }
public ImpactTracking(Client client)
{
Client = client;
PacketType = ServerPacketType.ImpactTracking;
}
public override void ParseFromNetworkMessage(NetworkMessage message)
{
Type = message.ReadByte();
if (Type == (byte)ImpactAnalyzer.Heal) {
Amount = message.ReadUInt32();
} else if (Type == (byte)ImpactAnalyzer.DamageDealt) {
Amount = message.ReadUInt32();
Element = (ElementType)message.ReadByte();
} else if (Type == (byte)ImpactAnalyzer.DamageReceived) {
Amount = message.ReadUInt32();
Element = (ElementType)message.ReadByte();
Target = message.ReadString();
} else {
throw new Exception($"[ImpactTracking.ParseFromNetworkMessage] Unknown impact type {Type}.");
}
}
public override void AppendToNetworkMessage(NetworkMessage message)
{
message.Write((byte)ServerPacketType.ImpactTracking);
message.Write(Type);
if (Type == (byte)ImpactAnalyzer.Heal) {
message.Write(Amount);
} else if (Type == (byte)ImpactAnalyzer.DamageDealt) {
Amount = message.ReadUInt32();
message.Write((byte)Element);
} else if (Type == (byte)ImpactAnalyzer.DamageReceived) {
message.Write(Amount);
message.Write((byte)Element);
message.Write(Target);
}
}
}
}