Fix uplink item spawning.

Actually spawns for the person who USES the uplink, not who owns it. Can't believe that was an actual bug.

Also puts it in your active hand if possible.
This commit is contained in:
Pieter-Jan Briers
2021-02-04 01:24:37 +01:00
parent d45835e863
commit a4563d2e75
4 changed files with 48 additions and 15 deletions

View File

@@ -198,14 +198,33 @@ namespace Content.Server.GameObjects.Components.GUI
return success;
}
/// <summary>
/// Drops the item if <paramref name="mob"/> doesn't have hands.
/// </summary>
public static void PutInHandOrDropStatic(IEntity mob, ItemComponent item, bool mobCheck = true)
{
if (!mob.TryGetComponent(out HandsComponent? hands))
{
DropAtFeet(mob, item);
return;
}
hands.PutInHandOrDrop(item, mobCheck);
}
public void PutInHandOrDrop(ItemComponent item, bool mobCheck = true)
{
if (!PutInHand(item, mobCheck))
{
item.Owner.Transform.Coordinates = Owner.Transform.Coordinates;
DropAtFeet(Owner, item);
}
}
private static void DropAtFeet(IEntity mob, ItemComponent item)
{
item.Owner.Transform.Coordinates = mob.Transform.Coordinates;
}
public bool CanPutInHand(ItemComponent item, bool mobCheck = true)
{
if (mobCheck && !ActionBlockerSystem.CanPickup(Owner))