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:
@@ -146,7 +146,7 @@ namespace Content.Shared.Hands.Components
|
||||
|
||||
private void RemoveHand(Hand hand)
|
||||
{
|
||||
DropHeldEntityToFloor(hand, intentionalDrop: false);
|
||||
DropHeldEntityToFloor(hand);
|
||||
hand.Container?.Shutdown();
|
||||
Hands.Remove(hand);
|
||||
|
||||
@@ -306,34 +306,34 @@ namespace Content.Shared.Hands.Components
|
||||
/// <summary>
|
||||
/// Tries to drop the contents of the active hand to the target location.
|
||||
/// </summary>
|
||||
public bool TryDropActiveHand(EntityCoordinates targetDropLocation, bool doMobChecks = true, bool intentional = true)
|
||||
public bool TryDropActiveHand(EntityCoordinates targetDropLocation, bool doMobChecks = true)
|
||||
{
|
||||
if (!TryGetActiveHand(out var hand))
|
||||
return false;
|
||||
|
||||
return TryDropHeldEntity(hand, targetDropLocation, doMobChecks, intentional);
|
||||
return TryDropHeldEntity(hand, targetDropLocation, doMobChecks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to drop the contents of a hand to the target location.
|
||||
/// </summary>
|
||||
public bool TryDropHand(string handName, EntityCoordinates targetDropLocation, bool checkActionBlocker = true, bool intentional = true)
|
||||
public bool TryDropHand(string handName, EntityCoordinates targetDropLocation, bool checkActionBlocker = true)
|
||||
{
|
||||
if (!TryGetHand(handName, out var hand))
|
||||
return false;
|
||||
|
||||
return TryDropHeldEntity(hand, targetDropLocation, checkActionBlocker, intentional);
|
||||
return TryDropHeldEntity(hand, targetDropLocation, checkActionBlocker);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to drop a held entity to the target location.
|
||||
/// </summary>
|
||||
public bool TryDropEntity(IEntity entity, EntityCoordinates coords, bool doMobChecks = true, bool intentional = true)
|
||||
public bool TryDropEntity(IEntity entity, EntityCoordinates coords, bool doMobChecks = true)
|
||||
{
|
||||
if (!TryGetHandHoldingEntity(entity, out var hand))
|
||||
return false;
|
||||
|
||||
return TryDropHeldEntity(hand, coords, doMobChecks, intentional);
|
||||
return TryDropHeldEntity(hand, coords, doMobChecks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -369,23 +369,23 @@ namespace Content.Shared.Hands.Components
|
||||
/// <summary>
|
||||
/// Tries to drop the contents of a hand directly under the player.
|
||||
/// </summary>
|
||||
public bool Drop(string handName, bool checkActionBlocker = true, bool intentionalDrop = true)
|
||||
public bool Drop(string handName, bool checkActionBlocker = true)
|
||||
{
|
||||
if (!TryGetHand(handName, out var hand))
|
||||
return false;
|
||||
|
||||
return TryDropHeldEntity(hand, Owner.Transform.Coordinates, checkActionBlocker, intentionalDrop);
|
||||
return TryDropHeldEntity(hand, Owner.Transform.Coordinates, checkActionBlocker);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to drop a held entity directly under the player.
|
||||
/// </summary>
|
||||
public bool Drop(IEntity entity, bool checkActionBlocker = true, bool intentionalDrop = true)
|
||||
public bool Drop(IEntity entity, bool checkActionBlocker = true)
|
||||
{
|
||||
if (!TryGetHandHoldingEntity(entity, out var hand))
|
||||
return false;
|
||||
|
||||
return TryDropHeldEntity(hand, Owner.Transform.Coordinates, checkActionBlocker, intentionalDrop);
|
||||
return TryDropHeldEntity(hand, Owner.Transform.Coordinates, checkActionBlocker);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -467,7 +467,7 @@ namespace Content.Shared.Hands.Components
|
||||
/// <summary>
|
||||
/// Drops a hands contents to the target location.
|
||||
/// </summary>
|
||||
public void DropHeldEntity(Hand hand, EntityCoordinates targetDropLocation, bool intentionalDrop = true)
|
||||
public void DropHeldEntity(Hand hand, EntityCoordinates targetDropLocation)
|
||||
{
|
||||
var heldEntity = hand.HeldEntity;
|
||||
|
||||
@@ -476,7 +476,7 @@ namespace Content.Shared.Hands.Components
|
||||
|
||||
RemoveHeldEntityFromHand(hand);
|
||||
|
||||
EntitySystem.Get<SharedInteractionSystem>().DroppedInteraction(Owner, heldEntity, intentionalDrop);
|
||||
EntitySystem.Get<SharedInteractionSystem>().DroppedInteraction(Owner, heldEntity);
|
||||
|
||||
heldEntity.Transform.WorldPosition = GetFinalDropCoordinates(targetDropLocation);
|
||||
|
||||
@@ -510,7 +510,7 @@ namespace Content.Shared.Hands.Components
|
||||
/// <summary>
|
||||
/// Tries to drop a hands contents to the target location.
|
||||
/// </summary>
|
||||
private bool TryDropHeldEntity(Hand hand, EntityCoordinates location, bool checkActionBlocker, bool intentionalDrop = true)
|
||||
private bool TryDropHeldEntity(Hand hand, EntityCoordinates location, bool checkActionBlocker)
|
||||
{
|
||||
if (!CanRemoveHeldEntityFromHand(hand))
|
||||
return false;
|
||||
@@ -518,16 +518,16 @@ namespace Content.Shared.Hands.Components
|
||||
if (checkActionBlocker && !PlayerCanDrop())
|
||||
return false;
|
||||
|
||||
DropHeldEntity(hand, location, intentionalDrop);
|
||||
DropHeldEntity(hand, location);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Drops the contents of a hand directly under the player.
|
||||
/// </summary>
|
||||
private void DropHeldEntityToFloor(Hand hand, bool intentionalDrop = true)
|
||||
private void DropHeldEntityToFloor(Hand hand)
|
||||
{
|
||||
DropHeldEntity(hand, Owner.Transform.Coordinates, intentionalDrop);
|
||||
DropHeldEntity(hand, Owner.Transform.Coordinates);
|
||||
}
|
||||
|
||||
private bool CanPutHeldEntityIntoContainer(Hand hand, IContainer targetContainer, bool checkActionBlocker)
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user