Files
RobustToolbox/Robust.Shared/Containers/ContainerSystem.cs
Acruid 24707b7385 Shared Containers (#1579)
* Added a basic server simulation framework for help with tests.

* Moved as much as possible to Robust.Shared/Containers.
Moved ContainerSlot from content to engine.

* Moved ClientContainer to shared.

* Merged client/server ContainerManagerComponents into a single shared version.

* ContainerManagerComponent is now implicitly registered with the attributes.

* Migrated to 2021 serialization technology.

* Existing Unit Tests work.

* More tests coverage.
Fixed bug with transferring items between containers.

* Container Type info is now sent over the network.

* Merge client/server container systems.

* Code cleanup.

* Attempted to fix dictionary serialization.
Logs warning when trying to check if an unknown GridId is paused.

* Remove OldCode.
2021-03-01 15:19:59 -08:00

26 lines
811 B
C#

using Robust.Shared.GameObjects;
namespace Robust.Shared.Containers
{
public class ContainerSystem : EntitySystem
{
/// <inheritdoc />
public override void Initialize()
{
SubscribeLocalEvent<EntParentChangedMessage>(HandleParentChanged);
}
// Eject entities from their parent container if the parent change is done by the transform only.
private static void HandleParentChanged(EntParentChangedMessage message)
{
var oldParentEntity = message.OldParent;
if (oldParentEntity == null || !oldParentEntity.IsValid())
return;
if (oldParentEntity.TryGetComponent(out IContainerManager? containerManager))
containerManager.ForceRemove(message.Entity);
}
}
}