Kill ContainerHelpers (#20908)
This commit is contained in:
@@ -15,6 +15,7 @@ namespace Content.Client.Commands
|
|||||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
{
|
{
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
var containerSys = entityManager.System<SharedContainerSystem>();
|
||||||
var organs = entityManager.EntityQuery<OrganComponent>(true);
|
var organs = entityManager.EntityQuery<OrganComponent>(true);
|
||||||
|
|
||||||
foreach (var part in organs)
|
foreach (var part in organs)
|
||||||
@@ -27,7 +28,7 @@ namespace Content.Client.Commands
|
|||||||
sprite.ContainerOccluded = false;
|
sprite.ContainerOccluded = false;
|
||||||
|
|
||||||
var tempParent = part.Owner;
|
var tempParent = part.Owner;
|
||||||
while (tempParent.TryGetContainer(out var container))
|
while (containerSys.TryGetContainingContainer(tempParent, out var container))
|
||||||
{
|
{
|
||||||
if (!container.ShowContents)
|
if (!container.ShowContents)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -174,8 +174,9 @@ namespace Content.Client.Instruments.UI
|
|||||||
if (localPlayer.ControlledEntity == instrumentEnt)
|
if (localPlayer.ControlledEntity == instrumentEnt)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
var container = _owner.Entities.System<SharedContainerSystem>();
|
||||||
// If we're a handheld instrument, we might be in a container. Get it just in case.
|
// If we're a handheld instrument, we might be in a container. Get it just in case.
|
||||||
instrumentEnt.TryGetContainerMan(out var conMan);
|
container.TryGetContainingContainer(instrumentEnt, out var conMan);
|
||||||
|
|
||||||
// If the instrument is handheld and we're not holding it, we return.
|
// If the instrument is handheld and we're not holding it, we return.
|
||||||
if ((instrument.Handheld && (conMan == null || conMan.Owner != localPlayer.ControlledEntity)))
|
if ((instrument.Handheld && (conMan == null || conMan.Owner != localPlayer.ControlledEntity)))
|
||||||
|
|||||||
@@ -6,15 +6,17 @@ namespace Content.Client.Interactable
|
|||||||
{
|
{
|
||||||
public sealed class InteractionSystem : SharedInteractionSystem
|
public sealed class InteractionSystem : SharedInteractionSystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||||
|
|
||||||
public override bool CanAccessViaStorage(EntityUid user, EntityUid target)
|
public override bool CanAccessViaStorage(EntityUid user, EntityUid target)
|
||||||
{
|
{
|
||||||
if (!EntityManager.EntityExists(target))
|
if (!EntityManager.EntityExists(target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!target.TryGetContainer(out var container))
|
if (!_container.TryGetContainingContainer(target, out var container))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!TryComp(container.Owner, out StorageComponent? storage))
|
if (!HasComp<StorageComponent>(container.Owner))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// we don't check if the user can access the storage entity itself. This should be handed by the UI system.
|
// we don't check if the user can access the storage entity itself. This should be handed by the UI system.
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ namespace Content.Server.Containers
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class EmptyOnMachineDeconstructSystem : EntitySystem
|
public sealed class EmptyOnMachineDeconstructSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -33,12 +35,12 @@ namespace Content.Server.Containers
|
|||||||
{
|
{
|
||||||
if (!EntityManager.TryGetComponent<ContainerManagerComponent>(uid, out var mComp))
|
if (!EntityManager.TryGetComponent<ContainerManagerComponent>(uid, out var mComp))
|
||||||
return;
|
return;
|
||||||
var baseCoords = EntityManager.GetComponent<TransformComponent>(component.Owner).Coordinates;
|
var baseCoords = EntityManager.GetComponent<TransformComponent>(uid).Coordinates;
|
||||||
foreach (var v in component.Containers)
|
foreach (var v in component.Containers)
|
||||||
{
|
{
|
||||||
if (mComp.TryGetContainer(v, out var container))
|
if (mComp.TryGetContainer(v, out var container))
|
||||||
{
|
{
|
||||||
container.EmptyContainer(true, baseCoords);
|
_container.EmptyContainer(container, true, baseCoords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using Content.Shared.Destructible;
|
|||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ namespace Content.Server.Destructible
|
|||||||
[Dependency] public readonly TriggerSystem TriggerSystem = default!;
|
[Dependency] public readonly TriggerSystem TriggerSystem = default!;
|
||||||
[Dependency] public readonly SolutionContainerSystem SolutionContainerSystem = default!;
|
[Dependency] public readonly SolutionContainerSystem SolutionContainerSystem = default!;
|
||||||
[Dependency] public readonly PuddleSystem PuddleSystem = default!;
|
[Dependency] public readonly PuddleSystem PuddleSystem = default!;
|
||||||
|
[Dependency] public readonly SharedContainerSystem ContainerSystem = default!;
|
||||||
[Dependency] public readonly IPrototypeManager PrototypeManager = default!;
|
[Dependency] public readonly IPrototypeManager PrototypeManager = default!;
|
||||||
[Dependency] public readonly IComponentFactory ComponentFactory = default!;
|
[Dependency] public readonly IComponentFactory ComponentFactory = default!;
|
||||||
[Dependency] public readonly IAdminLogManager _adminLogger = default!;
|
[Dependency] public readonly IAdminLogManager _adminLogger = default!;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
|||||||
|
|
||||||
foreach (var container in containerManager.GetAllContainers())
|
foreach (var container in containerManager.GetAllContainers())
|
||||||
{
|
{
|
||||||
container.EmptyContainer(true, system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates);
|
system.ContainerSystem.EmptyContainer(container, true, system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace Content.Server.Guardian
|
|||||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
[Dependency] private readonly BodySystem _bodySystem = default!;
|
[Dependency] private readonly BodySystem _bodySystem = default!;
|
||||||
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -88,7 +89,7 @@ namespace Content.Server.Guardian
|
|||||||
|
|
||||||
private void OnHostInit(EntityUid uid, GuardianHostComponent component, ComponentInit args)
|
private void OnHostInit(EntityUid uid, GuardianHostComponent component, ComponentInit args)
|
||||||
{
|
{
|
||||||
component.GuardianContainer = uid.EnsureContainer<ContainerSlot>("GuardianContainer");
|
component.GuardianContainer = _container.EnsureContainer<ContainerSlot>(uid, "GuardianContainer");
|
||||||
_actionSystem.AddAction(uid, ref component.ActionEntity, component.Action);
|
_actionSystem.AddAction(uid, ref component.ActionEntity, component.Action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,9 +169,9 @@ namespace Content.Server.Hands.Systems
|
|||||||
|
|
||||||
if (playerSession.AttachedEntity is not {Valid: true} player ||
|
if (playerSession.AttachedEntity is not {Valid: true} player ||
|
||||||
!Exists(player) ||
|
!Exists(player) ||
|
||||||
player.IsInContainer() ||
|
ContainerSystem.IsEntityInContainer(player) ||
|
||||||
!TryComp(player, out HandsComponent? hands) ||
|
!TryComp(player, out HandsComponent? hands) ||
|
||||||
hands.ActiveHandEntity is not EntityUid throwEnt ||
|
hands.ActiveHandEntity is not { } throwEnt ||
|
||||||
!_actionBlockerSystem.CanThrow(player, throwEnt))
|
!_actionBlockerSystem.CanThrow(player, throwEnt))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using Content.Server.Atmos.EntitySystems;
|
|||||||
using Content.Server.Body.Components;
|
using Content.Server.Body.Components;
|
||||||
using Content.Server.Body.Systems;
|
using Content.Server.Body.Systems;
|
||||||
using Content.Server.Chemistry.EntitySystems;
|
using Content.Server.Chemistry.EntitySystems;
|
||||||
using Content.Server.Nutrition.Components;
|
|
||||||
using Content.Shared.Nutrition.Components;
|
using Content.Shared.Nutrition.Components;
|
||||||
using Content.Shared.Chemistry;
|
using Content.Shared.Chemistry;
|
||||||
using Content.Shared.Chemistry.Reagent;
|
using Content.Shared.Chemistry.Reagent;
|
||||||
@@ -29,11 +28,12 @@ namespace Content.Server.Nutrition.EntitySystems
|
|||||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||||
[Dependency] private readonly ClothingSystem _clothing = default!;
|
[Dependency] private readonly ClothingSystem _clothing = default!;
|
||||||
[Dependency] private readonly SharedItemSystem _items = default!;
|
[Dependency] private readonly SharedItemSystem _items = default!;
|
||||||
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||||
|
|
||||||
private const float UpdateTimer = 3f;
|
private const float UpdateTimer = 3f;
|
||||||
|
|
||||||
private float _timer = 0f;
|
private float _timer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// We keep a list of active smokables, because iterating all existing smokables would be dumb.
|
/// We keep a list of active smokables, because iterating all existing smokables would be dumb.
|
||||||
@@ -130,8 +130,8 @@ namespace Content.Server.Nutrition.EntitySystems
|
|||||||
|
|
||||||
// This is awful. I hate this so much.
|
// This is awful. I hate this so much.
|
||||||
// TODO: Please, someone refactor containers and free me from this bullshit.
|
// TODO: Please, someone refactor containers and free me from this bullshit.
|
||||||
if (!smokable.Owner.TryGetContainerMan(out var containerManager) ||
|
if (!_container.TryGetContainingContainer(uid, out var containerManager) ||
|
||||||
!(_inventorySystem.TryGetSlotEntity(containerManager.Owner, "mask", out var inMaskSlotUid) && inMaskSlotUid == smokable.Owner) ||
|
!(_inventorySystem.TryGetSlotEntity(containerManager.Owner, "mask", out var inMaskSlotUid) && inMaskSlotUid == uid) ||
|
||||||
!TryComp(containerManager.Owner, out BloodstreamComponent? bloodstream))
|
!TryComp(containerManager.Owner, out BloodstreamComponent? bloodstream))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public sealed class EscapeInventorySystem : EntitySystem
|
|||||||
if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs, out component.DoAfter))
|
if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs, out component.DoAfter))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Dirty(component);
|
Dirty(user, component);
|
||||||
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting"), user, user);
|
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting"), user, user);
|
||||||
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting-target"), container, container);
|
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting-target"), container, container);
|
||||||
}
|
}
|
||||||
@@ -88,12 +88,12 @@ public sealed class EscapeInventorySystem : EntitySystem
|
|||||||
private void OnEscape(EntityUid uid, CanEscapeInventoryComponent component, EscapeInventoryEvent args)
|
private void OnEscape(EntityUid uid, CanEscapeInventoryComponent component, EscapeInventoryEvent args)
|
||||||
{
|
{
|
||||||
component.DoAfter = null;
|
component.DoAfter = null;
|
||||||
Dirty(component);
|
Dirty(uid, component);
|
||||||
|
|
||||||
if (args.Handled || args.Cancelled)
|
if (args.Handled || args.Cancelled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Transform(uid).AttachParentToContainerOrGrid(EntityManager);
|
_containerSystem.AttachParentToContainerOrGrid(Transform(uid));
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,8 @@ using Robust.Shared.Map;
|
|||||||
|
|
||||||
namespace Content.Shared.Hands.EntitySystems;
|
namespace Content.Shared.Hands.EntitySystems;
|
||||||
|
|
||||||
public abstract partial class SharedHandsSystem : EntitySystem
|
public abstract partial class SharedHandsSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
|
||||||
|
|
||||||
private void InitializeDrop()
|
private void InitializeDrop()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleEntityRemoved);
|
SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleEntityRemoved);
|
||||||
@@ -23,10 +21,10 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
var gotUnequipped = new GotUnequippedHandEvent(uid, args.Entity, hand);
|
var gotUnequipped = new GotUnequippedHandEvent(uid, args.Entity, hand);
|
||||||
RaiseLocalEvent(args.Entity, gotUnequipped, false);
|
RaiseLocalEvent(args.Entity, gotUnequipped);
|
||||||
|
|
||||||
var didUnequip = new DidUnequipHandEvent(uid, args.Entity, hand);
|
var didUnequip = new DidUnequipHandEvent(uid, args.Entity, hand);
|
||||||
RaiseLocalEvent(uid, didUnequip, false);
|
RaiseLocalEvent(uid, didUnequip);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -37,7 +35,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
if (hand.Container?.ContainedEntity is not {} held)
|
if (hand.Container?.ContainedEntity is not {} held)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!_container.CanRemove(held, hand.Container))
|
if (!ContainerSystem.CanRemove(held, hand.Container))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (checkActionBlocker && !_actionBlocker.CanDrop(uid))
|
if (checkActionBlocker && !_actionBlocker.CanDrop(uid))
|
||||||
@@ -90,7 +88,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
|
|
||||||
var userXform = Transform(uid);
|
var userXform = Transform(uid);
|
||||||
var itemXform = Transform(entity);
|
var itemXform = Transform(entity);
|
||||||
var isInContainer = _containerSystem.IsEntityInContainer(uid);
|
var isInContainer = ContainerSystem.IsEntityInContainer(uid);
|
||||||
|
|
||||||
if (targetDropLocation == null || isInContainer)
|
if (targetDropLocation == null || isInContainer)
|
||||||
{
|
{
|
||||||
@@ -98,14 +96,14 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
// TODO recursively check upwards for containers
|
// TODO recursively check upwards for containers
|
||||||
|
|
||||||
if (!isInContainer
|
if (!isInContainer
|
||||||
|| !_containerSystem.TryGetContainingContainer(userXform.ParentUid, uid, out var container, skipExistCheck: true)
|
|| !ContainerSystem.TryGetContainingContainer(userXform.ParentUid, uid, out var container, skipExistCheck: true)
|
||||||
|| !container.Insert(entity, EntityManager, itemXform))
|
|| !container.Insert(entity, EntityManager, itemXform))
|
||||||
itemXform.AttachToGridOrMap();
|
TransformSystem.AttachToGridOrMap(entity, itemXform);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var target = targetDropLocation.Value.ToMap(EntityManager);
|
var target = targetDropLocation.Value.ToMap(EntityManager, TransformSystem);
|
||||||
itemXform.WorldPosition = GetFinalDropCoordinates(uid, userXform.MapPosition, target);
|
TransformSystem.SetWorldPosition(userXform, GetFinalDropCoordinates(uid, userXform.MapPosition, target));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +121,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
if (!CanDropHeld(uid, hand, checkActionBlocker))
|
if (!CanDropHeld(uid, hand, checkActionBlocker))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!_container.CanInsert(entity, targetContainer))
|
if (!ContainerSystem.CanInsert(entity, targetContainer))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DoDrop(uid, hand, false, handsComp);
|
DoDrop(uid, hand, false, handsComp);
|
||||||
@@ -171,12 +169,12 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dirty(handsComp);
|
Dirty(uid, handsComp);
|
||||||
|
|
||||||
if (doDropInteraction)
|
if (doDropInteraction)
|
||||||
_interactionSystem.DroppedInteraction(uid, entity);
|
_interactionSystem.DroppedInteraction(uid, entity);
|
||||||
|
|
||||||
if (hand == handsComp.ActiveHand)
|
if (hand == handsComp.ActiveHand)
|
||||||
RaiseLocalEvent(entity, new HandDeselectedEvent(uid), false);
|
RaiseLocalEvent(entity, new HandDeselectedEvent(uid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// check can insert (including raising attempt events).
|
// check can insert (including raising attempt events).
|
||||||
return _containerSystem.CanInsert(entity, handContainer);
|
return ContainerSystem.CanInsert(entity, handContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -202,7 +202,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
// TODO make this check upwards for any container, and parent to that.
|
// TODO make this check upwards for any container, and parent to that.
|
||||||
// Currently this just checks the direct parent, so items can still teleport through containers.
|
// Currently this just checks the direct parent, so items can still teleport through containers.
|
||||||
Transform(entity).AttachParentToContainerOrGrid(EntityManager);
|
ContainerSystem.AttachParentToContainerOrGrid(Transform(entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public abstract partial class SharedHandsSystem
|
|||||||
private void OnVirtualAfter(EntityUid uid, HandVirtualItemComponent component, ref AfterAutoHandleStateEvent args)
|
private void OnVirtualAfter(EntityUid uid, HandVirtualItemComponent component, ref AfterAutoHandleStateEvent args)
|
||||||
{
|
{
|
||||||
// update hands GUI with new entity.
|
// update hands GUI with new entity.
|
||||||
if (_containerSystem.IsEntityInContainer(uid))
|
if (ContainerSystem.IsEntityInContainer(uid))
|
||||||
_items.VisualsChanged(uid);
|
_items.VisualsChanged(uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ using Robust.Shared.Input.Binding;
|
|||||||
|
|
||||||
namespace Content.Shared.Hands.EntitySystems;
|
namespace Content.Shared.Hands.EntitySystems;
|
||||||
|
|
||||||
public abstract partial class SharedHandsSystem : EntitySystem
|
public abstract partial class SharedHandsSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||||
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
||||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||||
[Dependency] private readonly SharedItemSystem _items = default!;
|
[Dependency] private readonly SharedItemSystem _items = default!;
|
||||||
[Dependency] private readonly SharedStorageSystem _storage = default!;
|
[Dependency] private readonly SharedStorageSystem _storage = default!;
|
||||||
@@ -47,7 +47,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
if (handsComp.Hands.ContainsKey(handName))
|
if (handsComp.Hands.ContainsKey(handName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var container = _containerSystem.EnsureContainer<ContainerSlot>(uid, handName);
|
var container = ContainerSystem.EnsureContainer<ContainerSlot>(uid, handName);
|
||||||
container.OccludesLight = false;
|
container.OccludesLight = false;
|
||||||
|
|
||||||
var newHand = new Hand(handName, handLocation, container);
|
var newHand = new Hand(handName, handLocation, container);
|
||||||
@@ -57,8 +57,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
if (handsComp.ActiveHand == null)
|
if (handsComp.ActiveHand == null)
|
||||||
SetActiveHand(uid, newHand, handsComp);
|
SetActiveHand(uid, newHand, handsComp);
|
||||||
|
|
||||||
RaiseLocalEvent(uid, new HandCountChangedEvent(uid), false);
|
RaiseLocalEvent(uid, new HandCountChangedEvent(uid));
|
||||||
Dirty(handsComp);
|
Dirty(uid, handsComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void RemoveHand(EntityUid uid, string handName, HandsComponent? handsComp = null)
|
public virtual void RemoveHand(EntityUid uid, string handName, HandsComponent? handsComp = null)
|
||||||
@@ -76,8 +76,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
if (handsComp.ActiveHand == hand)
|
if (handsComp.ActiveHand == hand)
|
||||||
TrySetActiveHand(uid, handsComp.SortedHands.FirstOrDefault(), handsComp);
|
TrySetActiveHand(uid, handsComp.SortedHands.FirstOrDefault(), handsComp);
|
||||||
|
|
||||||
RaiseLocalEvent(uid, new HandCountChangedEvent(uid), false);
|
RaiseLocalEvent(uid, new HandCountChangedEvent(uid));
|
||||||
Dirty(handsComp);
|
Dirty(uid, handsComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -169,7 +169,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
if (name == handsComp.ActiveHand?.Name)
|
if (name == handsComp.ActiveHand?.Name)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (handsComp.Hands[name].HeldEntity is EntityUid held)
|
if (handsComp.Hands[name].HeldEntity is { } held)
|
||||||
yield return held;
|
yield return held;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,8 +206,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
if (hand == handComp.ActiveHand)
|
if (hand == handComp.ActiveHand)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (handComp.ActiveHand?.HeldEntity is EntityUid held)
|
if (handComp.ActiveHand?.HeldEntity is { } held)
|
||||||
RaiseLocalEvent(held, new HandDeselectedEvent(uid), false);
|
RaiseLocalEvent(held, new HandDeselectedEvent(uid));
|
||||||
|
|
||||||
if (hand == null)
|
if (hand == null)
|
||||||
{
|
{
|
||||||
@@ -219,8 +219,9 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
|||||||
OnHandSetActive?.Invoke(handComp);
|
OnHandSetActive?.Invoke(handComp);
|
||||||
|
|
||||||
if (hand.HeldEntity != null)
|
if (hand.HeldEntity != null)
|
||||||
RaiseLocalEvent(hand.HeldEntity.Value, new HandSelectedEvent(uid), false);
|
RaiseLocalEvent(hand.HeldEntity.Value, new HandSelectedEvent(uid));
|
||||||
Dirty(handComp);
|
|
||||||
|
Dirty(uid, handComp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user