Revert "Add support for multi-layer in-hand and clothing sprites" (#6521)

This commit is contained in:
metalgearsloth
2022-02-07 14:59:22 +11:00
committed by GitHub
parent 470e4f8bdc
commit f9e32fb0c1
17 changed files with 262 additions and 529 deletions

View File

@@ -2,6 +2,7 @@ using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Hands.Components;
using Content.Shared.Input;
using Content.Shared.Item;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Input.Binding;
@@ -10,6 +11,7 @@ using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using System.Collections.Generic;
namespace Content.Shared.Hands
{
@@ -23,7 +25,8 @@ namespace Content.Shared.Hands
SubscribeAllEvent<RequestSetHandEvent>(HandleSetHand);
SubscribeLocalEvent<SharedHandsComponent, EntRemovedFromContainerMessage>(HandleContainerRemoved);
SubscribeLocalEvent<SharedHandsComponent, EntInsertedIntoContainerMessage>(HandleContainerInserted);
SubscribeLocalEvent<SharedHandsComponent, EntInsertedIntoContainerMessage>(HandleContainerModified);
SubscribeLocalEvent<SharedHandsComponent, ItemPrefixChangeEvent>(OnPrefixChanged);
CommandBinds.Builder
.Bind(ContentKeyFunctions.Drop, new PointerInputCmdHandler(DropPressed))
@@ -31,6 +34,15 @@ namespace Content.Shared.Hands
.Register<SharedHandsSystem>();
}
private void OnPrefixChanged(EntityUid uid, SharedHandsComponent component, ItemPrefixChangeEvent args)
{
// update hands visuals if this item is in a hand (rather then inventory or other container).
if (component.HasHand(args.ContainerId))
{
UpdateHandVisuals(uid, component);
}
}
public override void Shutdown()
{
base.Shutdown();
@@ -124,25 +136,43 @@ namespace Content.Shared.Hands
public abstract void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition,
EntityUid? exclude);
#endregion
protected virtual void HandleContainerRemoved(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args)
{
HandleContainerModified(uid, component, args);
}
#endregion
protected virtual void HandleContainerModified(EntityUid uid, SharedHandsComponent hands, ContainerModifiedMessage args)
#region visuals
private void HandleContainerModified(EntityUid uid, SharedHandsComponent hands, ContainerModifiedMessage args)
{
// client updates hand visuals here.
UpdateHandVisuals(uid, hands);
}
private void HandleContainerInserted(EntityUid uid, SharedHandsComponent component, EntInsertedIntoContainerMessage args)
/// <summary>
/// Update the In-Hand sprites
/// </summary>
public virtual void UpdateHandVisuals(EntityUid uid, SharedHandsComponent? handComp = null, AppearanceComponent? appearance = null)
{
// un-rotate entities. needed for things like directional flashlights
Transform(args.Entity).LocalRotation = 0;
if (!Resolve(uid, ref handComp, ref appearance, false))
return;
HandleContainerModified(uid, component, args);
var handsVisuals = new List<HandVisualState>();
foreach (var hand in handComp.Hands)
{
if (hand.HeldEntity == null)
continue;
if (!TryComp(hand.HeldEntity.Value, out SharedItemComponent? item) || item.RsiPath == null)
continue;
var handState = new HandVisualState(item.RsiPath, item.EquippedPrefix, hand.Location, item.Color);
handsVisuals.Add(handState);
}
appearance.SetData(HandsVisuals.VisualState, new HandsVisualState(handsVisuals));
}
#endregion
private void HandleSetHand(RequestSetHandEvent msg, EntitySessionEventArgs eventArgs)
{