Remove hands component reference (#15197)

This commit is contained in:
DrSmugleaf
2023-04-07 11:21:12 -07:00
committed by GitHub
parent c54ee5290b
commit b947856431
73 changed files with 277 additions and 328 deletions

View File

@@ -48,7 +48,7 @@ public sealed class DoAfterSystem : SharedDoAfterSystem
var time = GameTiming.CurTime;
var comp = Comp<DoAfterComponent>(playerEntity.Value);
var xformQuery = GetEntityQuery<TransformComponent>();
var handsQuery = GetEntityQuery<SharedHandsComponent>();
var handsQuery = GetEntityQuery<HandsComponent>();
Update(playerEntity.Value, active, comp, time, xformQuery, handsQuery);
}
}

View File

@@ -1,23 +0,0 @@
using Content.Client.Hands.Systems;
using Content.Client.Hands.UI;
using Content.Shared.Hands.Components;
namespace Content.Client.Hands
{
[RegisterComponent]
[ComponentReference(typeof(SharedHandsComponent))]
[Access(typeof(HandsSystem))]
public sealed class HandsComponent : SharedHandsComponent
{
/// <summary>
/// Whether or not to add in-hand sprites for held items. Some entities (e.g., drones) don't want these.
/// </summary>
[DataField("showInHands")]
public bool ShowInHands = true;
/// <summary>
/// Data about the current sprite layers that the hand is contributing to the owner entity. Used for sprite in-hands.
/// </summary>
public readonly Dictionary<HandLocation, HashSet<string>> RevealedLayers = new();
}
}

View File

@@ -1,7 +1,8 @@
using System.Diagnostics.CodeAnalysis;
using Content.Client.Animations;
using Content.Client.Examine;
using Content.Client.Strip;
using Content.Client.Verbs;
using Content.Client.Verbs.UI;
using Content.Shared.Hands;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
@@ -9,13 +10,11 @@ using Content.Shared.Item;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Timing;
using System.Diagnostics.CodeAnalysis;
using Content.Client.Verbs.UI;
using Robust.Client.UserInterface;
namespace Content.Client.Hands.Systems
{
@@ -44,8 +43,8 @@ namespace Content.Client.Hands.Systems
{
base.Initialize();
SubscribeLocalEvent<SharedHandsComponent, EntRemovedFromContainerMessage>(HandleItemRemoved);
SubscribeLocalEvent<SharedHandsComponent, EntInsertedIntoContainerMessage>(HandleItemAdded);
SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleItemRemoved);
SubscribeLocalEvent<HandsComponent, EntInsertedIntoContainerMessage>(HandleItemAdded);
SubscribeLocalEvent<HandsComponent, PlayerAttachedEvent>(HandlePlayerAttached);
SubscribeLocalEvent<HandsComponent, PlayerDetachedEvent>(HandlePlayerDetached);
@@ -142,7 +141,7 @@ namespace Content.Client.Hands.Systems
OnPlayerHandsAdded?.Invoke(hands);
}
public override void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, SharedHandsComponent? hands = null)
public override void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, HandsComponent? hands = null)
{
base.DoDrop(uid, hand, doDropInteraction, hands);
@@ -252,7 +251,7 @@ namespace Content.Client.Hands.Systems
#region visuals
private void HandleItemAdded(EntityUid uid, SharedHandsComponent handComp, ContainerModifiedMessage args)
private void HandleItemAdded(EntityUid uid, HandsComponent handComp, ContainerModifiedMessage args)
{
if (!handComp.Hands.TryGetValue(args.Container.ID, out var hand))
return;
@@ -268,7 +267,7 @@ namespace Content.Client.Hands.Systems
OnPlayerHandBlocked?.Invoke(hand.Name);
}
private void HandleItemRemoved(EntityUid uid, SharedHandsComponent handComp, ContainerModifiedMessage args)
private void HandleItemRemoved(EntityUid uid, HandsComponent handComp, ContainerModifiedMessage args)
{
if (!handComp.Hands.TryGetValue(args.Container.ID, out var hand))
return;
@@ -393,12 +392,12 @@ namespace Content.Client.Hands.Systems
}
#endregion
private void AddHand(EntityUid uid, Hand newHand, SharedHandsComponent? handsComp = null)
private void AddHand(EntityUid uid, Hand newHand, HandsComponent? handsComp = null)
{
AddHand(uid, newHand.Name, newHand.Location, handsComp);
}
public override void AddHand(EntityUid uid, string handName, HandLocation handLocation, SharedHandsComponent? handsComp = null)
public override void AddHand(EntityUid uid, string handName, HandLocation handLocation, HandsComponent? handsComp = null)
{
base.AddHand(uid, handName, handLocation, handsComp);
@@ -411,7 +410,7 @@ namespace Content.Client.Hands.Systems
if (handsComp.ActiveHand == null)
SetActiveHand(uid, handsComp.Hands[handName], handsComp);
}
public override void RemoveHand(EntityUid uid, string handName, SharedHandsComponent? handsComp = null)
public override void RemoveHand(EntityUid uid, string handName, HandsComponent? handsComp = null)
{
if (uid == _playerManager.LocalPlayer?.ControlledEntity && handsComp != null &&
handsComp.Hands.ContainsKey(handName) && uid ==
@@ -423,7 +422,7 @@ namespace Content.Client.Hands.Systems
base.RemoveHand(uid, handName, handsComp);
}
private void OnHandActivated(SharedHandsComponent? handsComponent)
private void OnHandActivated(HandsComponent? handsComponent)
{
if (handsComponent == null)
return;

View File

@@ -2,7 +2,6 @@ using Content.Client.Clothing;
using Content.Client.Examine;
using Content.Client.Storage;
using Content.Client.UserInterface.Controls;
using Content.Client.Verbs;
using Content.Client.Verbs.UI;
using Content.Shared.Clothing.Components;
using Content.Shared.Hands.Components;
@@ -234,7 +233,7 @@ namespace Content.Client.Inventory
// TODO hud refactor This should also live in a UI Controller
private void HoverInSlotButton(EntityUid uid, string slot, SlotControl control,
InventoryComponent? inventoryComponent = null, SharedHandsComponent? hands = null)
InventoryComponent? inventoryComponent = null, HandsComponent? hands = null)
{
if (!Resolve(uid, ref inventoryComponent))
return;

View File

@@ -1,12 +1,9 @@
using System.Linq;
using Content.Client.Cuffs;
using Content.Client.Examine;
using Content.Client.Hands;
using Content.Client.Strip;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Hands.Controls;
using Content.Client.Verbs;
using Content.Client.Verbs.UI;
using Content.Shared.Cuffs;
using Content.Shared.Cuffs.Components;
@@ -16,7 +13,6 @@ using Content.Shared.IdentityManagement;
using Content.Shared.Input;
using Content.Shared.Inventory;
using Content.Shared.Strip.Components;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
@@ -24,7 +20,6 @@ using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using static Content.Client.Inventory.ClientInventorySystem;
using static Robust.Client.UserInterface.Control;

View File

@@ -1,5 +1,4 @@
using Content.Client.Gameplay;
using Content.Client.Hands;
using Content.Client.Hands.Systems;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Hands.Controls;
@@ -8,6 +7,7 @@ using Content.Shared.Cooldown;
using Content.Shared.Hands.Components;
using Content.Shared.Input;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Shared.Input;
@@ -19,6 +19,7 @@ namespace Content.Client.UserInterface.Systems.Hands;
public sealed class HandsUIController : UIController, IOnStateEntered<GameplayState>, IOnSystemChanged<HandsSystem>
{
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[UISystemDependency] private readonly HandsSystem _handsSystem = default!;
@@ -246,7 +247,8 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
if (HandsGui != null &&
_playerHandsComponent != null &&
_playerHandsComponent.Hands.TryGetValue(handName, out var hand))
_player.LocalPlayer?.ControlledEntity is { } playerEntity &&
_handsSystem.TryGetHand(playerEntity, handName, out var hand, _playerHandsComponent))
{
HandsGui.UpdatePanelEntity(hand.HeldEntity);
}

View File

@@ -1,11 +1,11 @@
using Content.Client.Gameplay;
using Content.Client.Hands;
using Content.Client.Hands.Systems;
using Content.Client.Inventory;
using Content.Client.Storage;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Inventory.Controls;
using Content.Client.UserInterface.Systems.Inventory.Windows;
using Content.Shared.Hands.Components;
using Content.Shared.Input;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;

View File

@@ -1,19 +1,17 @@
using Content.Client.CombatMode;
using Content.Client.Gameplay;
using Content.Client.Hands;
using Content.Shared.Hands.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.StatusEffect;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.StatusEffect;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
using Robust.Client.ResourceManagement;
using Robust.Client.State;
using Robust.Shared.Input;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;