Kill ContainerHelpers (#20908)
This commit is contained in:
@@ -6,10 +6,8 @@ using Robust.Shared.Map;
|
||||
|
||||
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);
|
||||
@@ -23,10 +21,10 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
}
|
||||
|
||||
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>
|
||||
@@ -37,7 +35,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
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))
|
||||
@@ -90,7 +88,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
|
||||
var userXform = Transform(uid);
|
||||
var itemXform = Transform(entity);
|
||||
var isInContainer = _containerSystem.IsEntityInContainer(uid);
|
||||
var isInContainer = ContainerSystem.IsEntityInContainer(uid);
|
||||
|
||||
if (targetDropLocation == null || isInContainer)
|
||||
{
|
||||
@@ -98,14 +96,14 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -123,7 +121,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
if (!CanDropHeld(uid, hand, checkActionBlocker))
|
||||
return false;
|
||||
|
||||
if (!_container.CanInsert(entity, targetContainer))
|
||||
if (!ContainerSystem.CanInsert(entity, targetContainer))
|
||||
return false;
|
||||
|
||||
DoDrop(uid, hand, false, handsComp);
|
||||
@@ -171,12 +169,12 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
return false;
|
||||
|
||||
// check can insert (including raising attempt events).
|
||||
return _containerSystem.CanInsert(entity, handContainer);
|
||||
return ContainerSystem.CanInsert(entity, handContainer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -202,7 +202,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ public abstract partial class SharedHandsSystem
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ using Robust.Shared.Input.Binding;
|
||||
|
||||
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!;
|
||||
@@ -47,7 +47,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
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);
|
||||
@@ -57,8 +57,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
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)
|
||||
@@ -76,8 +76,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
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>
|
||||
@@ -169,7 +169,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
if (name == handsComp.ActiveHand?.Name)
|
||||
continue;
|
||||
|
||||
if (handsComp.Hands[name].HeldEntity is EntityUid held)
|
||||
if (handsComp.Hands[name].HeldEntity is { } held)
|
||||
yield return held;
|
||||
}
|
||||
}
|
||||
@@ -206,8 +206,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
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)
|
||||
{
|
||||
@@ -219,8 +219,9 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user