forked from marcosvf132/TibiaAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLootContainer.cs
More file actions
72 lines (64 loc) · 2.95 KB
/
LootContainer.cs
File metadata and controls
72 lines (64 loc) · 2.95 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using OXGaming.TibiaAPI.Constants;
using OXGaming.TibiaAPI.Utilities;
namespace OXGaming.TibiaAPI.Network.ClientPackets
{
public class LootContainer : ClientPacket
{
Position Position { get; set; }
public ContainerManagerType Type { get; set; }
public ushort ObjectId { get; set; }
public byte Index { get; set; }
public byte ItemCategory { get; set; }
public bool UseMainContainerAsFallback { get; set; }
public LootContainer(Client client)
{
Client = client;
PacketType = ClientPacketType.LootContainer;
}
public override void ParseFromNetworkMessage(NetworkMessage message)
{
Type = (ContainerManagerType)message.ReadByte();
if (Type == ContainerManagerType.AddLoot) {
ItemCategory = message.ReadByte();
Position = message.ReadPosition();
ObjectId = message.ReadUInt16();
Index = message.ReadByte();
} else if (Type == ContainerManagerType.RemoveLoot || Type == ContainerManagerType.OpenLoot) {
ItemCategory = message.ReadByte();
} else if (Type == ContainerManagerType.UseMainContainerAsFallback) {
UseMainContainerAsFallback = message.ReadBool();
} else if (Type == ContainerManagerType.AddObtain) {
ItemCategory = message.ReadByte();
Position = message.ReadPosition();
ObjectId = message.ReadUInt16();
Index = message.ReadByte();
} else if (Type == ContainerManagerType.RemoveObtain || Type == ContainerManagerType.OpenObtain) {
ItemCategory = message.ReadByte();
} else {
Client.Logger.Error($"[LootContainer.ParseFromNetworkMessage] Invalid type: {Type}");
}
}
public override void AppendToNetworkMessage(NetworkMessage message)
{
message.Write((byte)ClientPacketType.LootContainer);
message.Write((byte)Type);
if (Type == ContainerManagerType.AddLoot) {
message.Write(ItemCategory);
message.Write(Position);
message.Write(ObjectId);
message.Write(Index);
} else if (Type == ContainerManagerType.RemoveLoot || Type == ContainerManagerType.OpenLoot) {
message.Write(ItemCategory);
} else if (Type == ContainerManagerType.AddObtain) {
message.Write(ItemCategory);
message.Write(Position);
message.Write(ObjectId);
message.Write(Index);
} else if (Type == ContainerManagerType.RemoveObtain || Type == ContainerManagerType.OpenObtain) {
message.Write(ItemCategory);
} else if (Type == ContainerManagerType.UseMainContainerAsFallback) {
message.Write(UseMainContainerAsFallback);
}
}
}
}