Fix misc cuffing issues (#12127)

This commit is contained in:
Leon Friedrich
2022-10-22 18:54:28 +13:00
committed by GitHub
parent b75cd3f7ca
commit b73d188e67
4 changed files with 27 additions and 7 deletions

View File

@@ -108,7 +108,17 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
foreach (var (name, hand) in handsComp.Hands)
{
var handButton = AddHand(name, hand.Location);
handButton.SpriteView.Sprite = _entities.GetComponentOrNull<SpriteComponent>(hand.HeldEntity);
if (_entities.TryGetComponent(hand.HeldEntity, out HandVirtualItemComponent? virt))
{
handButton.SpriteView.Sprite = _entities.GetComponentOrNull<SpriteComponent>(virt.BlockingEntity);
handButton.Blocked = true;
}
else
{
handButton.SpriteView.Sprite = _entities.GetComponentOrNull<SpriteComponent>(hand.HeldEntity);
handButton.Blocked = false;
}
}
var activeHand = handsComp.ActiveHand;
@@ -149,9 +159,16 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
var hand = GetHand(name);
if (hand == null)
return;
if (_entities.TryGetComponent(entity, out ISpriteComponent? sprite))
if (_entities.TryGetComponent(entity, out HandVirtualItemComponent? virt))
{
hand.SpriteView.Sprite = sprite;
hand.SpriteView.Sprite = _entities.GetComponentOrNull<SpriteComponent>(virt.BlockingEntity);
hand.Blocked = true;
}
else
{
hand.SpriteView.Sprite = _entities.GetComponentOrNull<SpriteComponent>(entity);
hand.Blocked = false;
}
if (_playerHandsComponent?.ActiveHand?.Name == name)