Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream sync #1616

Merged
merged 88 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
8a10aa4
Fix Christmas tree bounding box (#22139)
enumerate0 Dec 5, 2023
3efa81b
Automatic changelog update
PJBot Dec 5, 2023
c091926
boom (#22150)
JoeHammad1844 Dec 5, 2023
1c1ee22
Automatic changelog update
PJBot Dec 5, 2023
172bd79
paramedic on marathon (#22151)
JoeHammad1844 Dec 5, 2023
04cacf3
Automatic changelog update
PJBot Dec 5, 2023
50201e4
lower chloral hydrate effect minimum to 10u (requires 11u to sleep) (…
QuietlyWhisper Dec 5, 2023
704b60a
Automatic changelog update
PJBot Dec 5, 2023
3ad5bbe
Adds Emergency Nitrogen Tanks (#22142)
DangerRevolution Dec 5, 2023
1f6b76a
Automatic changelog update
PJBot Dec 5, 2023
bef7272
Added thresholds and new stomatch for mice (#22143)
Lazzi0706 Dec 5, 2023
f412504
Removes paramedic suit from medidrobe (#22146)
JoeHammad1844 Dec 5, 2023
858474d
Automatic changelog update
PJBot Dec 5, 2023
685cb9c
Action Cooldowns Reset on Rejuvenate (#22149)
ForestNoises Dec 5, 2023
74781f8
Automatic changelog update
PJBot Dec 5, 2023
18f40c1
gas tanks ops (#22154)
lzk228 Dec 5, 2023
5937d0c
Set cocoa to trash on empty (#22155)
themias Dec 5, 2023
f0c7634
fixes ghosts completely lacking speech (#22157)
deathride58 Dec 5, 2023
09a78ef
Automatic changelog update
PJBot Dec 5, 2023
f11d94e
Add water cups to water coolers (#22073)
tgrkzus Dec 5, 2023
2ea8207
Automatic changelog update
PJBot Dec 5, 2023
6479d4d
Fixed projectile spells not counting user (#22158)
DexlerXD Dec 5, 2023
fb4a507
Cyborg assembly no longer need a power cell (#22144)
M3739 Dec 5, 2023
000ac6f
Change points per node to 6500 (#22163)
DogZeroX Dec 5, 2023
9ca84ac
Grid inventory fixes (#22161)
EmoGarbage404 Dec 5, 2023
453eb1a
Automatic changelog update
PJBot Dec 5, 2023
922d516
Change combat boots to a 2x1 grid (#22167)
EmoGarbage404 Dec 6, 2023
55c8ad0
Adds scarfs to Secdrobe and hydrobe. (#21927)
Adrian16199 Dec 6, 2023
daa70fc
Fix wallmount board dropping at random side of the wall (#21920)
qwerltaz Dec 6, 2023
2fa8517
Update submodule to 187.1.2 (#22171)
metalgearsloth Dec 6, 2023
7f5cbf2
gridinv shape adjustments (#22162)
EmoGarbage404 Dec 6, 2023
7cd5bf3
Automatic changelog update
PJBot Dec 6, 2023
8583f0d
Predict helmet toggles (#22089)
metalgearsloth Dec 6, 2023
5ecd4aa
Automatic changelog update
PJBot Dec 6, 2023
89295d9
research console radio messages on unlock (#22166)
EmoGarbage404 Dec 6, 2023
abfea8d
Add public methods to relay inventory events (#22165)
DrSmugleaf Dec 6, 2023
7eaa5a8
Pool NPC entitylookup fields (#21806)
metalgearsloth Dec 6, 2023
81b3f95
Gemini hotfixes (#22177)
TsjipTsjip Dec 6, 2023
80a1aad
Disposals chute make it go splat (#20848)
Henry12116 Dec 6, 2023
c3ba35f
Update submodule to 187.2.0 (#22178)
metalgearsloth Dec 6, 2023
8fcc7d0
EMT belt (#22173)
JoeHammad1844 Dec 6, 2023
f31b015
Options are statements, not questions (#22185)
Errant-4 Dec 6, 2023
47359cf
medibot fixes and refactoring (#21852)
deltanedas Dec 6, 2023
abce2dd
Automatic changelog update
PJBot Dec 6, 2023
3252a2b
Fix toggleable helmets (#22195)
metalgearsloth Dec 6, 2023
ee897f1
Automatic changelog update
PJBot Dec 6, 2023
4b76c4b
Make boots with storage use itemslot (#22186)
deltanedas Dec 6, 2023
a4027a3
Fixes speech bubbles now lacking names for the living (#22191)
deathride58 Dec 6, 2023
fc921ce
trim bibles.yml (#22184)
lzk228 Dec 6, 2023
e639006
Automatic changelog update
PJBot Dec 6, 2023
b4f8393
Log server ID in connection logs table (#21911)
PJB3005 Dec 6, 2023
281e808
saltern dispenser update (#22189)
deltanedas Dec 6, 2023
6ccce8b
atlas dispenser update (#22190)
deltanedas Dec 6, 2023
f98322a
T shaped pickaxe and grid UI fix (#22197)
TemporalOroboros Dec 7, 2023
629fa48
Automatic changelog update
PJBot Dec 7, 2023
c047f19
Inventory sprite rotation (#22201)
EmoGarbage404 Dec 7, 2023
8000428
tweak crowbar storage sprites (#22202)
EmoGarbage404 Dec 7, 2023
a5d1640
Lizard Underbelly Marking (#22200)
Nairodian Dec 7, 2023
17e0143
Automatic changelog update
PJBot Dec 7, 2023
0c63f2e
Make test EntitySpecifiers ignore entities with null prototypes (#22174)
TemporalOroboros Dec 7, 2023
88119c6
nar'sie fake (#20299)
deltanedas Dec 7, 2023
460bfdc
Space cobra 1.1 (#20298)
Nimfar11 Dec 7, 2023
d652e64
Automatic changelog update
PJBot Dec 7, 2023
fe41e20
3 New Brute Chemicals (And Razorium) (#22103)
CrigCrag Dec 7, 2023
6509681
Automatic changelog update
PJBot Dec 7, 2023
fb10dff
Mirror speed penalty for worn duffels and hardsuits when in-hand (#22…
EmoGarbage404 Dec 7, 2023
b5f931b
Automatic changelog update
PJBot Dec 7, 2023
2553bad
Narsie test bandaid (#22206)
EmoGarbage404 Dec 7, 2023
50e8707
fix explosion resistance (#22224)
deltanedas Dec 7, 2023
445c474
Automatic changelog update
PJBot Dec 7, 2023
287d22c
Inventory slot enumerator rejig (#21788)
ElectroJr Dec 7, 2023
5f2a4f9
Fix inventory enumerator resolve error (#22227)
ElectroJr Dec 7, 2023
039e5d4
added classic cornrows 2 (#22210)
liltenhead Dec 7, 2023
7a109a3
Implements greyscale (white) chairs (#22209)
Flareguy Dec 7, 2023
fcad478
fixes the descriptions of the ert hardsuit helmets + some other misc …
Flareguy Dec 7, 2023
beb8c26
Paramedic loses external access (#22228)
Aexxie Dec 7, 2023
8fe3f3f
Automatic changelog update
PJBot Dec 7, 2023
b01f0b5
add tooltip with entity name on inventory hover (#22203)
EmoGarbage404 Dec 8, 2023
828b787
Automatic changelog update
PJBot Dec 8, 2023
d1241c5
psychologist bed (#22223)
Nimfar11 Dec 8, 2023
dc59a36
Automatic changelog update
PJBot Dec 8, 2023
caf8ac8
Merge remote-tracking branch 'upstream/master' into upstream-sync
Morb0 Dec 8, 2023
b83e3e0
hellfire (#22243)
Emisse Dec 8, 2023
dbdb9bc
Automatic changelog update
PJBot Dec 8, 2023
0003e1e
Merge remote-tracking branch 'upstream/master' into upstream-sync
Morb0 Dec 8, 2023
5e9e55d
Remove ClothingShoesBootsJackSecFilled
Morb0 Dec 8, 2023
81f07a9
Update locale
Morb0 Dec 8, 2023
8e82b67
Fix locale
Morb0 Dec 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Content.Client/Chat/UI/SpeechBubble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ protected string ExtractSpeechSubstring(ChatMessage message, string tag)
var rawmsg = message.WrappedMessage;
var tagStart = rawmsg.IndexOf($"[{tag}]");
var tagEnd = rawmsg.IndexOf($"[/{tag}]");
if (tagStart < 0 || tagEnd < 0) //the above return -1 if the tag's not found, which in turn will cause the below to throw an exception. a blank speech bubble is far more noticeably broken than the bubble not appearing at all -bhijn
return "";
tagStart += tag.Length + 2;
return rawmsg.Substring(tagStart, tagEnd - tagStart);
}
Expand Down
12 changes: 5 additions & 7 deletions Content.Client/Clothing/ClientClothingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,15 @@ private void OnDidUnequip(EntityUid uid, SpriteComponent component, DidUnequipEv
revealedLayers.Clear();
}

public void InitClothing(EntityUid uid, InventoryComponent? component = null, SpriteComponent? sprite = null)
public void InitClothing(EntityUid uid, InventoryComponent component)
{
if (!Resolve(uid, ref sprite, ref component) || !_inventorySystem.TryGetSlots(uid, out var slots, component))
if (!TryComp(uid, out SpriteComponent? sprite))
return;

foreach (var slot in slots)
var enumerator = _inventorySystem.GetSlotEnumerator((uid, component));
while (enumerator.NextItem(out var item, out var slot))
{
if (!_inventorySystem.TryGetSlotContainer(uid, slot.Name, out var containerSlot, out _, component) ||
!containerSlot.ContainedEntity.HasValue) continue;

RenderEquipment(uid, containerSlot.ContainedEntity.Value, slot.Name, component, sprite);
RenderEquipment(uid, item, slot.Name, component, sprite);
}
}

Expand Down
66 changes: 10 additions & 56 deletions Content.Client/Inventory/ClientInventorySystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Content.Client.Clothing;
using Content.Client.Examine;
using Content.Client.UserInterface.Controls;
using Content.Client.Verbs.UI;
using Content.Shared.Clothing.Components;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory;
Expand All @@ -15,14 +13,12 @@
using Robust.Shared.Containers;
using Robust.Shared.Input.Binding;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;

namespace Content.Client.Inventory
{
[UsedImplicitly]
public sealed class ClientInventorySystem : InventorySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IUserInterfaceManager _ui = default!;

Expand Down Expand Up @@ -89,7 +85,7 @@ private void OnUseInHand(EntityUid uid, ClothingComponent component, UseInHandEv
private void OnDidUnequip(InventorySlotsComponent component, DidUnequipEvent args)
{
UpdateSlot(args.Equipee, component, args.Slot);
if (args.Equipee != _playerManager.LocalPlayer?.ControlledEntity)
if (args.Equipee != _playerManager.LocalEntity)
return;
var update = new SlotSpriteUpdate(null, args.SlotGroup, args.Slot, false);
OnSpriteUpdate?.Invoke(update);
Expand All @@ -98,7 +94,7 @@ private void OnDidUnequip(InventorySlotsComponent component, DidUnequipEvent arg
private void OnDidEquip(InventorySlotsComponent component, DidEquipEvent args)
{
UpdateSlot(args.Equipee, component, args.Slot);
if (args.Equipee != _playerManager.LocalPlayer?.ControlledEntity)
if (args.Equipee != _playerManager.LocalEntity)
return;
var update = new SlotSpriteUpdate(args.Equipment, args.SlotGroup, args.Slot,
HasComp<StorageComponent>(args.Equipment));
Expand All @@ -107,10 +103,8 @@ private void OnDidEquip(InventorySlotsComponent component, DidEquipEvent args)

private void OnShutdown(EntityUid uid, InventoryComponent component, ComponentShutdown args)
{
if (uid != _playerManager.LocalPlayer?.ControlledEntity)
return;

OnUnlinkInventory?.Invoke();
if (uid == _playerManager.LocalEntity)
OnUnlinkInventory?.Invoke();
}

private void OnPlayerDetached(EntityUid uid, InventorySlotsComponent component, LocalPlayerDetachedEvent args)
Expand Down Expand Up @@ -151,21 +145,18 @@ protected override void OnInit(EntityUid uid, InventoryComponent component, Comp
base.OnInit(uid, component, args);
_clothingVisualsSystem.InitClothing(uid, component);

if (!_prototypeManager.TryIndex(component.TemplateId, out InventoryTemplatePrototype? invTemplate) ||
!TryComp(uid, out InventorySlotsComponent? inventorySlots))
{
if (!TryComp(uid, out InventorySlotsComponent? inventorySlots))
return;
}

foreach (var slot in invTemplate.Slots)
foreach (var slot in component.Slots)
{
TryAddSlotDef(uid, inventorySlots, slot);
}
}

public void ReloadInventory(InventorySlotsComponent? component = null)
{
var player = _playerManager.LocalPlayer?.ControlledEntity;
var player = _playerManager.LocalEntity;
if (player == null || !Resolve(player.Value, ref component, false))
{
return;
Expand All @@ -179,7 +170,7 @@ public void SetSlotHighlight(EntityUid owner, InventorySlotsComponent component,
{
var oldData = component.SlotData[slotName];
var newData = component.SlotData[slotName] = new SlotData(oldData, state);
if (owner == _playerManager.LocalPlayer?.ControlledEntity)
if (owner == _playerManager.LocalEntity)
EntitySlotUpdate?.Invoke(newData);
}

Expand All @@ -198,7 +189,7 @@ public void UpdateSlot(EntityUid owner, InventorySlotsComponent component, strin

var newData = component.SlotData[slotName] =
new SlotData(component.SlotData[slotName], newHighlight, newBlocked);
if (owner == _playerManager.LocalPlayer?.ControlledEntity)
if (owner == _playerManager.LocalEntity)
EntitySlotUpdate?.Invoke(newData);
}

Expand All @@ -208,48 +199,11 @@ public bool TryAddSlotDef(EntityUid owner, InventorySlotsComponent component, Sl
if (!component.SlotData.TryAdd(newSlotDef.Name, newSlotData))
return false;

if (owner == _playerManager.LocalPlayer?.ControlledEntity)
if (owner == _playerManager.LocalEntity)
OnSlotAdded?.Invoke(newSlotData);
return true;
}

public void RemoveSlotDef(EntityUid owner, InventorySlotsComponent component, SlotData slotData)
{
if (component.SlotData.Remove(slotData.SlotName))
{
if (owner == _playerManager.LocalPlayer?.ControlledEntity)
OnSlotRemoved?.Invoke(slotData);
}
}

public void RemoveSlotDef(EntityUid owner, InventorySlotsComponent component, string slotName)
{
if (!component.SlotData.TryGetValue(slotName, out var slotData))
return;

component.SlotData.Remove(slotName);

if (owner == _playerManager.LocalPlayer?.ControlledEntity)
OnSlotRemoved?.Invoke(slotData);
}

// TODO hud refactor This should also live in a UI Controller
private void HoverInSlotButton(EntityUid uid, string slot, SlotControl control,
InventoryComponent? inventoryComponent = null, HandsComponent? hands = null)
{
if (!Resolve(uid, ref inventoryComponent))
return;

if (!Resolve(uid, ref hands, false))
return;

if (hands.ActiveHandEntity is not EntityUid heldEntity)
return;

if (!TryGetSlotContainer(uid, slot, out var containerSlot, out var slotDef, inventoryComponent))
return;
}

public void UIInventoryActivate(string slot)
{
EntityManager.RaisePredictiveEvent(new UseSlotNetworkMessage(slot));
Expand Down
8 changes: 4 additions & 4 deletions Content.Client/Inventory/StrippableBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ public void UpdateMenu()

_strippingMenu.ClearButtons();

if (EntMan.TryGetComponent<InventoryComponent>(Owner, out var inv) && _protoMan.TryIndex<InventoryTemplatePrototype>(inv.TemplateId, out var template))
if (EntMan.TryGetComponent<InventoryComponent>(Owner, out var inv))
{
foreach (var slot in template.Slots)
foreach (var slot in inv.Slots)
{
AddInventoryButton(Owner, slot.Name, template, inv);
AddInventoryButton(Owner, slot.Name, inv);
}
}

Expand Down Expand Up @@ -190,7 +190,7 @@ private void SlotPressed(GUIBoundKeyEventArgs ev, SlotControl slot)
_ui.GetUIController<VerbMenuUIController>().OpenVerbMenu(slot.Entity.Value);
}

private void AddInventoryButton(EntityUid invUid, string slotId, InventoryTemplatePrototype _, InventoryComponent inv)
private void AddInventoryButton(EntityUid invUid, string slotId, InventoryComponent inv)
{
if (!_inv.TryGetSlotContainer(invUid, slotId, out var container, out var slotDef, inv))
return;
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Options/UI/Tabs/GraphicsTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</BoxContainer>
<CheckBox Name="ShowHeldItemCheckBox" Text="{Loc 'ui-options-show-held-item'}" />
<CheckBox Name="ShowCombatModeIndicatorsCheckBox" Text="{Loc 'ui-options-show-combat-mode-indicators'}" />
<CheckBox Name="OpaqueStorageWindowCheckBox" Text="{Loc 'ui-options-opaque-storage-window'}" />
<CheckBox Name="ShowLoocAboveHeadCheckBox" Text="{Loc 'ui-options-show-looc-on-head'}" />
<CheckBox Name="FancySpeechBubblesCheckBox" Text="{Loc 'ui-options-fancy-speech'}" />
<CheckBox Name="FancyNameBackgroundsCheckBox" Text="{Loc 'ui-options-fancy-name-background'}" />
Expand Down
6 changes: 6 additions & 0 deletions Content.Client/Options/UI/Tabs/GraphicsTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public GraphicsTab()

ShowHeldItemCheckBox.OnToggled += OnCheckBoxToggled;
ShowCombatModeIndicatorsCheckBox.OnToggled += OnCheckBoxToggled;
OpaqueStorageWindowCheckBox.OnToggled += OnCheckBoxToggled;
ShowLoocAboveHeadCheckBox.OnToggled += OnCheckBoxToggled;
ShowLoocAboveHeadCheckBox.OnToggled += OnCheckBoxToggled;
FancySpeechBubblesCheckBox.OnToggled += OnCheckBoxToggled;
FancyNameBackgroundsCheckBox.OnToggled += OnCheckBoxToggled;
Expand All @@ -124,6 +126,7 @@ public GraphicsTab()
FpsCounterCheckBox.Pressed = _cfg.GetCVar(CCVars.HudFpsCounterVisible);
ShowHeldItemCheckBox.Pressed = _cfg.GetCVar(CCVars.HudHeldItemShow);
ShowCombatModeIndicatorsCheckBox.Pressed = _cfg.GetCVar(CCVars.CombatModeIndicatorsPointShow);
OpaqueStorageWindowCheckBox.Pressed = _cfg.GetCVar(CCVars.OpaqueStorageWindow);
ShowLoocAboveHeadCheckBox.Pressed = _cfg.GetCVar(CCVars.LoocAboveHeadShow);
FancySpeechBubblesCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatEnableFancyBubbles);
FancyNameBackgroundsCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatFancyNameBackground);
Expand Down Expand Up @@ -174,6 +177,7 @@ private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
_cfg.SetCVar(CCVars.ParallaxLowQuality, ParallaxLowQualityCheckBox.Pressed);
_cfg.SetCVar(CCVars.HudHeldItemShow, ShowHeldItemCheckBox.Pressed);
_cfg.SetCVar(CCVars.CombatModeIndicatorsPointShow, ShowCombatModeIndicatorsCheckBox.Pressed);
_cfg.SetCVar(CCVars.OpaqueStorageWindow, OpaqueStorageWindowCheckBox.Pressed);
_cfg.SetCVar(CCVars.LoocAboveHeadShow, ShowLoocAboveHeadCheckBox.Pressed);
_cfg.SetCVar(CCVars.ChatEnableFancyBubbles, FancySpeechBubblesCheckBox.Pressed);
_cfg.SetCVar(CCVars.ChatFancyNameBackground, FancyNameBackgroundsCheckBox.Pressed);
Expand Down Expand Up @@ -214,6 +218,7 @@ private void UpdateApplyButton()
var isPLQSame = ParallaxLowQualityCheckBox.Pressed == _cfg.GetCVar(CCVars.ParallaxLowQuality);
var isShowHeldItemSame = ShowHeldItemCheckBox.Pressed == _cfg.GetCVar(CCVars.HudHeldItemShow);
var isCombatModeIndicatorsSame = ShowCombatModeIndicatorsCheckBox.Pressed == _cfg.GetCVar(CCVars.CombatModeIndicatorsPointShow);
var isOpaqueStorageWindow = OpaqueStorageWindowCheckBox.Pressed == _cfg.GetCVar(CCVars.OpaqueStorageWindow);
var isLoocShowSame = ShowLoocAboveHeadCheckBox.Pressed == _cfg.GetCVar(CCVars.LoocAboveHeadShow);
var isFancyChatSame = FancySpeechBubblesCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatEnableFancyBubbles);
var isFancyBackgroundSame = FancyNameBackgroundsCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatFancyNameBackground);
Expand All @@ -233,6 +238,7 @@ private void UpdateApplyButton()
isHudThemeSame &&
isShowHeldItemSame &&
isCombatModeIndicatorsSame &&
isOpaqueStorageWindow &&
isLoocShowSame &&
isFancyChatSame &&
isFancyBackgroundSame &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
using System.Linq;
using System.Numerics;
using Content.Client.Items.Systems;
using Content.Shared.Item;
using Content.Shared.Storage;
using Content.Shared.Storage.EntitySystems;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.CustomControls;

namespace Content.Client.UserInterface.Systems.Storage.Controls;

public sealed class ItemGridPiece : Control
{
private readonly ItemSystem _itemSystem;
private readonly SpriteSystem _spriteSystem;
private readonly IEntityManager _entityManager;
private readonly StorageUIController _storageController;

private readonly List<(Texture, Vector2)> _texturesPositions = new();
Expand Down Expand Up @@ -49,8 +47,7 @@ public ItemGridPiece(Entity<ItemComponent> entity, ItemStorageLocation location,
{
IoCManager.InjectDependencies(this);

_itemSystem = entityManager.System<ItemSystem>();
_spriteSystem = entityManager.System<SpriteSystem>();
_entityManager = entityManager;
_storageController = UserInterfaceManager.GetUIController<StorageUIController>();

Entity = entity.Owner;
Expand All @@ -59,9 +56,22 @@ public ItemGridPiece(Entity<ItemComponent> entity, ItemStorageLocation location,
Visible = true;
MouseFilter = MouseFilterMode.Pass;

TooltipSupplier = SupplyTooltip;

OnThemeUpdated();
}

private Control? SupplyTooltip(Control sender)
{
if (_storageController.IsDragging)
return null;

return new Tooltip
{
Text = _entityManager.GetComponent<MetaDataComponent>(Entity).EntityName
};
}

protected override void OnThemeUpdated()
{
base.OnThemeUpdated();
Expand All @@ -81,10 +91,17 @@ protected override void Draw(DrawingHandleScreen handle)
{
base.Draw(handle);

// really just an "oh shit" catch.
if (!_entityManager.EntityExists(Entity) || !_entityManager.TryGetComponent<ItemComponent>(Entity, out var itemComponent))
{
Dispose();
return;
}

if (_storageController.IsDragging && _storageController.CurrentlyDragging == this)
return;

var adjustedShape = _itemSystem.GetAdjustedItemShape((Entity, null), Location.Rotation, Vector2i.Zero);
var adjustedShape = _entityManager.System<ItemSystem>().GetAdjustedItemShape((Entity, itemComponent), Location.Rotation, Vector2i.Zero);
var boundingGrid = adjustedShape.GetBoundingBox();
var size = _centerTexture!.Size * 2 * UIScale;

Expand Down Expand Up @@ -127,15 +144,37 @@ protected override void Draw(DrawingHandleScreen handle)
}

// typically you'd divide by two, but since the textures are half a tile, this is done implicitly
var iconOffset = new Vector2((boundingGrid.Width + 1) * size.X ,
var iconPosition = new Vector2((boundingGrid.Width + 1) * size.X ,
(boundingGrid.Height + 1) * size.Y);
var iconRotation = Location.Rotation + Angle.FromDegrees(itemComponent.StoredRotation);

_spriteSystem.ForceUpdate(Entity);
handle.DrawEntity(Entity,
PixelPosition + iconOffset,
Vector2.One * 2 * UIScale,
Angle.Zero,
overrideDirection: Direction.South);
if (itemComponent.StoredSprite is { } storageSprite)
{
var scale = 2 * UIScale;
var offset = (((Box2) boundingGrid).Size - Vector2.One) * size;
var sprite = _entityManager.System<SpriteSystem>().Frame0(storageSprite);

var spriteBox = new Box2Rotated(new Box2(0f, sprite.Height * scale, sprite.Width * scale, 0f), -iconRotation, Vector2.Zero);
var root = spriteBox.CalcBoundingBox().BottomLeft;
var pos = PixelPosition * 2
+ (Parent?.GlobalPixelPosition ?? Vector2.Zero)
+ offset;

handle.SetTransform(pos, iconRotation);
var box = new UIBox2(root, root + sprite.Size * scale);
handle.DrawTextureRect(sprite, box);
handle.SetTransform(Matrix3.Identity);
}
else
{
_entityManager.System<SpriteSystem>().ForceUpdate(Entity);
handle.DrawEntity(Entity,
PixelPosition + iconPosition,
Vector2.One * 2 * UIScale,
Angle.Zero,
eyeRotation: iconRotation,
overrideDirection: Direction.South);
}
}

protected override bool HasPoint(Vector2 point)
Expand Down
Loading