diff --git a/Content.Client/Hands/HandsComponent.cs b/Content.Client/Hands/HandsComponent.cs index 4276ca1e9c..78d288ac24 100644 --- a/Content.Client/Hands/HandsComponent.cs +++ b/Content.Client/Hands/HandsComponent.cs @@ -28,15 +28,12 @@ namespace Content.Client.Hands ActiveHand = state.ActiveHand; - UpdateHandContainers(); - UpdateHandVisualizer(); - Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new HandsModifiedMessage { Hands = this }); + HandsModified(); } public override void HandsModified() { UpdateHandContainers(); - UpdateHandVisualizer(); base.HandsModified(); } @@ -55,28 +52,5 @@ namespace Content.Client.Hands } } } - - public void UpdateHandVisualizer() - { - if (Owner.TryGetComponent(out SharedAppearanceComponent? appearance)) - appearance.SetData(HandsVisuals.VisualState, GetHandsVisualState()); - } - - private HandsVisualState GetHandsVisualState() - { - var hands = new List(); - foreach (var hand in Hands) - { - if (hand.HeldEntity == null) - continue; - - if (!hand.HeldEntity.TryGetComponent(out SharedItemComponent? item) || item.RsiPath == null) - continue; - - var handState = new HandVisualState(item.RsiPath, item.EquippedPrefix, hand.Location, item.Color); - hands.Add(handState); - } - return new(hands); - } } } diff --git a/Content.Client/Hands/HandsVisualizer.cs b/Content.Client/Hands/HandsVisualizer.cs index e8291d49ea..993e1032b5 100644 --- a/Content.Client/Hands/HandsVisualizer.cs +++ b/Content.Client/Hands/HandsVisualizer.cs @@ -61,38 +61,4 @@ namespace Content.Client.Hands return location.ToString(); } } - - public enum HandsVisuals : byte - { - VisualState - } - - public class HandsVisualState - { - public List Hands { get; } = new(); - - public HandsVisualState(List hands) - { - Hands = hands; - } - } - - public class HandVisualState - { - public string RsiPath { get; } - - public string? EquippedPrefix { get; } - - public HandLocation Location { get; } - - public Color Color { get; } - - public HandVisualState(string rsiPath, string? equippedPrefix, HandLocation location, Color color) - { - RsiPath = rsiPath; - EquippedPrefix = equippedPrefix; - Location = location; - Color = color; - } - } } diff --git a/Content.Shared/Hands/Components/SharedHandsComponent.cs b/Content.Shared/Hands/Components/SharedHandsComponent.cs index 80278e6357..03c3867bde 100644 --- a/Content.Shared/Hands/Components/SharedHandsComponent.cs +++ b/Content.Shared/Hands/Components/SharedHandsComponent.cs @@ -91,11 +91,34 @@ namespace Content.Shared.Hands.Components public virtual void HandsModified() { // todo axe all this for ECS. + // todo burn it all down. + UpdateHandVisualizer(); Dirty(); Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new HandsModifiedMessage { Hands = this }); } + public void UpdateHandVisualizer() + { + if (!Owner.TryGetComponent(out SharedAppearanceComponent? appearance)) + return; + + var hands = new List(); + foreach (var hand in Hands) + { + if (hand.HeldEntity == null) + continue; + + if (!hand.HeldEntity.TryGetComponent(out SharedItemComponent? item) || item.RsiPath == null) + continue; + + var handState = new HandVisualState(item.RsiPath, item.EquippedPrefix, hand.Location, item.Color); + hands.Add(handState); + } + + appearance.SetData(HandsVisuals.VisualState, new HandsVisualState(hands)); + } + public void AddHand(string handName, HandLocation handLocation) { if (HasHand(handName)) @@ -812,6 +835,42 @@ namespace Content.Shared.Hands.Components protected virtual void HandlePickupAnimation(IEntity entity) { } } + #region visualizerData + [Serializable, NetSerializable] + public enum HandsVisuals : byte + { + VisualState + } + + [Serializable, NetSerializable] + public class HandsVisualState + { + public List Hands { get; } = new(); + + public HandsVisualState(List hands) + { + Hands = hands; + } + } + + [Serializable, NetSerializable] + public class HandVisualState + { + public string RsiPath { get; } + public string? EquippedPrefix { get; } + public HandLocation Location { get; } + public Color Color { get; } + + public HandVisualState(string rsiPath, string? equippedPrefix, HandLocation location, Color color) + { + RsiPath = rsiPath; + EquippedPrefix = equippedPrefix; + Location = location; + Color = color; + } + } + #endregion + public class Hand { [ViewVariables]