public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var entityManager = IoCManager.Resolve<IEntityManager>();
+ var containerSys = entityManager.System<SharedContainerSystem>();
var organs = entityManager.EntityQuery<OrganComponent>(true);
foreach (var part in organs)
sprite.ContainerOccluded = false;
var tempParent = part.Owner;
- while (tempParent.TryGetContainer(out var container))
+ while (containerSys.TryGetContainingContainer(tempParent, out var container))
{
if (!container.ShowContents)
{
if (localPlayer.ControlledEntity == instrumentEnt)
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.
- 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 ((instrument.Handheld && (conMan == null || conMan.Owner != localPlayer.ControlledEntity)))
{
public sealed class InteractionSystem : SharedInteractionSystem
{
+ [Dependency] private readonly SharedContainerSystem _container = default!;
+
public override bool CanAccessViaStorage(EntityUid user, EntityUid target)
{
if (!EntityManager.EntityExists(target))
return false;
- if (!target.TryGetContainer(out var container))
+ if (!_container.TryGetContainingContainer(target, out var container))
return false;
- if (!TryComp(container.Owner, out StorageComponent? storage))
+ if (!HasComp<StorageComponent>(container.Owner))
return false;
// we don't check if the user can access the storage entity itself. This should be handed by the UI system.
[UsedImplicitly]
public sealed class EmptyOnMachineDeconstructSystem : EntitySystem
{
+ [Dependency] private readonly SharedContainerSystem _container = default!;
+
public override void Initialize()
{
base.Initialize();
{
if (!EntityManager.TryGetComponent<ContainerManagerComponent>(uid, out var mComp))
return;
- var baseCoords = EntityManager.GetComponent<TransformComponent>(component.Owner).Coordinates;
+ var baseCoords = EntityManager.GetComponent<TransformComponent>(uid).Coordinates;
foreach (var v in component.Containers)
{
if (mComp.TryGetContainer(v, out var container))
{
- container.EmptyContainer(true, baseCoords);
+ _container.EmptyContainer(container, true, baseCoords);
}
}
}
using Content.Shared.FixedPoint;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
+using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
[Dependency] public readonly TriggerSystem TriggerSystem = default!;
[Dependency] public readonly SolutionContainerSystem SolutionContainerSystem = default!;
[Dependency] public readonly PuddleSystem PuddleSystem = default!;
+ [Dependency] public readonly SharedContainerSystem ContainerSystem = default!;
[Dependency] public readonly IPrototypeManager PrototypeManager = default!;
[Dependency] public readonly IComponentFactory ComponentFactory = default!;
[Dependency] public readonly IAdminLogManager _adminLogger = default!;
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);
}
}
}
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly BodySystem _bodySystem = default!;
+ [Dependency] private readonly SharedContainerSystem _container = default!;
public override void Initialize()
{
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);
}
if (playerSession.AttachedEntity is not {Valid: true} player ||
!Exists(player) ||
- player.IsInContainer() ||
+ ContainerSystem.IsEntityInContainer(player) ||
!TryComp(player, out HandsComponent? hands) ||
- hands.ActiveHandEntity is not EntityUid throwEnt ||
+ hands.ActiveHandEntity is not { } throwEnt ||
!_actionBlockerSystem.CanThrow(player, throwEnt))
return false;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.EntitySystems;
-using Content.Server.Nutrition.Components;
using Content.Shared.Nutrition.Components;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Reagent;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly ClothingSystem _clothing = default!;
[Dependency] private readonly SharedItemSystem _items = default!;
+ [Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
private const float UpdateTimer = 3f;
- private float _timer = 0f;
+ private float _timer;
/// <summary>
/// We keep a list of active smokables, because iterating all existing smokables would be dumb.
// This is awful. I hate this so much.
// TODO: Please, someone refactor containers and free me from this bullshit.
- if (!smokable.Owner.TryGetContainerMan(out var containerManager) ||
- !(_inventorySystem.TryGetSlotEntity(containerManager.Owner, "mask", out var inMaskSlotUid) && inMaskSlotUid == smokable.Owner) ||
+ if (!_container.TryGetContainingContainer(uid, out var containerManager) ||
+ !(_inventorySystem.TryGetSlotEntity(containerManager.Owner, "mask", out var inMaskSlotUid) && inMaskSlotUid == uid) ||
!TryComp(containerManager.Owner, out BloodstreamComponent? bloodstream))
{
continue;
if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs, out component.DoAfter))
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-target"), container, container);
}
private void OnEscape(EntityUid uid, CanEscapeInventoryComponent component, EscapeInventoryEvent args)
{
component.DoAfter = null;
- Dirty(component);
+ Dirty(uid, component);
if (args.Handled || args.Cancelled)
return;
- Transform(uid).AttachParentToContainerOrGrid(EntityManager);
+ _containerSystem.AttachParentToContainerOrGrid(Transform(uid));
args.Handled = true;
}
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()
{
SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleEntityRemoved);
}
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);
- RaiseLocalEvent(uid, didUnequip, false);
+ RaiseLocalEvent(uid, didUnequip);
}
/// <summary>
if (hand.Container?.ContainedEntity is not {} held)
return false;
- if (!_container.CanRemove(held, hand.Container))
+ if (!ContainerSystem.CanRemove(held, hand.Container))
return false;
if (checkActionBlocker && !_actionBlocker.CanDrop(uid))
var userXform = Transform(uid);
var itemXform = Transform(entity);
- var isInContainer = _containerSystem.IsEntityInContainer(uid);
+ var isInContainer = ContainerSystem.IsEntityInContainer(uid);
if (targetDropLocation == null || isInContainer)
{
// TODO recursively check upwards for containers
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))
- itemXform.AttachToGridOrMap();
+ TransformSystem.AttachToGridOrMap(entity, itemXform);
return true;
}
- var target = targetDropLocation.Value.ToMap(EntityManager);
- itemXform.WorldPosition = GetFinalDropCoordinates(uid, userXform.MapPosition, target);
+ var target = targetDropLocation.Value.ToMap(EntityManager, TransformSystem);
+ TransformSystem.SetWorldPosition(userXform, GetFinalDropCoordinates(uid, userXform.MapPosition, target));
return true;
}
if (!CanDropHeld(uid, hand, checkActionBlocker))
return false;
- if (!_container.CanInsert(entity, targetContainer))
+ if (!ContainerSystem.CanInsert(entity, targetContainer))
return false;
DoDrop(uid, hand, false, handsComp);
return;
}
- Dirty(handsComp);
+ Dirty(uid, handsComp);
if (doDropInteraction)
_interactionSystem.DroppedInteraction(uid, entity);
if (hand == handsComp.ActiveHand)
- RaiseLocalEvent(entity, new HandDeselectedEvent(uid), false);
+ RaiseLocalEvent(entity, new HandDeselectedEvent(uid));
}
}
return false;
// check can insert (including raising attempt events).
- return _containerSystem.CanInsert(entity, handContainer);
+ return ContainerSystem.CanInsert(entity, handContainer);
}
/// <summary>
{
// 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.
- Transform(entity).AttachParentToContainerOrGrid(EntityManager);
+ ContainerSystem.AttachParentToContainerOrGrid(Transform(entity));
}
}
private void OnVirtualAfter(EntityUid uid, HandVirtualItemComponent component, ref AfterAutoHandleStateEvent args)
{
// update hands GUI with new entity.
- if (_containerSystem.IsEntityInContainer(uid))
+ if (ContainerSystem.IsEntityInContainer(uid))
_items.VisualsChanged(uid);
}
}
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 ActionBlockerSystem _actionBlocker = default!;
- [Dependency] private readonly SharedContainerSystem _containerSystem = default!;
+ [Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly SharedItemSystem _items = default!;
[Dependency] private readonly SharedStorageSystem _storage = default!;
if (handsComp.Hands.ContainsKey(handName))
return;
- var container = _containerSystem.EnsureContainer<ContainerSlot>(uid, handName);
+ var container = ContainerSystem.EnsureContainer<ContainerSlot>(uid, handName);
container.OccludesLight = false;
var newHand = new Hand(handName, handLocation, container);
if (handsComp.ActiveHand == null)
SetActiveHand(uid, newHand, handsComp);
- RaiseLocalEvent(uid, new HandCountChangedEvent(uid), false);
- Dirty(handsComp);
+ RaiseLocalEvent(uid, new HandCountChangedEvent(uid));
+ Dirty(uid, handsComp);
}
public virtual void RemoveHand(EntityUid uid, string handName, HandsComponent? handsComp = null)
if (handsComp.ActiveHand == hand)
TrySetActiveHand(uid, handsComp.SortedHands.FirstOrDefault(), handsComp);
- RaiseLocalEvent(uid, new HandCountChangedEvent(uid), false);
- Dirty(handsComp);
+ RaiseLocalEvent(uid, new HandCountChangedEvent(uid));
+ Dirty(uid, handsComp);
}
/// <summary>
if (name == handsComp.ActiveHand?.Name)
continue;
- if (handsComp.Hands[name].HeldEntity is EntityUid held)
+ if (handsComp.Hands[name].HeldEntity is { } held)
yield return held;
}
}
if (hand == handComp.ActiveHand)
return false;
- if (handComp.ActiveHand?.HeldEntity is EntityUid held)
- RaiseLocalEvent(held, new HandDeselectedEvent(uid), false);
+ if (handComp.ActiveHand?.HeldEntity is { } held)
+ RaiseLocalEvent(held, new HandDeselectedEvent(uid));
if (hand == null)
{
OnHandSetActive?.Invoke(handComp);
if (hand.HeldEntity != null)
- RaiseLocalEvent(hand.HeldEntity.Value, new HandSelectedEvent(uid), false);
- Dirty(handComp);
+ RaiseLocalEvent(hand.HeldEntity.Value, new HandSelectedEvent(uid));
+
+ Dirty(uid, handComp);
return true;
}