Fix stuck in-hand sprites (#5068)
This commit is contained in:
@@ -28,15 +28,12 @@ namespace Content.Client.Hands
|
|||||||
|
|
||||||
ActiveHand = state.ActiveHand;
|
ActiveHand = state.ActiveHand;
|
||||||
|
|
||||||
UpdateHandContainers();
|
HandsModified();
|
||||||
UpdateHandVisualizer();
|
|
||||||
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new HandsModifiedMessage { Hands = this });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandsModified()
|
public override void HandsModified()
|
||||||
{
|
{
|
||||||
UpdateHandContainers();
|
UpdateHandContainers();
|
||||||
UpdateHandVisualizer();
|
|
||||||
|
|
||||||
base.HandsModified();
|
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<HandVisualState>();
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,38 +61,4 @@ namespace Content.Client.Hands
|
|||||||
return location.ToString();
|
return location.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum HandsVisuals : byte
|
|
||||||
{
|
|
||||||
VisualState
|
|
||||||
}
|
|
||||||
|
|
||||||
public class HandsVisualState
|
|
||||||
{
|
|
||||||
public List<HandVisualState> Hands { get; } = new();
|
|
||||||
|
|
||||||
public HandsVisualState(List<HandVisualState> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,11 +91,34 @@ namespace Content.Shared.Hands.Components
|
|||||||
public virtual void HandsModified()
|
public virtual void HandsModified()
|
||||||
{
|
{
|
||||||
// todo axe all this for ECS.
|
// todo axe all this for ECS.
|
||||||
|
// todo burn it all down.
|
||||||
|
UpdateHandVisualizer();
|
||||||
Dirty();
|
Dirty();
|
||||||
|
|
||||||
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new HandsModifiedMessage { Hands = this });
|
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new HandsModifiedMessage { Hands = this });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateHandVisualizer()
|
||||||
|
{
|
||||||
|
if (!Owner.TryGetComponent(out SharedAppearanceComponent? appearance))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var hands = new List<HandVisualState>();
|
||||||
|
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)
|
public void AddHand(string handName, HandLocation handLocation)
|
||||||
{
|
{
|
||||||
if (HasHand(handName))
|
if (HasHand(handName))
|
||||||
@@ -812,6 +835,42 @@ namespace Content.Shared.Hands.Components
|
|||||||
protected virtual void HandlePickupAnimation(IEntity entity) { }
|
protected virtual void HandlePickupAnimation(IEntity entity) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region visualizerData
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum HandsVisuals : byte
|
||||||
|
{
|
||||||
|
VisualState
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public class HandsVisualState
|
||||||
|
{
|
||||||
|
public List<HandVisualState> Hands { get; } = new();
|
||||||
|
|
||||||
|
public HandsVisualState(List<HandVisualState> 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
|
public class Hand
|
||||||
{
|
{
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
|
|||||||
Reference in New Issue
Block a user