Remove IContainer and move some functions to the system (#4351)

This commit is contained in:
Leon Friedrich
2023-09-10 12:17:00 +10:00
committed by GitHub
parent 8274623edb
commit 5e21dbdd7f
21 changed files with 309 additions and 487 deletions
@@ -0,0 +1,26 @@
using Robust.Shared.GameObjects;
namespace Robust.Shared.Containers;
public abstract partial class SharedContainerSystem
{
/// <summary>
/// Checks if the entity can be removed from this container.
/// </summary>
/// <returns>True if the entity can be removed, false otherwise.</returns>
public bool CanRemove(EntityUid toRemove, BaseContainer container)
{
if (!container.Contains(toRemove))
return false;
//raise events
var removeAttemptEvent = new ContainerIsRemovingAttemptEvent(container, toRemove);
RaiseLocalEvent(container.Owner, removeAttemptEvent, true);
if (removeAttemptEvent.Cancelled)
return false;
var gettingRemovedAttemptEvent = new ContainerGettingRemovedAttemptEvent(container, toRemove);
RaiseLocalEvent(toRemove, gettingRemovedAttemptEvent, true);
return !gettingRemovedAttemptEvent.Cancelled;
}
}