mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Add support for struct directed events. - Turn transform events into readonly structs * TransformComponent events have readonly fields. * Reduce boxing allocations, add DirectedRegistration readonly struct. * Use typeof in a few places instead of GetType * Add overloads to allow passing directed events by ref. * Raise transform events by ref. * Fix occluder AnchorStateChangedEvent subscription * Fix broadphase subscriptions * Fix bug oops * Fix transform system raising moveevents by value * Don't reflect the test entity systems. * Directed EventBus uses ref everywhere, internally Deduplicates a bunch of code. Whoo! * Add broadcast by-ref events * Fix by-ref events bug using Unsafe, add new tests for sorted by-ref events. * Port broadcast events to by-ref. * Speed, more correctness, reduce generics bloat. * Clean up subscription code some. * Remove bad test. Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
30 lines
910 B
C#
30 lines
910 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(ref EntParentChangedMessage message)
|
|
{
|
|
var oldParentEntity = message.OldParent;
|
|
|
|
if (oldParentEntity == null || !oldParentEntity.IsValid())
|
|
return;
|
|
|
|
if (oldParentEntity.TryGetComponent(out IContainerManager? containerManager))
|
|
containerManager.ForceRemove(message.Entity);
|
|
}
|
|
}
|
|
}
|