Refactor slip dropping to use throwing (#5476)

* Refactor slip dropping to use throwing

* Update Content.Server/Fluids/EntitySystems/SpillableSystem.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Uncringe

* Update Content.Server/Fluids/EntitySystems/SpillableSystem.cs

Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
This commit is contained in:
Clyybber
2021-11-24 00:38:39 +01:00
committed by GitHub
parent ee27c75224
commit 0e98c1c524
10 changed files with 113 additions and 121 deletions

View File

@@ -18,47 +18,6 @@ namespace Content.Shared.Hands
SubscribeAllEvent<RequestSetHandEvent>(HandleSetHand);
}
public void DropHandItems(IEntity entity, bool doMobChecks = true)
{
DropHandItems(entity.Uid, doMobChecks);
}
public void DropHandItems(EntityUid uid, bool doMobChecks = true, SharedHandsComponent? hands = null)
{
if (!Resolve(uid, ref hands))
return;
DropHandItems(hands, doMobChecks);
}
private void DropHandItems(SharedHandsComponent handsComponent, bool doMobChecks = true)
{
var msg = new DropHandItemsAttemptEvent();
var entity = handsComponent.Owner;
var uid = entity.Uid;
var eventBus = EntityManager.EventBus;
eventBus.RaiseLocalEvent(uid, msg);
if (msg.Cancelled)
return;
if (entity.TryGetContainerMan(out var containerManager))
{
var parentMsg = new ContainedEntityDropHandItemsAttemptEvent(uid);
eventBus.RaiseLocalEvent(containerManager.OwnerUid, parentMsg);
if (parentMsg.Cancelled)
return;
}
DropAllItemsInHands(entity, doMobChecks);
}
protected virtual void DropAllItemsInHands(IEntity entity, bool doMobChecks = true)
{
}
private static void HandleSetHand(RequestSetHandEvent msg, EntitySessionEventArgs eventArgs)
{
var entity = eventArgs.SenderSession.AttachedEntity;
@@ -78,18 +37,6 @@ namespace Content.Shared.Hands
}
}
public sealed class ContainedEntityDropHandItemsAttemptEvent : CancellableEntityEventArgs
{
public EntityUid EntityUid { get; }
public ContainedEntityDropHandItemsAttemptEvent(EntityUid uid)
{
EntityUid = uid;
}
}
public sealed class DropHandItemsAttemptEvent : CancellableEntityEventArgs {}
[Serializable, NetSerializable]
public class RequestSetHandEvent : EntityEventArgs
{