Updated ContainerHelpers to use new extensions (#2530)
Co-authored-by: David Tan <>
This commit is contained in:
@@ -29,7 +29,7 @@ namespace Content.Client.Commands
|
|||||||
sprite.ContainerOccluded = false;
|
sprite.ContainerOccluded = false;
|
||||||
|
|
||||||
var tempParent = mechanism.Owner;
|
var tempParent = mechanism.Owner;
|
||||||
while (ContainerHelpers.TryGetContainer(tempParent, out var container))
|
while (tempParent.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
if (!container.ShowContents)
|
if (!container.ShowContents)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace Content.Client.GameObjects.Components.Items
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
_equippedPrefix = value;
|
_equippedPrefix = value;
|
||||||
if (!ContainerHelpers.TryGetContainer(Owner, out IContainer container)) return;
|
if (!Owner.TryGetContainer(out IContainer container)) return;
|
||||||
if(container.Owner.TryGetComponent(out HandsComponent hands))
|
if(container.Owner.TryGetComponent(out HandsComponent hands))
|
||||||
hands.RefreshInHands();
|
hands.RefreshInHands();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!_playerCanSeeThroughContainers &&
|
if (!_playerCanSeeThroughContainers &&
|
||||||
ContainerHelpers.TryGetContainer(entity, out var container) &&
|
entity.TryGetContainer(out var container) &&
|
||||||
!container.ShowContents)
|
!container.ShowContents)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ namespace Content.Client.Instruments
|
|||||||
var instrumentEnt = _owner.Instrument.Owner;
|
var instrumentEnt = _owner.Instrument.Owner;
|
||||||
var instrument = _owner.Instrument;
|
var instrument = _owner.Instrument;
|
||||||
|
|
||||||
ContainerHelpers.TryGetContainerMan(_owner.Instrument.Owner, out var conMan);
|
_owner.Instrument.Owner.TryGetContainerMan(out var conMan);
|
||||||
|
|
||||||
var localPlayer = IoCManager.Resolve<IPlayerManager>().LocalPlayer;
|
var localPlayer = IoCManager.Resolve<IPlayerManager>().LocalPlayer;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace Content.Server.AI.Operators.Inventory
|
|||||||
|
|
||||||
public override Outcome Execute(float frameTime)
|
public override Outcome Execute(float frameTime)
|
||||||
{
|
{
|
||||||
if (!ContainerHelpers.TryGetContainer(_target, out var container))
|
if (!_target.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
return Outcome.Success;
|
return Outcome.Success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace Content.Server.AI.Operators.Inventory
|
|||||||
{
|
{
|
||||||
if (_target.Deleted ||
|
if (_target.Deleted ||
|
||||||
!_target.HasComponent<ItemComponent>() ||
|
!_target.HasComponent<ItemComponent>() ||
|
||||||
ContainerHelpers.IsInContainer(_target) ||
|
_target.IsInContainer() ||
|
||||||
!_owner.InRangeUnobstructed(_target, popup: true))
|
!_owner.InRangeUnobstructed(_target, popup: true))
|
||||||
{
|
{
|
||||||
return Outcome.Failed;
|
return Outcome.Failed;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Content.Server.AI.Utility.Considerations.Containers
|
|||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContainerHelpers.TryGetContainer(target, out var container))
|
if (target.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
if (container.Owner.TryGetComponent(out EntityStorageComponent storageComponent))
|
if (container.Owner.TryGetComponent(out EntityStorageComponent storageComponent))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Content.Server.AI.WorldState.States.Clothing
|
|||||||
foreach (var entity in Visibility
|
foreach (var entity in Visibility
|
||||||
.GetNearestEntities(Owner.Transform.Coordinates, typeof(ClothingComponent), controller.VisionRadius))
|
.GetNearestEntities(Owner.Transform.Coordinates, typeof(ClothingComponent), controller.VisionRadius))
|
||||||
{
|
{
|
||||||
if (ContainerHelpers.TryGetContainer(entity, out var container))
|
if (entity.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
if (!container.Owner.HasComponent<EntityStorageComponent>())
|
if (!container.Owner.HasComponent<EntityStorageComponent>())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition
|
|||||||
foreach (var entity in Visibility
|
foreach (var entity in Visibility
|
||||||
.GetNearestEntities(Owner.Transform.Coordinates, typeof(DrinkComponent), controller.VisionRadius))
|
.GetNearestEntities(Owner.Transform.Coordinates, typeof(DrinkComponent), controller.VisionRadius))
|
||||||
{
|
{
|
||||||
if (ContainerHelpers.TryGetContainer(entity, out var container))
|
if (entity.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
if (!container.Owner.HasComponent<EntityStorageComponent>())
|
if (!container.Owner.HasComponent<EntityStorageComponent>())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition
|
|||||||
foreach (var entity in Visibility
|
foreach (var entity in Visibility
|
||||||
.GetNearestEntities(Owner.Transform.Coordinates, typeof(FoodComponent), controller.VisionRadius))
|
.GetNearestEntities(Owner.Transform.Coordinates, typeof(FoodComponent), controller.VisionRadius))
|
||||||
{
|
{
|
||||||
if (ContainerHelpers.TryGetContainer(entity, out var container))
|
if (entity.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
if (!container.Owner.HasComponent<EntityStorageComponent>())
|
if (!container.Owner.HasComponent<EntityStorageComponent>())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ namespace Content.Server.Atmos
|
|||||||
{
|
{
|
||||||
if (!entity.TryGetComponent(out IPhysicsComponent physics)
|
if (!entity.TryGetComponent(out IPhysicsComponent physics)
|
||||||
|| !entity.TryGetComponent(out MovedByPressureComponent pressure)
|
|| !entity.TryGetComponent(out MovedByPressureComponent pressure)
|
||||||
|| ContainerHelpers.IsInContainer(entity))
|
|| entity.IsInContainer())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
physics.WakeBody();
|
physics.WakeBody();
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
private InternalsComponent? GetInternalsComponent(IEntity? owner = null)
|
private InternalsComponent? GetInternalsComponent(IEntity? owner = null)
|
||||||
{
|
{
|
||||||
if (owner != null) return owner.GetComponentOrNull<InternalsComponent>();
|
if (owner != null) return owner.GetComponentOrNull<InternalsComponent>();
|
||||||
return ContainerHelpers.TryGetContainer(Owner, out var container)
|
return Owner.TryGetContainer(out var container)
|
||||||
? container.Owner.GetComponentOrNull<InternalsComponent>()
|
? container.Owner.GetComponentOrNull<InternalsComponent>()
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,10 +199,10 @@ namespace Content.Server.GameObjects.Components.Buckle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If in a container
|
// If in a container
|
||||||
if (ContainerHelpers.TryGetContainer(Owner, out var ownerContainer))
|
if (Owner.TryGetContainer(out var ownerContainer))
|
||||||
{
|
{
|
||||||
// And not in the same container as the strap
|
// And not in the same container as the strap
|
||||||
if (!ContainerHelpers.TryGetContainer(strap.Owner, out var strapContainer) ||
|
if (!strap.Owner.TryGetContainer(out var strapContainer) ||
|
||||||
ownerContainer != strapContainer)
|
ownerContainer != strapContainer)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -336,7 +336,7 @@ namespace Content.Server.GameObjects.Components.Buckle
|
|||||||
|
|
||||||
if (Owner.Transform.Parent == oldBuckledTo.Owner.Transform)
|
if (Owner.Transform.Parent == oldBuckledTo.Owner.Transform)
|
||||||
{
|
{
|
||||||
ContainerHelpers.AttachParentToContainerOrGrid(Owner.Transform);
|
Owner.Transform.AttachParentToContainerOrGrid();
|
||||||
Owner.Transform.WorldRotation = oldBuckledTo.Owner.Transform.WorldRotation;
|
Owner.Transform.WorldRotation = oldBuckledTo.Owner.Transform.WorldRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ namespace Content.Server.GameObjects.Components.Conveyor
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContainerHelpers.IsInContainer(entity))
|
if (entity.IsInContainer())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
|
|
||||||
if (entity.Transform.Parent == Owner.Transform)
|
if (entity.Transform.Parent == Owner.Transform)
|
||||||
{
|
{
|
||||||
ContainerHelpers.AttachParentToContainerOrGrid(entity.Transform);
|
entity.Transform.AttachParentToContainerOrGrid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -720,7 +720,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContainerHelpers.IsInContainer(eventArgs.User))
|
if (eventArgs.User.IsInContainer())
|
||||||
{
|
{
|
||||||
Owner.PopupMessage(eventArgs.User, Loc.GetString("You can't reach there!"));
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("You can't reach there!"));
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -623,7 +623,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContainerHelpers.IsInContainer(eventArgs.User))
|
if (eventArgs.User.IsInContainer())
|
||||||
{
|
{
|
||||||
Owner.PopupMessage(eventArgs.User, Loc.GetString("You can't reach there!"));
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("You can't reach there!"));
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace Content.Server.GameObjects.Components.Explosion
|
|||||||
public bool Explode()
|
public bool Explode()
|
||||||
{
|
{
|
||||||
// If we're in a locker or whatever then can't flash anything
|
// If we're in a locker or whatever then can't flash anything
|
||||||
ContainerHelpers.TryGetContainer(Owner, out var container);
|
Owner.TryGetContainer(out var container);
|
||||||
if (container == null || !container.Owner.HasComponent<EntityStorageComponent>())
|
if (container == null || !container.Owner.HasComponent<EntityStorageComponent>())
|
||||||
{
|
{
|
||||||
FlashableComponent.FlashAreaHelper(Owner, _range, _duration);
|
FlashableComponent.FlashAreaHelper(Owner, _range, _duration);
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ namespace Content.Server.GameObjects.Components.GUI
|
|||||||
spriteComponent.RenderOrder = item.Owner.EntityManager.CurrentTick.Value;
|
spriteComponent.RenderOrder = item.Owner.EntityManager.CurrentTick.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContainerHelpers.TryGetContainer(Owner, out var container))
|
if (Owner.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
container.Insert(item.Owner);
|
container.Insert(item.Owner);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ namespace Content.Server.GameObjects.Components.GUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: The item should be dropped to the container our owner is in, if any.
|
// TODO: The item should be dropped to the container our owner is in, if any.
|
||||||
ContainerHelpers.AttachParentToContainerOrGrid(entity.Transform);
|
entity.Transform.AttachParentToContainerOrGrid();
|
||||||
|
|
||||||
_entitySystemManager.GetEntitySystem<InteractionSystem>().UnequippedInteraction(Owner, entity, slot);
|
_entitySystemManager.GetEntitySystem<InteractionSystem>().UnequippedInteraction(Owner, entity, slot);
|
||||||
|
|
||||||
@@ -321,7 +321,7 @@ namespace Content.Server.GameObjects.Components.GUI
|
|||||||
|
|
||||||
var itemTransform = entity.Transform;
|
var itemTransform = entity.Transform;
|
||||||
|
|
||||||
ContainerHelpers.AttachParentToContainerOrGrid(itemTransform);
|
itemTransform.AttachParentToContainerOrGrid();
|
||||||
|
|
||||||
_entitySystemManager.GetEntitySystem<InteractionSystem>().UnequippedInteraction(Owner, item.Owner, slot);
|
_entitySystemManager.GetEntitySystem<InteractionSystem>().UnequippedInteraction(Owner, item.Owner, slot);
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace Content.Server.GameObjects.Components.Headset
|
|||||||
|
|
||||||
public void Receive(string message, int channel, IEntity source)
|
public void Receive(string message, int channel, IEntity source)
|
||||||
{
|
{
|
||||||
if (ContainerHelpers.TryGetContainer(Owner, out var container))
|
if (Owner.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
if (!container.Owner.TryGetComponent(out IActorComponent actor))
|
if (!container.Owner.TryGetComponent(out IActorComponent actor))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
protected override void GetData(IEntity user, ItemComponent component, VerbData data)
|
protected override void GetData(IEntity user, ItemComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
if (!ActionBlockerSystem.CanInteract(user) ||
|
if (!ActionBlockerSystem.CanInteract(user) ||
|
||||||
ContainerHelpers.IsInContainer(component.Owner) ||
|
component.Owner.IsInContainer() ||
|
||||||
!component.CanPickup(user))
|
!component.CanPickup(user))
|
||||||
{
|
{
|
||||||
data.Visibility = VerbVisibility.Invisible;
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ namespace Content.Server.GameObjects.Components.Recycling
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContainerHelpers.IsInContainer(entity))
|
if (entity.IsInContainer())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ namespace Content.Server.GameObjects.Components.Singularity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContainerHelpers.IsInContainer(entity)) return;
|
if (entity.IsInContainer()) return;
|
||||||
|
|
||||||
entity.Delete();
|
entity.Delete();
|
||||||
Energy++;
|
Energy++;
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
if (_chamberContainer.ContainedEntity == null && manual)
|
if (_chamberContainer.ContainedEntity == null && manual)
|
||||||
{
|
{
|
||||||
BoltOpen = true;
|
BoltOpen = true;
|
||||||
if (ContainerHelpers.TryGetContainer(Owner, out var container))
|
if (Owner.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
Owner.PopupMessage(container.Owner, Loc.GetString("Bolt opened"));
|
Owner.PopupMessage(container.Owner, Loc.GetString("Bolt opened"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
soundSystem.PlayAtCoords(_soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5));
|
soundSystem.PlayAtCoords(_soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContainerHelpers.TryGetContainer(Owner, out var container))
|
if (Owner.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
Owner.PopupMessage(container.Owner, Loc.GetString("Bolt open"));
|
Owner.PopupMessage(container.Owner, Loc.GetString("Bolt open"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var contained = ContainerHelpers.TryGetContainer(buckle.Owner, out var ownContainer);
|
var contained = buckle.Owner.TryGetContainer(out var ownContainer);
|
||||||
var strapContained = ContainerHelpers.TryGetContainer(strap.Owner, out var strapContainer);
|
var strapContained = strap.Owner.TryGetContainer(out var strapContainer);
|
||||||
|
|
||||||
if (contained != strapContained || ownContainer != strapContainer)
|
if (contained != strapContained || ownContainer != strapContainer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -329,19 +329,19 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If in a container
|
// If in a container
|
||||||
if (ContainerHelpers.IsInContainer(player))
|
if (player.IsInContainer())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// In a container where the attacked entity is not the container's owner
|
// In a container where the attacked entity is not the container's owner
|
||||||
if (ContainerHelpers.TryGetContainer(player, out var playerContainer) &&
|
if (player.TryGetContainer(out var playerContainer) &&
|
||||||
attacked != playerContainer.Owner)
|
attacked != playerContainer.Owner)
|
||||||
{
|
{
|
||||||
// Either the attacked entity is null, not contained or in a different container
|
// Either the attacked entity is null, not contained or in a different container
|
||||||
if (attacked == null ||
|
if (attacked == null ||
|
||||||
!ContainerHelpers.TryGetContainer(attacked, out var attackedContainer) ||
|
!attacked.TryGetContainer(out var attackedContainer) ||
|
||||||
attackedContainer != playerContainer)
|
attackedContainer != playerContainer)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
private bool TrySlip(IEntity entity)
|
private bool TrySlip(IEntity entity)
|
||||||
{
|
{
|
||||||
if (!Slippery
|
if (!Slippery
|
||||||
|| ContainerHelpers.IsInContainer(Owner)
|
|| Owner.IsInContainer()
|
||||||
|| _slipped.Contains(entity.Uid)
|
|| _slipped.Contains(entity.Uid)
|
||||||
|| !entity.TryGetComponent(out SharedStunnableComponent stun)
|
|| !entity.TryGetComponent(out SharedStunnableComponent stun)
|
||||||
|| !entity.TryGetComponent(out IPhysicsComponent otherBody)
|
|| !entity.TryGetComponent(out IPhysicsComponent otherBody)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Content.Shared.GameObjects.Components
|
|||||||
_count = value;
|
_count = value;
|
||||||
if (_count <= 0)
|
if (_count <= 0)
|
||||||
{
|
{
|
||||||
if (ContainerHelpers.TryGetContainerMan(Owner, out var containerManager))
|
if (Owner.TryGetContainerMan(out var containerManager))
|
||||||
{
|
{
|
||||||
containerManager.Remove(Owner);
|
containerManager.Remove(Owner);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
|
|
||||||
Ignored predicate = entity => entity == examiner || entity == examined;
|
Ignored predicate = entity => entity == examiner || entity == examined;
|
||||||
|
|
||||||
if (ContainerHelpers.TryGetContainer(examiner, out var container))
|
if (examiner.TryGetContainer(out var container))
|
||||||
{
|
{
|
||||||
predicate += entity => entity == container.Owner;
|
predicate += entity => entity == container.Owner;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace Content.Shared.GameObjects.Verbs
|
|||||||
{
|
{
|
||||||
if (!user.IsInSameOrNoContainer(target))
|
if (!user.IsInSameOrNoContainer(target))
|
||||||
{
|
{
|
||||||
if (!ContainerHelpers.TryGetContainer(target, out var container) ||
|
if (!target.TryGetContainer(out var container) ||
|
||||||
container.Owner != user)
|
container.Owner != user)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user