/// <inheritdoc /> public virtual bool CanRemove(EntityUid toremove, IEntityManager?entMan = null) { DebugTools.Assert(!Deleted); if (!Contains(toremove)) { return(false); } IoCManager.Resolve(ref entMan); //raise events var removeAttemptEvent = new ContainerIsRemovingAttemptEvent(this, toremove); entMan.EventBus.RaiseLocalEvent(Owner, removeAttemptEvent); if (removeAttemptEvent.Cancelled) { return(false); } var gettingRemovedAttemptEvent = new ContainerGettingRemovedAttemptEvent(this, toremove); entMan.EventBus.RaiseLocalEvent(toremove, gettingRemovedAttemptEvent); if (gettingRemovedAttemptEvent.Cancelled) { return(false); } return(true); }
/// <summary> /// Prevents an item with the Unremovable component from being removed from a container by almost any means /// </summary> private void OnRemoveAttempt(EntityUid uid, UnremoveableComponent item, ContainerGettingRemovedAttemptEvent args) { args.Cancel(); }