]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Better hover coloring for inventory (#23148)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Fri, 29 Dec 2023 01:46:51 +0000 (20:46 -0500)
committerGitHub <noreply@github.com>
Fri, 29 Dec 2023 01:46:51 +0000 (12:46 +1100)
Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs

index 8af68282f30103eb7e0c9026d6a08bf7a7819c8c..73040e9932fdbb26dfc0c0adc6f5fb05a803f08f 100644 (file)
@@ -3,11 +3,13 @@ using System.Numerics;
 using Content.Client.Gameplay;
 using Content.Client.Hands.Systems;
 using Content.Client.Inventory;
+using Content.Client.Storage.Systems;
 using Content.Client.UserInterface.Controls;
 using Content.Client.UserInterface.Systems.Gameplay;
 using Content.Client.UserInterface.Systems.Inventory.Controls;
 using Content.Client.UserInterface.Systems.Inventory.Widgets;
 using Content.Client.UserInterface.Systems.Inventory.Windows;
+using Content.Shared.Containers.ItemSlots;
 using Content.Shared.Hands.Components;
 using Content.Shared.Input;
 using Content.Shared.Storage;
@@ -336,6 +338,25 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
         var fits = _inventorySystem.CanEquip(player.Value, held, control.SlotName, out _, slotDef) &&
                    _container.CanInsert(held, container);
 
+        if (!fits && _entities.TryGetComponent<StorageComponent>(container.ContainedEntity, out var storage))
+        {
+            fits = _entities.System<StorageSystem>().CanInsert(container.ContainedEntity.Value, held, out _, storage);
+        }
+        else if (!fits && _entities.TryGetComponent<ItemSlotsComponent>(container.ContainedEntity, out var itemSlots))
+        {
+            var itemSlotsSys = _entities.System<ItemSlotsSystem>();
+            foreach (var slot in itemSlots.Slots.Values)
+            {
+                if (!slot.InsertOnInteract)
+                    continue;
+
+                if (!itemSlotsSys.CanInsert(container.ContainedEntity.Value, held, null, slot))
+                    continue;
+                fits = true;
+                break;
+            }
+        }
+
         hoverSprite.CopyFrom(sprite);
         hoverSprite.Color = fits ? new Color(0, 255, 0, 127) : new Color(255, 0, 0, 127);