mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 11:40:52 +01:00
* Fix containers that hold entities not on client * Delete from ExpectedEntities when entity removed * Fix ContainerSystem not registering on the server * Move container state to entity system Move client code to client * Fix removal and clean up code * Add test * Add more checks to test * Remove unneeded deletion event handler When the child is deleted, if the entity does not exist on the client, then HandleComponentState runs. If the entity does exist, then HandleEntityInitialized would have run. Either way HandleEntityDeleted is not needed. * Renamed unexpected to removedExpected
30 lines
906 B
C#
30 lines
906 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Robust.Shared.Containers
|
|
{
|
|
public abstract class SharedContainerSystem : EntitySystem
|
|
{
|
|
/// <inheritdoc />
|
|
public override void Initialize()
|
|
{
|
|
base.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);
|
|
}
|
|
}
|
|
}
|