-
Notifications
You must be signed in to change notification settings - Fork 16
/
ItemActions.cs
81 lines (65 loc) · 2.36 KB
/
ItemActions.cs
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
73
74
75
76
77
78
79
80
81
using AutomaticTypeMapper;
using EOLib.Domain.Map;
using EOLib.Net;
using EOLib.Net.Communication;
namespace EOLib.Domain.Item
{
[AutoMappedType]
public class ItemActions : IItemActions
{
private readonly IPacketSendService _packetSendService;
public ItemActions(IPacketSendService packetSendService)
{
_packetSendService = packetSendService;
}
public void UseItem(short itemId)
{
var packet = new PacketBuilder(PacketFamily.Item, PacketAction.Use)
.AddShort(itemId)
.Build();
_packetSendService.SendPacket(packet);
}
public void EquipItem(short itemId, bool alternateLocation)
{
var packet = new PacketBuilder(PacketFamily.PaperDoll, PacketAction.Add)
.AddShort(itemId)
.AddChar((byte)(alternateLocation ? 1 : 0))
.Build();
_packetSendService.SendPacket(packet);
}
public void UnequipItem(short itemId, bool alternateLocation)
{
var packet = new PacketBuilder(PacketFamily.PaperDoll, PacketAction.Remove)
.AddShort(itemId)
.AddChar((byte)(alternateLocation ? 1 : 0))
.Build();
_packetSendService.SendPacket(packet);
}
public void DropItem(short itemId, int amount, MapCoordinate dropPoint)
{
var packet = new PacketBuilder(PacketFamily.Item, PacketAction.Drop)
.AddShort(itemId)
.AddInt(amount)
.AddChar((byte)dropPoint.X)
.AddChar((byte)dropPoint.Y)
.Build();
_packetSendService.SendPacket(packet);
}
public void JunkItem(short itemId, int amount)
{
var packet = new PacketBuilder(PacketFamily.Item, PacketAction.Junk)
.AddShort(itemId)
.AddInt(amount)
.Build();
_packetSendService.SendPacket(packet);
}
}
public interface IItemActions
{
void UseItem(short itemId);
void EquipItem(short itemId, bool alternateLocation);
void UnequipItem(short itemId, bool alternateLocation);
void DropItem(short itemId, int amount, MapCoordinate dropPoint);
void JunkItem(short itemId, int amount);
}
}