Fixed ItemContainer not setting the position of a contained item when it's placed in the ItemInventory, minor refactoring
This commit is contained in:
@@ -111,18 +111,7 @@ namespace Barotrauma
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void DropItem(Item item)
|
||||
{
|
||||
bool enabled = item.body!=null && item.body.Enabled;
|
||||
item.Drop(character);
|
||||
|
||||
if (!enabled)
|
||||
{
|
||||
item.SetTransform(character.SimPosition, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int FindLimbSlot(InvSlotType limbSlot)
|
||||
{
|
||||
for (int i = 0; i < Items.Length; i++)
|
||||
|
||||
@@ -121,21 +121,21 @@ namespace Barotrauma.Items.Components
|
||||
itemsWithStatusEffects = new List<Pair<Item, StatusEffect>>();
|
||||
}
|
||||
|
||||
public void OnItemContained(Item item)
|
||||
public void OnItemContained(Item containedItem)
|
||||
{
|
||||
item.SetContainedItemPositions();
|
||||
|
||||
RelatedItem ri = containableItems.Find(x => x.MatchesItem(item));
|
||||
RelatedItem ri = containableItems.Find(x => x.MatchesItem(containedItem));
|
||||
if (ri != null)
|
||||
{
|
||||
foreach (StatusEffect effect in ri.statusEffects)
|
||||
{
|
||||
itemsWithStatusEffects.Add(Pair<Item, StatusEffect>.Create(item, effect));
|
||||
itemsWithStatusEffects.Add(Pair<Item, StatusEffect>.Create(containedItem, effect));
|
||||
}
|
||||
}
|
||||
|
||||
//no need to Update() if this item has no statuseffects and no physics body
|
||||
IsActive = itemsWithStatusEffects.Count > 0 || item.body != null;
|
||||
IsActive = itemsWithStatusEffects.Count > 0 || containedItem.body != null;
|
||||
}
|
||||
|
||||
public void OnItemRemoved(Item item)
|
||||
|
||||
@@ -258,13 +258,7 @@ namespace Barotrauma
|
||||
item.ParentInventory = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DropItem(Item item)
|
||||
{
|
||||
item.Drop(null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
protected virtual void CreateSlots()
|
||||
{
|
||||
slots = new InventorySlot[capacity];
|
||||
@@ -311,7 +305,7 @@ namespace Barotrauma
|
||||
{
|
||||
CreateNetworkEvent();
|
||||
|
||||
DropItem(draggingItem);
|
||||
draggingItem.Drop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1549,6 +1549,9 @@ namespace Barotrauma
|
||||
|
||||
if (Container != null)
|
||||
{
|
||||
if (body != null) body.Enabled = true;
|
||||
SetTransform(Container.SimPosition, 0.0f);
|
||||
|
||||
Container.RemoveContained(this);
|
||||
Container = null;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,6 @@ namespace Barotrauma
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
protected override void DropItem(Item item)
|
||||
{
|
||||
item.Drop();
|
||||
if (item.body != null) item.body.Enabled = true;
|
||||
item.SetTransform(container.Item.SimPosition, 0.0f);
|
||||
}
|
||||
|
||||
public override int FindAllowedSlot(Item item)
|
||||
{
|
||||
for (int i = 0; i < capacity; i++)
|
||||
|
||||
Reference in New Issue
Block a user