Clean up Drop and fix IDropped.Dropped (#2057)
This commit is contained in:
@@ -224,8 +224,10 @@ namespace Content.Server.GameObjects.Components.GUI
|
||||
if (!interactionSystem.TryDroppedInteraction(Owner, item.Owner))
|
||||
return false;
|
||||
}
|
||||
|
||||
interactionSystem.DroppedInteraction(Owner, item.Owner);
|
||||
else
|
||||
{
|
||||
interactionSystem.DroppedInteraction(Owner, item.Owner);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -248,7 +250,7 @@ namespace Content.Server.GameObjects.Components.GUI
|
||||
public bool Drop(string slot, EntityCoordinates coords, bool doMobChecks = true)
|
||||
{
|
||||
var hand = GetHand(slot);
|
||||
if (!CanDrop(slot) || hand?.Entity == null)
|
||||
if (!CanDrop(slot, doMobChecks) || hand?.Entity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -260,12 +262,17 @@ namespace Content.Server.GameObjects.Components.GUI
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!DroppedInteraction(item, doMobChecks))
|
||||
if (!DroppedInteraction(item, false))
|
||||
return false;
|
||||
|
||||
item.RemovedFromSlot();
|
||||
item.Owner.Transform.Coordinates = coords;
|
||||
|
||||
if (item.Owner.TryGetComponent<SpriteComponent>(out var spriteComponent))
|
||||
{
|
||||
spriteComponent.RenderOrder = item.Owner.EntityManager.CurrentTick.Value;
|
||||
}
|
||||
|
||||
if (ContainerHelpers.TryGetContainer(Owner, out var container))
|
||||
{
|
||||
container.Insert(item.Owner);
|
||||
@@ -294,39 +301,7 @@ namespace Content.Server.GameObjects.Components.GUI
|
||||
|
||||
public bool Drop(string slot, bool mobChecks = true)
|
||||
{
|
||||
var hand = GetHand(slot);
|
||||
if (!CanDrop(slot, mobChecks) || hand?.Entity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var item = hand.Entity.GetComponent<ItemComponent>();
|
||||
|
||||
if (!DroppedInteraction(item, mobChecks))
|
||||
return false;
|
||||
|
||||
if (!hand.Container.Remove(hand.Entity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
item.RemovedFromSlot();
|
||||
item.Owner.Transform.Coordinates = Owner.Transform.Coordinates;
|
||||
|
||||
if (item.Owner.TryGetComponent<SpriteComponent>(out var spriteComponent))
|
||||
{
|
||||
spriteComponent.RenderOrder = item.Owner.EntityManager.CurrentTick.Value;
|
||||
}
|
||||
|
||||
if (ContainerHelpers.TryGetContainer(Owner, out var container))
|
||||
{
|
||||
container.Insert(item.Owner);
|
||||
}
|
||||
|
||||
OnItemChanged?.Invoke();
|
||||
|
||||
Dirty();
|
||||
return true;
|
||||
return Drop(slot, Owner.Transform.Coordinates, mobChecks);
|
||||
}
|
||||
|
||||
public bool Drop(IEntity entity, bool mobChecks = true)
|
||||
@@ -341,7 +316,7 @@ namespace Content.Server.GameObjects.Components.GUI
|
||||
throw new ArgumentException("Entity must be held in one of our hands.", nameof(entity));
|
||||
}
|
||||
|
||||
return Drop(slot, mobChecks);
|
||||
return Drop(slot, Owner.Transform.Coordinates, mobChecks);
|
||||
}
|
||||
|
||||
public bool Drop(string slot, BaseContainer targetContainer, bool doMobChecks = true)
|
||||
@@ -357,16 +332,11 @@ namespace Content.Server.GameObjects.Components.GUI
|
||||
}
|
||||
|
||||
var hand = GetHand(slot);
|
||||
if (!CanDrop(slot) || hand?.Entity == null)
|
||||
if (!CanDrop(slot, doMobChecks) || hand?.Entity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var item = hand.Entity.GetComponent<ItemComponent>();
|
||||
|
||||
if (!DroppedInteraction(item, doMobChecks))
|
||||
return false;
|
||||
|
||||
if (!hand.Container.CanRemove(hand.Entity))
|
||||
{
|
||||
return false;
|
||||
@@ -377,11 +347,16 @@ namespace Content.Server.GameObjects.Components.GUI
|
||||
return false;
|
||||
}
|
||||
|
||||
var item = hand.Entity.GetComponent<ItemComponent>();
|
||||
|
||||
if (!hand.Container.Remove(hand.Entity))
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
if (!DroppedInteraction(item, doMobChecks))
|
||||
return false;
|
||||
|
||||
item.RemovedFromSlot();
|
||||
|
||||
if (!targetContainer.Insert(item.Owner))
|
||||
|
||||
Reference in New Issue
Block a user