From c1249b6d00a6f453820236c31296771f1aab3197 Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Wed, 27 Apr 2022 20:42:37 -0700 Subject: [PATCH] Rename Item -> MapItem and add [Record] attribute. Remove IItem interface. --- .../BuiltInIdentifierConfigurator.cs | 2 +- EOBot/TrainerBot.cs | 4 +- EOLib/Domain/Item/ItemPickupValidator.cs | 4 +- EOLib/Domain/Login/LoginActions.cs | 2 +- .../Domain/Login/LoginRequestCompletedData.cs | 2 +- EOLib/Domain/Map/CurrentMapStateRepository.cs | 11 +- EOLib/Domain/Map/IMapCellState.cs | 2 +- EOLib/Domain/Map/Item.cs | 127 ------------------ EOLib/Domain/Map/MapActions.cs | 4 +- EOLib/Domain/Map/MapCellState.cs | 4 +- EOLib/Domain/Map/MapItem.cs | 39 ++++++ EOLib/Domain/Map/RefreshReplyPacketData.cs | 14 +- EOLib/Domain/Map/WarpAgreePacketData.cs | 14 +- .../Translators/MapStatePacketTranslator.cs | 8 +- EOLib/PacketHandlers/EndPlayerWarpHandler.cs | 2 +- EOLib/PacketHandlers/Items/DropItemHandler.cs | 6 +- .../Items/OtherPlayerDropItemHandler.cs | 6 +- EOLib/PacketHandlers/MainPlayerWalkHandler.cs | 2 +- EOLib/PacketHandlers/NPCLeaveMapHandler.cs | 7 +- .../PacketHandlers/RefreshMapStateHandler.cs | 2 +- .../Controllers/MapInteractionController.cs | 4 +- .../HUD/Inventory/InventorySpaceValidator.cs | 4 +- .../Rendering/MouseCursorRenderer.cs | 4 +- 23 files changed, 93 insertions(+), 181 deletions(-) delete mode 100644 EOLib/Domain/Map/Item.cs create mode 100644 EOLib/Domain/Map/MapItem.cs diff --git a/EOBot/Interpreter/BuiltInIdentifierConfigurator.cs b/EOBot/Interpreter/BuiltInIdentifierConfigurator.cs index 05e625701..6cac73f90 100644 --- a/EOBot/Interpreter/BuiltInIdentifierConfigurator.cs +++ b/EOBot/Interpreter/BuiltInIdentifierConfigurator.cs @@ -282,7 +282,7 @@ private IVariable GetMapStateNPC(NPC npc) return npcObj; } - private IVariable GetMapStateItem(IItem item) + private IVariable GetMapStateItem(MapItem item) { var itemFile = DependencyMaster.TypeRegistry[_botIndex].Resolve().EIFFile; diff --git a/EOBot/TrainerBot.cs b/EOBot/TrainerBot.cs index 6968aed1e..1017852c3 100644 --- a/EOBot/TrainerBot.cs +++ b/EOBot/TrainerBot.cs @@ -297,7 +297,7 @@ private async Task PickUpItems(IMapCellState cellState) } } - private async Task PickUpItem(IItem item) + private async Task PickUpItem(MapItem item) { await TrySend(() => { @@ -311,7 +311,7 @@ await TrySend(() => await Task.Delay(TimeSpan.FromMilliseconds(ATTACK_BACKOFF_MS)); } - private async Task JunkItem(IItem item) + private async Task JunkItem(MapItem item) { ConsoleHelper.WriteMessage(ConsoleHelper.Type.JunkItem, $"{item.Amount,7} - {_itemData.Single(x => x.ID == item.ItemID).Name}"); await TrySend(() => _itemActions.JunkItem(item.ItemID, item.Amount)); diff --git a/EOLib/Domain/Item/ItemPickupValidator.cs b/EOLib/Domain/Item/ItemPickupValidator.cs index 828a31b54..5ce014970 100644 --- a/EOLib/Domain/Item/ItemPickupValidator.cs +++ b/EOLib/Domain/Item/ItemPickupValidator.cs @@ -21,7 +21,7 @@ public ItemPickupValidator(IConfigurationProvider configurationProvider, _eifFileProvider = eifFileProvider; } - public ItemPickupResult ValidateItemPickup(Character.Character mainCharacter, IItem item) + public ItemPickupResult ValidateItemPickup(Character.Character mainCharacter, MapItem item) { var now = DateTime.Now; @@ -58,6 +58,6 @@ public ItemPickupResult ValidateItemPickup(Character.Character mainCharacter, II public interface IItemPickupValidator { - ItemPickupResult ValidateItemPickup(Character.Character mainCharacter, IItem item); + ItemPickupResult ValidateItemPickup(Character.Character mainCharacter, MapItem item); } } diff --git a/EOLib/Domain/Login/LoginActions.cs b/EOLib/Domain/Login/LoginActions.cs index 22098c9b9..18472e41b 100644 --- a/EOLib/Domain/Login/LoginActions.cs +++ b/EOLib/Domain/Login/LoginActions.cs @@ -185,7 +185,7 @@ public async Task CompleteCharacterLogin(short sessionID) _currentMapStateRepository.Characters = data.MapCharacters.Except(new[] { mainCharacter }).ToDictionary(k => k.ID, v => v); _currentMapStateRepository.NPCs = new HashSet(data.MapNPCs); - _currentMapStateRepository.MapItems = new HashSet(data.MapItems); + _currentMapStateRepository.MapItems = new HashSet(data.MapItems); _playerInfoRepository.PlayerIsInGame = true; _characterSessionRepository.ResetState(); diff --git a/EOLib/Domain/Login/LoginRequestCompletedData.cs b/EOLib/Domain/Login/LoginRequestCompletedData.cs index cd6d3310f..ac88e7ac7 100644 --- a/EOLib/Domain/Login/LoginRequestCompletedData.cs +++ b/EOLib/Domain/Login/LoginRequestCompletedData.cs @@ -23,7 +23,7 @@ public sealed partial class LoginRequestCompletedData : ITranslatedData public IReadOnlyList MapNPCs { get; } - public IReadOnlyList MapItems { get; } + public IReadOnlyList MapItems { get; } public CharacterLoginReply Error { get; } } diff --git a/EOLib/Domain/Map/CurrentMapStateRepository.cs b/EOLib/Domain/Map/CurrentMapStateRepository.cs index 28310f741..2516b4267 100644 --- a/EOLib/Domain/Map/CurrentMapStateRepository.cs +++ b/EOLib/Domain/Map/CurrentMapStateRepository.cs @@ -1,5 +1,4 @@ using AutomaticTypeMapper; -using EOLib.Domain.Character; using System.Collections.Generic; namespace EOLib.Domain.Map @@ -16,7 +15,7 @@ public interface ICurrentMapStateRepository HashSet NPCs { get; set; } - HashSet MapItems { get; set; } + HashSet MapItems { get; set; } HashSet OpenDoors { get; set; } @@ -43,7 +42,7 @@ public interface ICurrentMapStateProvider IReadOnlyCollection NPCs { get; } - IReadOnlyCollection MapItems { get; } + IReadOnlyCollection MapItems { get; } IReadOnlyCollection OpenDoors { get; } @@ -71,7 +70,7 @@ public class CurrentMapStateRepository : ICurrentMapStateRepository, ICurrentMap public HashSet NPCs { get; set; } - public HashSet MapItems { get; set; } + public HashSet MapItems { get; set; } public HashSet OpenDoors { get; set; } @@ -89,7 +88,7 @@ public class CurrentMapStateRepository : ICurrentMapStateRepository, ICurrentMap IReadOnlyCollection ICurrentMapStateProvider.NPCs => NPCs; - IReadOnlyCollection ICurrentMapStateProvider.MapItems => MapItems; + IReadOnlyCollection ICurrentMapStateProvider.MapItems => MapItems; IReadOnlyCollection ICurrentMapStateProvider.OpenDoors => OpenDoors; @@ -110,7 +109,7 @@ public void ResetState() Characters = new Dictionary(); NPCs = new HashSet(); - MapItems = new HashSet(); + MapItems = new HashSet(); OpenDoors = new HashSet(); PendingDoors = new HashSet(); VisibleSpikeTraps = new HashSet(); diff --git a/EOLib/Domain/Map/IMapCellState.cs b/EOLib/Domain/Map/IMapCellState.cs index f06e89a3c..68bbe041b 100644 --- a/EOLib/Domain/Map/IMapCellState.cs +++ b/EOLib/Domain/Map/IMapCellState.cs @@ -11,7 +11,7 @@ public interface IMapCellState MapCoordinate Coordinate { get; } - IReadOnlyList Items { get; } + IReadOnlyList Items { get; } TileSpec TileSpec { get; } diff --git a/EOLib/Domain/Map/Item.cs b/EOLib/Domain/Map/Item.cs deleted file mode 100644 index af4efb829..000000000 --- a/EOLib/Domain/Map/Item.cs +++ /dev/null @@ -1,127 +0,0 @@ -using Optional; -using System; - -namespace EOLib.Domain.Map -{ - public class Item : IItem - { - public short UniqueID { get; } - - public short ItemID { get; } - - public byte X { get; } - - public byte Y { get; } - - public int Amount { get; private set; } - - public bool IsNPCDrop { get; private set; } - - public Option OwningPlayerID { get; private set; } - - public Option DropTime { get; private set; } - - public static IItem None => new Item(0, 0, 0, 0); - - public Item(short uid, short itemID, byte x, byte y) - { - UniqueID = uid; - ItemID = itemID; - X = x; - Y = y; - } - - public IItem WithAmount(int newAmount) - { - var newItem = MakeCopy(this); - newItem.Amount = newAmount; - return newItem; - } - - public IItem WithIsNPCDrop(bool isNPCDrop) - { - var newItem = MakeCopy(this); - newItem.IsNPCDrop = isNPCDrop; - return newItem; - } - - public IItem WithOwningPlayerID(int owningPlayerID) - { - var newItem = MakeCopy(this); - newItem.OwningPlayerID = Option.Some(owningPlayerID); - return newItem; - } - - public IItem WithDropTime(DateTime dropTime) - { - var newItem = MakeCopy(this); - newItem.DropTime = Option.Some(dropTime); - return newItem; - } - - private static Item MakeCopy(IItem input) - { - return new Item(input.UniqueID, input.ItemID, input.X, input.Y) - { - Amount = input.Amount, - IsNPCDrop = input.IsNPCDrop, - OwningPlayerID = input.OwningPlayerID, - DropTime = input.DropTime - }; - } - - public override bool Equals(object obj) - { - return obj is Item item && - UniqueID == item.UniqueID && - ItemID == item.ItemID && - X == item.X && - Y == item.Y && - Amount == item.Amount && - IsNPCDrop == item.IsNPCDrop && - OwningPlayerID.Equals(item.OwningPlayerID) && - DropTime.Equals(item.DropTime); - } - - public override int GetHashCode() - { - int hashCode = -885092675; - hashCode = hashCode * -1521134295 + UniqueID.GetHashCode(); - hashCode = hashCode * -1521134295 + ItemID.GetHashCode(); - hashCode = hashCode * -1521134295 + X.GetHashCode(); - hashCode = hashCode * -1521134295 + Y.GetHashCode(); - hashCode = hashCode * -1521134295 + Amount.GetHashCode(); - hashCode = hashCode * -1521134295 + IsNPCDrop.GetHashCode(); - hashCode = hashCode * -1521134295 + OwningPlayerID.GetHashCode(); - hashCode = hashCode * -1521134295 + DropTime.GetHashCode(); - return hashCode; - } - } - - public interface IItem - { - short UniqueID { get; } - - short ItemID { get; } - - byte X { get; } - - byte Y { get; } - - int Amount { get; } - - bool IsNPCDrop { get; } - - Option OwningPlayerID { get; } - - Option DropTime { get; } - - IItem WithAmount(int newAmount); - - IItem WithIsNPCDrop(bool isNPCDrop); - - IItem WithOwningPlayerID(int owningPlayerID); - - IItem WithDropTime(DateTime dropTime); - } -} \ No newline at end of file diff --git a/EOLib/Domain/Map/MapActions.cs b/EOLib/Domain/Map/MapActions.cs index 49a10fba0..b2b8ff789 100644 --- a/EOLib/Domain/Map/MapActions.cs +++ b/EOLib/Domain/Map/MapActions.cs @@ -34,7 +34,7 @@ public void RequestRefresh() _packetSendService.SendPacket(packet); } - public ItemPickupResult PickUpItem(IItem item) + public ItemPickupResult PickUpItem(MapItem item) { var pickupResult = _itemPickupValidator.ValidateItemPickup(_characterProvider.MainCharacter, item); if (pickupResult == ItemPickupResult.Ok) @@ -85,7 +85,7 @@ public interface IMapActions { void RequestRefresh(); - ItemPickupResult PickUpItem(IItem item); + ItemPickupResult PickUpItem(MapItem item); void OpenDoor(IWarp warp); diff --git a/EOLib/Domain/Map/MapCellState.cs b/EOLib/Domain/Map/MapCellState.cs index 847438116..1b71abfbf 100644 --- a/EOLib/Domain/Map/MapCellState.cs +++ b/EOLib/Domain/Map/MapCellState.cs @@ -11,7 +11,7 @@ public class MapCellState : IMapCellState public MapCoordinate Coordinate { get; set; } - public IReadOnlyList Items { get; set; } + public IReadOnlyList Items { get; set; } public TileSpec TileSpec { get; set; } @@ -28,7 +28,7 @@ public class MapCellState : IMapCellState public MapCellState() { Coordinate = new MapCoordinate(0, 0); - Items = new List(); + Items = new List(); TileSpec = TileSpec.None; NPC = Option.None(); Character = Option.None(); diff --git a/EOLib/Domain/Map/MapItem.cs b/EOLib/Domain/Map/MapItem.cs new file mode 100644 index 000000000..6c4a7156a --- /dev/null +++ b/EOLib/Domain/Map/MapItem.cs @@ -0,0 +1,39 @@ +using Amadevus.RecordGenerator; +using Optional; +using System; + +namespace EOLib.Domain.Map +{ + [Record] + public sealed partial class MapItem + { + public short UniqueID { get; } + + public short ItemID { get; } + + public byte X { get; } + + public byte Y { get; } + + public int Amount { get; } + + public bool IsNPCDrop { get; } + + public Option OwningPlayerID { get; } + + public Option DropTime { get; } + + public static MapItem None => new MapItem(); + + public MapItem(short uid, short id, byte x, byte y, int amount) + { + UniqueID = uid; + ItemID = id; + X = x; + Y = y; + Amount = amount; + } + + private MapItem() { } + } +} \ No newline at end of file diff --git a/EOLib/Domain/Map/RefreshReplyPacketData.cs b/EOLib/Domain/Map/RefreshReplyPacketData.cs index 48199d4a1..7ed1c1017 100644 --- a/EOLib/Domain/Map/RefreshReplyPacketData.cs +++ b/EOLib/Domain/Map/RefreshReplyPacketData.cs @@ -9,13 +9,13 @@ public class RefreshReplyData : IRefreshReplyData public IReadOnlyList NPCs { get; private set; } - public IReadOnlyList Items { get; private set; } + public IReadOnlyList Items { get; private set; } public RefreshReplyData() { Characters = new List(); NPCs = new List(); - Items = new List(); + Items = new List(); } public IRefreshReplyData WithCharacters(IEnumerable characters) @@ -32,10 +32,10 @@ public IRefreshReplyData WithNPCs(IEnumerable npcs) return newData; } - public IRefreshReplyData WithItems(IEnumerable items) + public IRefreshReplyData WithItems(IEnumerable items) { var newData = MakeCopy(this); - newData.Items = new List(items); + newData.Items = new List(items); return newData; } @@ -45,7 +45,7 @@ private static RefreshReplyData MakeCopy(IRefreshReplyData source) { Characters = new List(source.Characters), NPCs = new List(source.NPCs), - Items = new List(source.Items) + Items = new List(source.Items) }; } } @@ -56,12 +56,12 @@ public interface IRefreshReplyData : ITranslatedData IReadOnlyList NPCs { get; } - IReadOnlyList Items { get; } + IReadOnlyList Items { get; } IRefreshReplyData WithCharacters(IEnumerable characters); IRefreshReplyData WithNPCs(IEnumerable npcs); - IRefreshReplyData WithItems(IEnumerable items); + IRefreshReplyData WithItems(IEnumerable items); } } diff --git a/EOLib/Domain/Map/WarpAgreePacketData.cs b/EOLib/Domain/Map/WarpAgreePacketData.cs index e5011246a..92d291f7b 100644 --- a/EOLib/Domain/Map/WarpAgreePacketData.cs +++ b/EOLib/Domain/Map/WarpAgreePacketData.cs @@ -14,13 +14,13 @@ public class WarpAgreePacketData : IWarpAgreePacketData public IReadOnlyList NPCs { get; private set; } - public IReadOnlyList Items { get; private set; } + public IReadOnlyList Items { get; private set; } public WarpAgreePacketData() { Characters = new List(); NPCs = new List(); - Items = new List(); + Items = new List(); } public IWarpAgreePacketData WithMapID(short mapID) @@ -51,10 +51,10 @@ public IWarpAgreePacketData WithNPCs(IEnumerable npcs) return newData; } - public IWarpAgreePacketData WithItems(IEnumerable items) + public IWarpAgreePacketData WithItems(IEnumerable items) { var newData = MakeCopy(this); - newData.Items = new List(items); + newData.Items = new List(items); return newData; } @@ -66,7 +66,7 @@ private static WarpAgreePacketData MakeCopy(IWarpAgreePacketData source) WarpAnimation = source.WarpAnimation, Characters = new List(source.Characters), NPCs = new List(source.NPCs), - Items = new List(source.Items) + Items = new List(source.Items) }; } } @@ -81,7 +81,7 @@ public interface IWarpAgreePacketData : ITranslatedData IReadOnlyList NPCs { get; } - IReadOnlyList Items { get; } + IReadOnlyList Items { get; } IWarpAgreePacketData WithMapID(short mapID); @@ -91,6 +91,6 @@ public interface IWarpAgreePacketData : ITranslatedData IWarpAgreePacketData WithNPCs(IEnumerable npcs); - IWarpAgreePacketData WithItems(IEnumerable items); + IWarpAgreePacketData WithItems(IEnumerable items); } } diff --git a/EOLib/Net/Translators/MapStatePacketTranslator.cs b/EOLib/Net/Translators/MapStatePacketTranslator.cs index f7f286d6a..a746553cf 100644 --- a/EOLib/Net/Translators/MapStatePacketTranslator.cs +++ b/EOLib/Net/Translators/MapStatePacketTranslator.cs @@ -1,7 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using EOLib.Domain.Character; using EOLib.Domain.Map; using EOLib.Domain.NPC; +using Optional; namespace EOLib.Net.Translators { @@ -57,7 +59,7 @@ protected IEnumerable GetNPCs(IPacket packet) packet.ReadByte(); //consume the tail 255 byte that broke loop iteration } - protected IEnumerable GetMapItems(IPacket packet) + protected IEnumerable GetMapItems(IPacket packet) { while (packet.ReadPosition < packet.Length) { @@ -67,7 +69,7 @@ protected IEnumerable GetMapItems(IPacket packet) var y = packet.ReadChar(); var amount = packet.ReadThree(); - yield return new Item(uid, itemID, x, y).WithAmount(amount); + yield return new MapItem(uid, itemID, x, y, amount); } } } diff --git a/EOLib/PacketHandlers/EndPlayerWarpHandler.cs b/EOLib/PacketHandlers/EndPlayerWarpHandler.cs index e6c7f9eba..b010fec75 100644 --- a/EOLib/PacketHandlers/EndPlayerWarpHandler.cs +++ b/EOLib/PacketHandlers/EndPlayerWarpHandler.cs @@ -69,7 +69,7 @@ public override bool HandlePacket(IPacket packet) _currentMapStateRepository.CurrentMapID = warpAgreePacketData.MapID; _currentMapStateRepository.Characters = warpAgreePacketData.Characters.ToDictionary(k => k.ID, v => v); _currentMapStateRepository.NPCs = new HashSet(warpAgreePacketData.NPCs); - _currentMapStateRepository.MapItems = new HashSet(warpAgreePacketData.Items); + _currentMapStateRepository.MapItems = new HashSet(warpAgreePacketData.Items); _currentMapStateRepository.OpenDoors.Clear(); _currentMapStateRepository.VisibleSpikeTraps.Clear(); _currentMapStateRepository.ShowMiniMap = _currentMapStateRepository.ShowMiniMap && diff --git a/EOLib/PacketHandlers/Items/DropItemHandler.cs b/EOLib/PacketHandlers/Items/DropItemHandler.cs index 443544114..3407d21ff 100644 --- a/EOLib/PacketHandlers/Items/DropItemHandler.cs +++ b/EOLib/PacketHandlers/Items/DropItemHandler.cs @@ -5,6 +5,7 @@ using EOLib.Domain.Notifiers; using EOLib.Net; using EOLib.Net.Handlers; +using Optional; using System; using System.Collections.Generic; @@ -57,9 +58,8 @@ public override bool HandlePacket(IPacket packet) .WithNewStat(CharacterStat.MaxWeight, maxWeight); _characterRepository.MainCharacter = _characterRepository.MainCharacter.WithStats(stats); - var mapItem = new Item(uid, id, dropX, dropY) - .WithAmount(amountDropped) - .WithDropTime(DateTime.Now.AddSeconds(-5)); + var mapItem = new MapItem(uid, id, dropX, dropY, amountDropped) + .WithDropTime(Option.Some(DateTime.Now.AddSeconds(-5))); _currentMapStateRepository.MapItems.Add(mapItem); foreach (var notifier in _mainCharacterEventNotifiers) diff --git a/EOLib/PacketHandlers/Items/OtherPlayerDropItemHandler.cs b/EOLib/PacketHandlers/Items/OtherPlayerDropItemHandler.cs index c6fb25631..407290427 100644 --- a/EOLib/PacketHandlers/Items/OtherPlayerDropItemHandler.cs +++ b/EOLib/PacketHandlers/Items/OtherPlayerDropItemHandler.cs @@ -3,6 +3,7 @@ using EOLib.Domain.Map; using EOLib.Net; using EOLib.Net.Handlers; +using Optional; using System; namespace EOLib.PacketHandlers.Items @@ -32,9 +33,8 @@ public override bool HandlePacket(IPacket packet) var dropX = packet.ReadChar(); var dropY = packet.ReadChar(); - var mapItem = new Item(uid, id, dropX, dropY) - .WithAmount(amountDropped) - .WithDropTime(DateTime.Now); + var mapItem = new MapItem(uid, id, dropX, dropY, amountDropped) + .WithDropTime(Option.Some(DateTime.Now)); _currentMapStateRepository.MapItems.Add(mapItem); return true; diff --git a/EOLib/PacketHandlers/MainPlayerWalkHandler.cs b/EOLib/PacketHandlers/MainPlayerWalkHandler.cs index 8df46d5f4..b5ee1c712 100644 --- a/EOLib/PacketHandlers/MainPlayerWalkHandler.cs +++ b/EOLib/PacketHandlers/MainPlayerWalkHandler.cs @@ -53,7 +53,7 @@ public override bool HandlePacket(IPacket packet) var y = packet.ReadChar(); var amount = packet.ReadThree(); - var newItem = new Item(uid, itemID, x, y).WithAmount(amount); + var newItem = new MapItem(uid, itemID, x, y, amount); _currentMapStateRepository.MapItems.Add(newItem); } diff --git a/EOLib/PacketHandlers/NPCLeaveMapHandler.cs b/EOLib/PacketHandlers/NPCLeaveMapHandler.cs index 5b83aafbf..1957dccbc 100644 --- a/EOLib/PacketHandlers/NPCLeaveMapHandler.cs +++ b/EOLib/PacketHandlers/NPCLeaveMapHandler.cs @@ -135,11 +135,10 @@ private void UpdateCharacterStat(CharacterStat whichStat, int statValue) private void ShowDroppedItem(short playerID, short droppedItemUID, short droppedItemID, byte x, byte y, int droppedAmount) { - IItem mapItem = new Item(droppedItemUID, droppedItemID, x, y); - mapItem = mapItem.WithAmount(droppedAmount) + var mapItem = new MapItem(droppedItemUID, droppedItemID, x, y, droppedAmount) .WithIsNPCDrop(true) - .WithDropTime(DateTime.Now) - .WithOwningPlayerID(playerID); + .WithDropTime(Option.Some(DateTime.Now)) + .WithOwningPlayerID(Option.Some(playerID)); _currentMapStateRepository.MapItems.RemoveWhere(item => item.UniqueID == droppedItemUID); _currentMapStateRepository.MapItems.Add(mapItem); diff --git a/EOLib/PacketHandlers/RefreshMapStateHandler.cs b/EOLib/PacketHandlers/RefreshMapStateHandler.cs index b0d79b4f6..401d9fbc7 100644 --- a/EOLib/PacketHandlers/RefreshMapStateHandler.cs +++ b/EOLib/PacketHandlers/RefreshMapStateHandler.cs @@ -55,7 +55,7 @@ public override bool HandlePacket(IPacket packet) _currentMapStateRepository.Characters = data.Characters.ToDictionary(k => k.ID, v => v); _currentMapStateRepository.NPCs = new HashSet(data.NPCs); - _currentMapStateRepository.MapItems = new HashSet(data.Items); + _currentMapStateRepository.MapItems = new HashSet(data.Items); _currentMapStateRepository.OpenDoors.Clear(); _currentMapStateRepository.PendingDoors.Clear(); diff --git a/EndlessClient/Controllers/MapInteractionController.cs b/EndlessClient/Controllers/MapInteractionController.cs index 87cb48164..9dab6beb9 100644 --- a/EndlessClient/Controllers/MapInteractionController.cs +++ b/EndlessClient/Controllers/MapInteractionController.cs @@ -101,7 +101,7 @@ public void LeftClick(IMapCellState cellState, Option mous var optionalItem = cellState.Items.FirstOrNone(); if (optionalItem.HasValue) { - var item = optionalItem.ValueOr(Item.None); + var item = optionalItem.ValueOr(MapItem.None); if (!_inventorySpaceValidator.ItemFits(item)) _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT); else @@ -212,7 +212,7 @@ public void RightClick(Character character) } } - private void HandlePickupResult(ItemPickupResult pickupResult, IItem item) + private void HandlePickupResult(ItemPickupResult pickupResult, MapItem item) { switch (pickupResult) { diff --git a/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs b/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs index af0b0a4d7..42a30ad6f 100644 --- a/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs +++ b/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs @@ -28,7 +28,7 @@ public InventorySpaceValidator(IEIFFileProvider eifFileProvider, _inventoryService = inventoryService; } - public bool ItemFits(IItem item) + public bool ItemFits(MapItem item) { return _characterInventoryProvider.ItemInventory.Any(x => x.ItemID == item.ItemID) || ItemFits(item.ItemID); } @@ -48,7 +48,7 @@ private bool ItemFits(ItemSize itemSize) public interface IInventorySpaceValidator { - bool ItemFits(IItem item); + bool ItemFits(MapItem item); bool ItemFits(int itemId); diff --git a/EndlessClient/Rendering/MouseCursorRenderer.cs b/EndlessClient/Rendering/MouseCursorRenderer.cs index a39f6f1fe..2c0f3a0be 100644 --- a/EndlessClient/Rendering/MouseCursorRenderer.cs +++ b/EndlessClient/Rendering/MouseCursorRenderer.cs @@ -177,7 +177,7 @@ private void UpdateCursorSourceRectangle(IMapCellState cellState) UpdateCursorIndexForTileSpec(cellState.TileSpec); if (!cellState.Items.Any()) - UpdateMapItemLabel(Option.None()); + UpdateMapItemLabel(Option.None()); _startClickTime.MatchSome(st => { @@ -211,7 +211,7 @@ private static Vector2 GetDrawCoordinatesFromGridUnits(int x, int y, int cOffX, return new Vector2(x*32 - y*32 + 288 - cOffX, y*16 + x*16 + 144 - cOffY); } - private void UpdateMapItemLabel(Option item) + private void UpdateMapItemLabel(Option item) { item.Match( some: i =>