Fixes inventories and throwing. (#133)
This commit is contained in:
committed by
Pieter-Jan Briers
parent
37df61113e
commit
69946c79d8
@@ -234,7 +234,7 @@ namespace Content.Server.GameObjects
|
||||
var activehand = hands.GetActiveHand;
|
||||
if (activehand != null && activehand.Owner.TryGetComponent(out ClothingComponent clothing))
|
||||
{
|
||||
hands.Drop(hands.ActiveIndex, null);
|
||||
hands.Drop(hands.ActiveIndex);
|
||||
if (!Equip(msg.Inventoryslot, clothing))
|
||||
{
|
||||
hands.PutInHand(clothing);
|
||||
|
||||
@@ -233,7 +233,6 @@ namespace Content.Server.GameObjects
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public bool Drop(IEntity entity)
|
||||
{
|
||||
if (entity == null)
|
||||
@@ -252,6 +251,16 @@ namespace Content.Server.GameObjects
|
||||
|
||||
public bool Drop(string slot, BaseContainer targetContainer)
|
||||
{
|
||||
if (slot == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(slot));
|
||||
}
|
||||
|
||||
if (targetContainer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(targetContainer));
|
||||
}
|
||||
|
||||
if (!CanDrop(slot))
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -127,20 +127,17 @@ namespace Content.Server.GameObjects
|
||||
{
|
||||
_ensureInitialCalculated();
|
||||
Logger.DebugS("Storage", "Storage (UID {0}) attacked by user (UID {1}) with entity (UID {2}).", Owner.Uid, user.Uid, attackwith.Uid);
|
||||
var hands = user.GetComponent<HandsComponent>();
|
||||
|
||||
if (!user.TryGetComponent(out HandsComponent hands))
|
||||
return false;
|
||||
|
||||
//Check that we can drop the item from our hands first otherwise we obviously cant put it inside
|
||||
if (hands.Drop(hands.ActiveIndex, null))
|
||||
if (hands.Drop(hands.ActiveIndex))
|
||||
{
|
||||
var inserted = Insert(attackwith);
|
||||
if (inserted)
|
||||
if (Insert(attackwith))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Return the object to the hand since its too big or something like that
|
||||
hands.PutInHand(attackwith.GetComponent<ItemComponent>());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
// pop off an item, or throw the single item in hand.
|
||||
if (!throwEnt.TryGetComponent(out StackComponent stackComp) || stackComp.Count < 2)
|
||||
{
|
||||
handsComp.Drop(handsComp.ActiveIndex, null);
|
||||
handsComp.Drop(handsComp.ActiveIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user