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