-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract ChestActions out of MapActions
- Loading branch information
1 parent
a707282
commit e91e102
Showing
6 changed files
with
64 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Character; | ||
using EOLib.Net; | ||
using EOLib.Net.Communication; | ||
|
||
namespace EOLib.Domain.Map | ||
{ | ||
[AutoMappedType] | ||
public class ChestActions : IChestActions | ||
{ | ||
private readonly IPacketSendService _packetSendService; | ||
private readonly IChestDataProvider _chestDataProvider; | ||
|
||
public ChestActions(IPacketSendService packetSendService, | ||
IChestDataProvider chestDataProvider) | ||
{ | ||
_packetSendService = packetSendService; | ||
_chestDataProvider = chestDataProvider; | ||
} | ||
|
||
public void AddItemToChest(IInventoryItem item) | ||
{ | ||
var packet = new PacketBuilder(PacketFamily.Chest, PacketAction.Add) | ||
.AddChar((byte)_chestDataProvider.Location.X) | ||
.AddChar((byte)_chestDataProvider.Location.Y) | ||
.AddShort(item.ItemID) | ||
.AddThree(item.Amount) | ||
.Build(); | ||
|
||
_packetSendService.SendPacket(packet); | ||
} | ||
|
||
public void TakeItemFromChest(short itemId) | ||
{ | ||
var packet = new PacketBuilder(PacketFamily.Chest, PacketAction.Take) | ||
.AddChar((byte)_chestDataProvider.Location.X) | ||
.AddChar((byte)_chestDataProvider.Location.Y) | ||
.AddShort(itemId) | ||
.Build(); | ||
|
||
_packetSendService.SendPacket(packet); | ||
} | ||
} | ||
|
||
public interface IChestActions | ||
{ | ||
|
||
void AddItemToChest(IInventoryItem item); | ||
|
||
void TakeItemFromChest(short itemId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters