Unstable 0.1400.8.0
This commit is contained in:
@@ -132,17 +132,17 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CanBePut(Item item, int i, bool ignoreCondition = false)
|
||||
public override bool CanBePutInSlot(Item item, int i, bool ignoreCondition = false)
|
||||
{
|
||||
return
|
||||
base.CanBePut(item, i, ignoreCondition) && item.AllowedSlots.Any(s => s.HasFlag(SlotTypes[i])) &&
|
||||
base.CanBePutInSlot(item, i, ignoreCondition) && item.AllowedSlots.Any(s => s.HasFlag(SlotTypes[i])) &&
|
||||
(SlotTypes[i] == InvSlotType.Any || slots[i].ItemCount < 1);
|
||||
}
|
||||
|
||||
public override bool CanBePut(ItemPrefab itemPrefab, int i, float? condition)
|
||||
public override bool CanBePutInSlot(ItemPrefab itemPrefab, int i, float? condition)
|
||||
{
|
||||
return
|
||||
base.CanBePut(itemPrefab, i, condition) &&
|
||||
base.CanBePutInSlot(itemPrefab, i, condition) &&
|
||||
(SlotTypes[i] == InvSlotType.Any || slots[i].ItemCount < 1);
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
||||
/// </summary>
|
||||
public override bool TryPutItem(Item item, Character user, IEnumerable<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
|
||||
public override bool TryPutItem(Item item, Character user, IEnumerable<InvSlotType> allowedSlots = null, bool createNetworkEvent = true, bool ignoreCondition = false)
|
||||
{
|
||||
if (allowedSlots == null || !allowedSlots.Any()) { return false; }
|
||||
if (item == null)
|
||||
@@ -326,7 +326,7 @@ namespace Barotrauma
|
||||
#if CLIENT
|
||||
if (PersonalSlots.HasFlag(SlotTypes[i])) { hidePersonalSlots = false; }
|
||||
#endif
|
||||
if (!slots[i].First().AllowedSlots.Contains(InvSlotType.Any) || !TryPutItem(slots[i].FirstOrDefault(), character, new List<InvSlotType> { InvSlotType.Any }, true))
|
||||
if (!slots[i].First().AllowedSlots.Contains(InvSlotType.Any) || !TryPutItem(slots[i].FirstOrDefault(), character, new List<InvSlotType> { InvSlotType.Any }, true, ignoreCondition))
|
||||
{
|
||||
free = false;
|
||||
#if CLIENT
|
||||
@@ -371,7 +371,7 @@ namespace Barotrauma
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (SlotTypes[i] != InvSlotType.Any) { continue; }
|
||||
if (!slots[i].Empty() && CanBePut(item, i))
|
||||
if (!slots[i].Empty() && CanBePutInSlot(item, i))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
@@ -387,7 +387,7 @@ namespace Barotrauma
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (SlotTypes[i] != InvSlotType.Any) { continue; }
|
||||
if (CanBePut(item, i))
|
||||
if (CanBePutInSlot(item, i))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
@@ -402,14 +402,14 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CanBePut(item, i)) { continue; }
|
||||
if (!CanBePutInSlot(item, i)) { continue; }
|
||||
}
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override bool TryPutItem(Item item, int index, bool allowSwapping, bool allowCombine, Character user, bool createNetworkEvent = true)
|
||||
public override bool TryPutItem(Item item, int index, bool allowSwapping, bool allowCombine, Character user, bool createNetworkEvent = true, bool ignoreCondition = false)
|
||||
{
|
||||
if (index < 0 || index >= slots.Length)
|
||||
{
|
||||
@@ -424,7 +424,7 @@ namespace Barotrauma
|
||||
if (slots[index].Any())
|
||||
{
|
||||
if (slots[index].Contains(item)) { return false; }
|
||||
return base.TryPutItem(item, index, allowSwapping, allowCombine, user, createNetworkEvent);
|
||||
return base.TryPutItem(item, index, allowSwapping, allowCombine, user, createNetworkEvent, ignoreCondition);
|
||||
}
|
||||
|
||||
if (SlotTypes[index] == InvSlotType.Any)
|
||||
@@ -460,7 +460,7 @@ namespace Barotrauma
|
||||
|
||||
if (!slotsFree) { return false; }
|
||||
|
||||
return TryPutItem(item, user, new List<InvSlotType>() { placeToSlots }, createNetworkEvent);
|
||||
return TryPutItem(item, user, new List<InvSlotType>() { placeToSlots }, createNetworkEvent, ignoreCondition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ namespace Barotrauma.Items.Components
|
||||
allowInsideFixture: true);
|
||||
|
||||
hitBodies.Clear();
|
||||
hitBodies.AddRange(bodies);
|
||||
hitBodies.AddRange(bodies.Distinct());
|
||||
|
||||
lastPickedFraction = Submarine.LastPickedFraction;
|
||||
Type lastHitType = null;
|
||||
|
||||
@@ -483,7 +483,7 @@ namespace Barotrauma.Items.Components
|
||||
foreach (ushort id in itemIds[i])
|
||||
{
|
||||
if (!(Entity.FindEntityByID(id) is Item item)) { continue; }
|
||||
Inventory.TryPutItem(item, i, false, false, null, false);
|
||||
Inventory.TryPutItem(item, i, false, false, null, createNetworkEvent: false, ignoreCondition: true);
|
||||
}
|
||||
}
|
||||
itemIds = null;
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
for (int i = inputContainer.Inventory.Capacity - 2; i >= 0; i--)
|
||||
{
|
||||
while (inputContainer.Inventory.GetItemAt(i) is Item item1 && inputContainer.Inventory.CanBePut(item1, i + 1))
|
||||
while (inputContainer.Inventory.GetItemAt(i) is Item item1 && inputContainer.Inventory.CanBePutInSlot(item1, i + 1))
|
||||
{
|
||||
if (!inputContainer.Inventory.TryPutItem(item1, i + 1, allowSwapping: false, allowCombine: false, user: null, createNetworkEvent: true))
|
||||
{
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Barotrauma.Items.Components
|
||||
private void StartFabricating(FabricationRecipe selectedItem, Character user, bool addToServerLog = true)
|
||||
{
|
||||
if (selectedItem == null) { return; }
|
||||
if (!outputContainer.Inventory.CanBePut(selectedItem.TargetItem, selectedItem.OutCondition)) { return; }
|
||||
if (!outputContainer.Inventory.CanBePut(selectedItem.TargetItem, selectedItem.OutCondition * selectedItem.TargetItem.Health)) { return; }
|
||||
|
||||
#if CLIENT
|
||||
itemList.Enabled = false;
|
||||
@@ -308,7 +308,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
Character tempUser = user;
|
||||
int amountFittingContainer = outputContainer.Inventory.HowManyCanBePut(fabricatedItem.TargetItem, fabricatedItem.OutCondition);
|
||||
int amountFittingContainer = outputContainer.Inventory.HowManyCanBePut(fabricatedItem.TargetItem, fabricatedItem.OutCondition * fabricatedItem.TargetItem.Health);
|
||||
for (int i = 0; i < fabricatedItem.Amount; i++)
|
||||
{
|
||||
if (i < amountFittingContainer)
|
||||
|
||||
@@ -380,7 +380,7 @@ namespace Barotrauma
|
||||
return ownerItem.ParentInventory.ItemOwnsSelf(item);
|
||||
}
|
||||
|
||||
public virtual int FindAllowedSlot(Item item)
|
||||
public virtual int FindAllowedSlot(Item item, bool ignoreCondition = false)
|
||||
{
|
||||
if (ItemOwnsSelf(item)) { return -1; }
|
||||
|
||||
@@ -392,7 +392,7 @@ namespace Barotrauma
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (slots[i].CanBePut(item)) { return i; }
|
||||
if (slots[i].CanBePut(item, ignoreCondition)) { return i; }
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -405,7 +405,7 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (CanBePut(item, i)) { return true; }
|
||||
if (CanBePutInSlot(item, i)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -413,7 +413,7 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// Can the item be put in the specified slot.
|
||||
/// </summary>
|
||||
public virtual bool CanBePut(Item item, int i, bool ignoreCondition = false)
|
||||
public virtual bool CanBePutInSlot(Item item, int i, bool ignoreCondition = false)
|
||||
{
|
||||
if (ItemOwnsSelf(item)) { return false; }
|
||||
if (i < 0 || i >= slots.Length) { return false; }
|
||||
@@ -424,12 +424,12 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (CanBePut(itemPrefab, i, condition)) { return true; }
|
||||
if (CanBePutInSlot(itemPrefab, i, condition)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool CanBePut(ItemPrefab itemPrefab, int i, float? condition = null)
|
||||
public virtual bool CanBePutInSlot(ItemPrefab itemPrefab, int i, float? condition = null)
|
||||
{
|
||||
if (i < 0 || i >= slots.Length) { return false; }
|
||||
return slots[i].CanBePut(itemPrefab, condition);
|
||||
@@ -454,16 +454,16 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
||||
/// </summary>
|
||||
public virtual bool TryPutItem(Item item, Character user, IEnumerable<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
|
||||
public virtual bool TryPutItem(Item item, Character user, IEnumerable<InvSlotType> allowedSlots = null, bool createNetworkEvent = true, bool ignoreCondition = false)
|
||||
{
|
||||
int slot = FindAllowedSlot(item);
|
||||
int slot = FindAllowedSlot(item, ignoreCondition);
|
||||
if (slot < 0) { return false; }
|
||||
|
||||
PutItem(item, slot, user, true, createNetworkEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool TryPutItem(Item item, int i, bool allowSwapping, bool allowCombine, Character user, bool createNetworkEvent = true)
|
||||
public virtual bool TryPutItem(Item item, int i, bool allowSwapping, bool allowCombine, Character user, bool createNetworkEvent = true, bool ignoreCondition = false)
|
||||
{
|
||||
if (i < 0 || i >= slots.Length)
|
||||
{
|
||||
@@ -481,12 +481,12 @@ namespace Barotrauma
|
||||
//item in the slot removed as a result of combining -> put this item in the now free slot
|
||||
if (!slots[i].Any())
|
||||
{
|
||||
return TryPutItem(item, i, allowSwapping, allowCombine, user, createNetworkEvent);
|
||||
return TryPutItem(item, i, allowSwapping, allowCombine, user, createNetworkEvent, ignoreCondition);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (CanBePut(item, i))
|
||||
if (CanBePutInSlot(item, i, ignoreCondition))
|
||||
{
|
||||
PutItem(item, i, user, true, createNetworkEvent);
|
||||
return true;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Barotrauma
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public override int FindAllowedSlot(Item item)
|
||||
public override int FindAllowedSlot(Item item, bool ignoreCondition = false)
|
||||
{
|
||||
if (ItemOwnsSelf(item)) { return -1; }
|
||||
|
||||
@@ -32,18 +32,18 @@ namespace Barotrauma
|
||||
//try to stack first
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (slots[i].Any() && CanBePut(item, i)) { return i; }
|
||||
if (slots[i].Any() && CanBePutInSlot(item, i, ignoreCondition)) { return i; }
|
||||
}
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (CanBePut(item, i)) { return i; }
|
||||
if (CanBePutInSlot(item, i, ignoreCondition)) { return i; }
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override bool CanBePut(Item item, int i, bool ignoreCondition = false)
|
||||
public override bool CanBePutInSlot(Item item, int i, bool ignoreCondition = false)
|
||||
{
|
||||
if (ItemOwnsSelf(item)) { return false; }
|
||||
if (i < 0 || i >= slots.Length) { return false; }
|
||||
@@ -51,7 +51,7 @@ namespace Barotrauma
|
||||
return item != null && slots[i].CanBePut(item, ignoreCondition) && slots[i].ItemCount < container.MaxStackSize;
|
||||
}
|
||||
|
||||
public override bool CanBePut(ItemPrefab itemPrefab, int i, float? condition)
|
||||
public override bool CanBePutInSlot(ItemPrefab itemPrefab, int i, float? condition)
|
||||
{
|
||||
if (i < 0 || i >= slots.Length) { return false; }
|
||||
if (!container.CanBeContained(itemPrefab)) { return false; }
|
||||
@@ -88,9 +88,9 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool TryPutItem(Item item, Character user, IEnumerable<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
|
||||
public override bool TryPutItem(Item item, Character user, IEnumerable<InvSlotType> allowedSlots = null, bool createNetworkEvent = true, bool ignoreCondition = false)
|
||||
{
|
||||
bool wasPut = base.TryPutItem(item, user, allowedSlots, createNetworkEvent);
|
||||
bool wasPut = base.TryPutItem(item, user, allowedSlots, createNetworkEvent, ignoreCondition);
|
||||
|
||||
if (wasPut)
|
||||
{
|
||||
@@ -108,9 +108,9 @@ namespace Barotrauma
|
||||
return wasPut;
|
||||
}
|
||||
|
||||
public override bool TryPutItem(Item item, int i, bool allowSwapping, bool allowCombine, Character user, bool createNetworkEvent = true)
|
||||
public override bool TryPutItem(Item item, int i, bool allowSwapping, bool allowCombine, Character user, bool createNetworkEvent = true, bool ignoreCondition = false)
|
||||
{
|
||||
bool wasPut = base.TryPutItem(item, i, allowSwapping, allowCombine, user, createNetworkEvent);
|
||||
bool wasPut = base.TryPutItem(item, i, allowSwapping, allowCombine, user, createNetworkEvent, ignoreCondition);
|
||||
if (wasPut && item.ParentInventory == this)
|
||||
{
|
||||
foreach (Character c in Character.CharacterList)
|
||||
|
||||
Reference in New Issue
Block a user