SharedItemComponent (#3513)

* StorableComponent refactor

* ItemComponent refactor

* conflict fixes

* removes redundant null check

* removes redundant item throwing code

* fix conflicts

* ExplosionLaunchedComponent

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
collinlunn
2021-04-02 04:01:03 -06:00
committed by GitHub
parent d9781c6f1c
commit f7aba5f701
21 changed files with 284 additions and 361 deletions

View File

@@ -4,7 +4,9 @@ using System.Linq;
using Content.Client.Animations;
using Content.Client.UserInterface;
using Content.Shared.GameObjects.Components.Items;
using Content.Shared.GameObjects.Components.Storage;
using Robust.Client.GameObjects;
using Robust.Client.ResourceManagement;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Network;
@@ -161,20 +163,26 @@ namespace Content.Client.GameObjects.Components.Items
return;
}
if (!entity.TryGetComponent(out ItemComponent? item)) return;
if (!entity.TryGetComponent(out SharedItemComponent? item))
return;
var maybeInHands = item.GetInHandStateInfo(hand.Location);
if (!maybeInHands.HasValue)
if (item.RsiPath == null)
{
_sprite.LayerSetVisible($"hand-{name}", false);
}
else
{
var (rsi, state, color) = maybeInHands.Value;
var rsi = IoCManager.Resolve<IResourceCache>().GetResource<RSIResource>(SharedSpriteComponent.TextureRoot / item.RsiPath).RSI;
var handName = hand.Location.ToString().ToLowerInvariant();
var prefix = item.EquippedPrefix;
var state = prefix != null ? $"{prefix}-inhand-{handName}" : $"inhand-{handName}";
var color = item.Color;
_sprite.LayerSetColor($"hand-{name}", color);
_sprite.LayerSetVisible($"hand-{name}", true);
_sprite.LayerSetState($"hand-{name}", state, rsi);
_sprite.LayerSetState($"hand-{name}", state, rsi);
}
}