Human AI improvements, minor UI tweaking
This commit is contained in:
@@ -81,7 +81,7 @@ namespace Barotrauma
|
||||
|
||||
public int FindLimbSlot(LimbSlot limbSlot)
|
||||
{
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
for (int i = 0; i < Items.Length; i++)
|
||||
{
|
||||
if ( limbSlots[i] == limbSlot) return i;
|
||||
}
|
||||
@@ -90,9 +90,9 @@ namespace Barotrauma
|
||||
|
||||
public bool IsInLimbSlot(Item item, LimbSlot limbSlot)
|
||||
{
|
||||
for (int i = 0; i<items.Length; i++)
|
||||
for (int i = 0; i<Items.Length; i++)
|
||||
{
|
||||
if (items[i] == item && limbSlots[i] == limbSlot) return true;
|
||||
if (Items[i] == item && limbSlots[i] == limbSlot) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (items[i] != null || limbSlots[i] != LimbSlot.Any) continue;
|
||||
if (Items[i] != null || limbSlots[i] != LimbSlot.Any) continue;
|
||||
PutItem(item, i, createNetworkEvent);
|
||||
item.Unequip(character);
|
||||
return true;
|
||||
@@ -127,7 +127,7 @@ namespace Barotrauma
|
||||
bool free = true;
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (allowedSlot.HasFlag(limbSlots[i]) && items[i]!=null && items[i]!=item)
|
||||
if (allowedSlot.HasFlag(limbSlots[i]) && Items[i]!=null && Items[i]!=item)
|
||||
{
|
||||
free = false;
|
||||
break;
|
||||
@@ -138,7 +138,7 @@ namespace Barotrauma
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (allowedSlot.HasFlag(limbSlots[i]) && items[i] == null)
|
||||
if (allowedSlot.HasFlag(limbSlots[i]) && Items[i] == null)
|
||||
{
|
||||
PutItem(item, i, createNetworkEvent, !placed);
|
||||
item.Equip(character);
|
||||
@@ -159,9 +159,9 @@ namespace Barotrauma
|
||||
public override bool TryPutItem(Item item, int index, bool createNetworkEvent)
|
||||
{
|
||||
//there's already an item in the slot
|
||||
if (items[index] != null)
|
||||
if (Items[index] != null)
|
||||
{
|
||||
if (items[index] == item) return false;
|
||||
if (Items[index] == item) return false;
|
||||
|
||||
bool combined = false;
|
||||
//if (item.Combine(items[i]))
|
||||
@@ -170,15 +170,15 @@ namespace Barotrauma
|
||||
// combined = true;
|
||||
//}
|
||||
//else
|
||||
if (items[index].Combine(item))
|
||||
if (Items[index].Combine(item))
|
||||
{
|
||||
//PutItem(items[i], i, false, false);
|
||||
if (items[index]==null)
|
||||
if (Items[index]==null)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(false);
|
||||
return false;
|
||||
}
|
||||
Inventory otherInventory = items[index].inventory;
|
||||
Inventory otherInventory = Items[index].inventory;
|
||||
if (otherInventory != null && createNetworkEvent)
|
||||
{
|
||||
new Networking.NetworkEvent(Networking.NetworkEventType.InventoryUpdate, otherInventory.Owner.ID, true, true);
|
||||
@@ -193,7 +193,7 @@ namespace Barotrauma
|
||||
if (limbSlots[index] == LimbSlot.Any)
|
||||
{
|
||||
if (!item.AllowedSlots.Contains(LimbSlot.Any)) return false;
|
||||
if (items[index] != null) return items[index] == item;
|
||||
if (Items[index] != null) return Items[index] == item;
|
||||
|
||||
PutItem(item, index, createNetworkEvent, true);
|
||||
return true;
|
||||
@@ -209,7 +209,7 @@ namespace Barotrauma
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (allowedSlot.HasFlag(limbSlots[i]) && items[i] != null && items[i] != item)
|
||||
if (allowedSlot.HasFlag(limbSlots[i]) && Items[i] != null && Items[i] != item)
|
||||
{
|
||||
slotsFree = false;
|
||||
break;
|
||||
@@ -381,11 +381,11 @@ namespace Barotrauma
|
||||
|
||||
bool multiSlot = false;
|
||||
//skip if the item is in multiple slots
|
||||
if (items[i]!=null)
|
||||
if (Items[i]!=null)
|
||||
{
|
||||
for (int n = 0; n < capacity; n++ )
|
||||
{
|
||||
if (i==n || items[n] != items[i]) continue;
|
||||
if (i==n || Items[n] != Items[i]) continue;
|
||||
multiSlot = true;
|
||||
break;
|
||||
}
|
||||
@@ -393,9 +393,9 @@ namespace Barotrauma
|
||||
|
||||
if (multiSlot) continue;
|
||||
|
||||
UpdateSlot(spriteBatch, slotRect, i, items[i], i > 4);
|
||||
UpdateSlot(spriteBatch, slotRect, i, Items[i], i > 4);
|
||||
|
||||
if (draggingItem!=null && draggingItem == items[i]) draggingItemSlot = slotRect;
|
||||
if (draggingItem!=null && draggingItem == Items[i]) draggingItemSlot = slotRect;
|
||||
}
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ namespace Barotrauma
|
||||
bool multiSlot = false;
|
||||
|
||||
//check if the item is in multiple slots
|
||||
if (items[i] != null)
|
||||
if (Items[i] != null)
|
||||
{
|
||||
slotRect.X = (int)slotPositions[i].X;
|
||||
slotRect.Y = (int)slotPositions[i].Y;
|
||||
@@ -415,7 +415,7 @@ namespace Barotrauma
|
||||
|
||||
for (int n = 0; n < capacity; n++)
|
||||
{
|
||||
if (items[n] != items[i]) continue;
|
||||
if (Items[n] != Items[i]) continue;
|
||||
|
||||
if (!multiSlot && i > n) break;
|
||||
|
||||
@@ -430,7 +430,7 @@ namespace Barotrauma
|
||||
|
||||
if (!multiSlot) continue;
|
||||
|
||||
UpdateSlot(spriteBatch, slotRect, i, items[i], i > 4);
|
||||
UpdateSlot(spriteBatch, slotRect, i, Items[i], i > 4);
|
||||
|
||||
//if (multiSlot && i == first)
|
||||
//{
|
||||
@@ -469,7 +469,7 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
message.Write(items[i]==null ? (ushort)0 : (ushort)items[i].ID);
|
||||
message.Write(Items[i]==null ? (ushort)0 : (ushort)Items[i].ID);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -486,14 +486,14 @@ namespace Barotrauma
|
||||
ushort itemId = message.ReadUInt16();
|
||||
if (itemId==0)
|
||||
{
|
||||
if (items[i] != null) items[i].Drop(character, false);
|
||||
if (Items[i] != null) Items[i].Drop(character, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Item item = Entity.FindEntityByID(itemId) as Item;
|
||||
if (item == null) continue;
|
||||
|
||||
if (items[i] != item && items[i] != null) items[i].Drop(character, false);
|
||||
if (Items[i] != item && Items[i] != null) Items[i].Drop(character, false);
|
||||
TryPutItem(item, i, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using FarseerPhysics.Factories;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Barotrauma.Lights;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -41,8 +42,7 @@ namespace Barotrauma.Items.Components
|
||||
if (linkedGap != null) return linkedGap;
|
||||
foreach (MapEntity e in item.linkedTo)
|
||||
{
|
||||
linkedGap = e as Gap;
|
||||
linkedGap.ConnectedDoor = this;
|
||||
linkedGap = e as Gap;
|
||||
if (linkedGap != null) return linkedGap;
|
||||
}
|
||||
linkedGap = new Gap(item.Rect);
|
||||
@@ -256,6 +256,30 @@ namespace Barotrauma.Items.Components
|
||||
linkedGap.Open = 1.0f;
|
||||
}
|
||||
|
||||
public List<Controller> GetButtons()
|
||||
{
|
||||
ConnectionPanel connectionPanel = Item.GetComponent<ConnectionPanel>();
|
||||
if (connectionPanel == null) return new List<Controller>();
|
||||
|
||||
List<Controller> buttons = new List<Controller>();
|
||||
|
||||
foreach (Connection c in connectionPanel.Connections)
|
||||
{
|
||||
foreach (Wire w in c.Wires)
|
||||
{
|
||||
if (w == null) continue;
|
||||
var otherConnection = w.OtherConnection(c);
|
||||
|
||||
if (otherConnection.Item == Item || otherConnection == null) continue;
|
||||
|
||||
var controller = otherConnection.Item.GetComponent<Controller>();
|
||||
if (controller != null) buttons.Add(controller);
|
||||
}
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
{
|
||||
Color color = (item.IsSelected) ? Color.Green : Color.White;
|
||||
@@ -272,38 +296,43 @@ namespace Barotrauma.Items.Components
|
||||
if (openState == 1.0f)
|
||||
{
|
||||
body.Enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
spriteBatch.Draw(doorSprite.Texture, new Vector2(item.Rect.Center.X, -item.Rect.Y),
|
||||
new Rectangle(doorSprite.SourceRect.X, (int)(doorSprite.size.Y * openState),
|
||||
(int)doorSprite.size.X, (int)(doorSprite.size.Y * (1.0f - openState))),
|
||||
color, 0.0f, doorSprite.Origin, 1.0f, SpriteEffects.None, doorSprite.Depth);
|
||||
|
||||
if (openState == 0.0f)
|
||||
{
|
||||
body.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
spriteBatch.Draw(doorSprite.Texture, new Vector2(item.Rect.Center.X, -item.Rect.Y),
|
||||
new Rectangle(doorSprite.SourceRect.X, (int)(doorSprite.size.Y * openState),
|
||||
(int)doorSprite.size.X, (int)(doorSprite.size.Y * (1.0f - openState))),
|
||||
color, 0.0f, doorSprite.Origin, 1.0f, SpriteEffects.None, doorSprite.Depth);
|
||||
//push characters out of the doorway when the door is closing/opening
|
||||
Vector2 simPos = ConvertUnits.ToSimUnits(new Vector2(item.Rect.X, item.Rect.Y));
|
||||
Vector2 simSize = ConvertUnits.ToSimUnits(new Vector2(item.Rect.Width,
|
||||
item.Rect.Height * (1.0f - openState)));
|
||||
|
||||
if (openState == 0.0f)
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
body.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//push characters out of the doorway when the door is closing/opening
|
||||
Vector2 simPos = ConvertUnits.ToSimUnits(new Vector2(item.Rect.X, item.Rect.Y));
|
||||
Vector2 simSize = ConvertUnits.ToSimUnits(new Vector2(item.Rect.Width,
|
||||
item.Rect.Height * (1.0f - openState)));
|
||||
|
||||
foreach (Character c in Character.CharacterList)
|
||||
int dir = Math.Sign(c.AnimController.Limbs[0].SimPosition.X - simPos.X);
|
||||
foreach (Limb l in c.AnimController.Limbs)
|
||||
{
|
||||
int dir = Math.Sign(c.AnimController.Limbs[0].SimPosition.X - simPos.X);
|
||||
foreach (Limb l in c.AnimController.Limbs)
|
||||
{
|
||||
if (l.SimPosition.Y < simPos.Y || l.SimPosition.Y > simPos.Y - simSize.Y) continue;
|
||||
if (Math.Abs(l.SimPosition.X - simPos.X) > simSize.X * 2.0f) continue;
|
||||
if (l.SimPosition.Y < simPos.Y || l.SimPosition.Y > simPos.Y - simSize.Y) continue;
|
||||
if (Math.Abs(l.SimPosition.X - simPos.X) > simSize.X * 2.0f) continue;
|
||||
|
||||
l.body.ApplyForce(new Vector2(dir * 10.0f, 0.0f));
|
||||
}
|
||||
l.body.ApplyForce(new Vector2(dir * 10.0f, 0.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void OnMapLoaded()
|
||||
{
|
||||
LinkedGap.ConnectedDoor = this;
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
|
||||
@@ -551,7 +551,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
if (!hasItem && ri.Type.HasFlag(RelatedItem.RelationType.Picked))
|
||||
{
|
||||
if (character.Inventory.items.FirstOrDefault(x => x!=null && x.Condition>0.0f && ri.MatchesItem(x))!=null) hasItem = true;
|
||||
if (character.Inventory.Items.FirstOrDefault(x => x!=null && x.Condition>0.0f && ri.MatchesItem(x))!=null) hasItem = true;
|
||||
}
|
||||
if (!hasItem)
|
||||
{
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (!hasStatusEffects) return;
|
||||
|
||||
foreach (Item contained in inventory.items)
|
||||
foreach (Item contained in inventory.Items)
|
||||
{
|
||||
if (contained == null || contained.Condition <= 0.0f) continue;
|
||||
//if (contained.body != null) contained.body.Enabled = false;
|
||||
@@ -179,7 +179,7 @@ namespace Barotrauma.Items.Components
|
||||
currentRotation += item.body.Rotation;
|
||||
}
|
||||
|
||||
foreach (Item containedItem in inventory.items)
|
||||
foreach (Item containedItem in inventory.Items)
|
||||
{
|
||||
if (containedItem == null) continue;
|
||||
|
||||
@@ -243,7 +243,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
base.Remove();
|
||||
|
||||
foreach (Item item in inventory.items)
|
||||
foreach (Item item in inventory.Items)
|
||||
{
|
||||
if (item == null) continue;
|
||||
item.Remove();
|
||||
@@ -274,10 +274,10 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
XElement componentElement = base.Save(parentElement);
|
||||
|
||||
string[] itemIdStrings = new string[inventory.items.Length];
|
||||
for (int i = 0; i < inventory.items.Length; i++)
|
||||
string[] itemIdStrings = new string[inventory.Items.Length];
|
||||
for (int i = 0; i < inventory.Items.Length; i++)
|
||||
{
|
||||
itemIdStrings[i] = (inventory.items[i]==null) ? "0" : inventory.items[i].ID.ToString();
|
||||
itemIdStrings[i] = (inventory.Items[i]==null) ? "0" : inventory.Items[i].ID.ToString();
|
||||
}
|
||||
|
||||
componentElement.Add(new XAttribute("contained", string.Join(",",itemIdStrings)));
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Barotrauma.Items.Components
|
||||
ItemContainer container = item.GetComponent<ItemContainer>();
|
||||
foreach (ItemPrefab ip in fabricatedItem.RequiredItems)
|
||||
{
|
||||
var requiredItem = Array.Find(container.inventory.items, it => it != null && it.Prefab == ip);
|
||||
var requiredItem = container.inventory.Items.FirstOrDefault(it => it != null && it.Prefab == ip);
|
||||
container.inventory.RemoveItem(requiredItem);
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace Barotrauma.Items.Components
|
||||
ItemContainer container = item.GetComponent<ItemContainer>();
|
||||
foreach (ItemPrefab ip in targetItem.RequiredItems)
|
||||
{
|
||||
if (Array.Find(container.inventory.items, it => it != null && it.Prefab == ip) != null) continue;
|
||||
if (Array.Find(container.inventory.Items, it => it != null && it.Prefab == ip) != null) continue;
|
||||
selectedItemFrame.GetChild<GUIButton>().Enabled = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -139,12 +139,12 @@ namespace Barotrauma.Items.Components
|
||||
ItemContainer containerComponent = projectileContainer.GetComponent<ItemContainer>();
|
||||
if (containerComponent == null) continue;
|
||||
|
||||
for (int i = 0; i < containerComponent.inventory.items.Length; i++)
|
||||
for (int i = 0; i < containerComponent.inventory.Items.Length; i++)
|
||||
{
|
||||
if (containerComponent.inventory.items[i] == null) continue;
|
||||
if ((projectileComponent = containerComponent.inventory.items[i].GetComponent<Projectile>()) != null)
|
||||
if (containerComponent.inventory.Items[i] == null) continue;
|
||||
if ((projectileComponent = containerComponent.inventory.Items[i].GetComponent<Projectile>()) != null)
|
||||
{
|
||||
projectile = containerComponent.inventory.items[i];
|
||||
projectile = containerComponent.inventory.Items[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Barotrauma
|
||||
GUIComponent component = reqFrame.children.Find(c => c.UserData as string == itemName);
|
||||
|
||||
GUITextBlock text = component as GUITextBlock;
|
||||
Item item = character.Inventory.items.FirstOrDefault(i => i !=null && (i.Name == itemName || i.HasTag(itemName)));
|
||||
Item item = character.Inventory.FindItem(itemName);
|
||||
bool itemFound = (item != null);
|
||||
|
||||
if (!itemFound) success = false;
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Barotrauma
|
||||
|
||||
protected int selectedSlot;
|
||||
|
||||
public Item[] items;
|
||||
public Item[] Items;
|
||||
|
||||
public Inventory(Entity owner, int capacity, Vector2? centerPos = null, int slotsPerRow=5)
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace Barotrauma
|
||||
|
||||
this.slotsPerRow = slotsPerRow;
|
||||
|
||||
items = new Item[capacity];
|
||||
Items = new Item[capacity];
|
||||
|
||||
CenterPos = (centerPos==null) ? new Vector2(0.5f, 0.5f) : (Vector2)centerPos;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (items[i] == item) return i;
|
||||
if (Items[i] == item) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -71,12 +71,12 @@ namespace Barotrauma
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
//item is already in the inventory!
|
||||
if (items[i] == item) return -1;
|
||||
if (Items[i] == item) return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (items[i] == null) return i;
|
||||
if (Items[i] == null) return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -84,8 +84,8 @@ namespace Barotrauma
|
||||
|
||||
public virtual bool CanBePut(Item item, int i)
|
||||
{
|
||||
if (i < 0 || i >= items.Length) return false;
|
||||
return (items[i] == null);
|
||||
if (i < 0 || i >= Items.Length) return false;
|
||||
return (Items[i] == null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -124,7 +124,7 @@ namespace Barotrauma
|
||||
if (item.inventory != null) item.inventory.RemoveItem(item);
|
||||
}
|
||||
|
||||
items[i] = item;
|
||||
Items[i] = item;
|
||||
item.inventory = this;
|
||||
if (item.body != null)
|
||||
{
|
||||
@@ -134,13 +134,18 @@ namespace Barotrauma
|
||||
if (createNetworkEvent) new NetworkEvent(NetworkEventType.InventoryUpdate, Owner.ID, true, true);
|
||||
}
|
||||
|
||||
public Item FindItem(string itemName)
|
||||
{
|
||||
return Items.FirstOrDefault(i => i != null && (i.Name == itemName || i.HasTag(itemName)));
|
||||
}
|
||||
|
||||
public void RemoveItem(Item item)
|
||||
{
|
||||
//go through the inventory and remove the item from all slots
|
||||
for (int n = 0; n < capacity; n++)
|
||||
{
|
||||
if (items[n] != item) continue;
|
||||
items[n] = null;
|
||||
if (Items[n] != item) continue;
|
||||
Items[n] = null;
|
||||
item.inventory = null;
|
||||
}
|
||||
}
|
||||
@@ -177,9 +182,9 @@ namespace Barotrauma
|
||||
slotRect.X = startX + (rectWidth + spacing) * (i % slotsPerRow);
|
||||
slotRect.Y = startY + (rectHeight + spacing) * ((int)Math.Floor((double)i / slotsPerRow));
|
||||
|
||||
if (draggingItem == items[i]) draggingItemSlot = slotRect;
|
||||
if (draggingItem == Items[i]) draggingItemSlot = slotRect;
|
||||
|
||||
UpdateSlot(spriteBatch, slotRect, i, items[i], false);
|
||||
UpdateSlot(spriteBatch, slotRect, i, Items[i], false);
|
||||
}
|
||||
|
||||
if (draggingItem != null && !draggingItemSlot.Contains(PlayerInput.MousePosition) && draggingItem.container == this.Owner)
|
||||
@@ -247,7 +252,7 @@ namespace Barotrauma
|
||||
{
|
||||
|
||||
#if DEBUG
|
||||
System.Diagnostics.Debug.Assert(slotIndex >= 0 && slotIndex < items.Length);
|
||||
System.Diagnostics.Debug.Assert(slotIndex >= 0 && slotIndex < Items.Length);
|
||||
#else
|
||||
if (slotIndex<0 || slotIndex>=items.Length) return;
|
||||
#endif
|
||||
@@ -266,7 +271,7 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(spriteBatch, containerRect, Color.White);
|
||||
|
||||
Item[] containedItems = null;
|
||||
if (items[slotIndex] != null) containedItems = items[slotIndex].ContainedItems;
|
||||
if (Items[slotIndex] != null) containedItems = Items[slotIndex].ContainedItems;
|
||||
|
||||
if (containedItems != null)
|
||||
{
|
||||
@@ -316,7 +321,7 @@ namespace Barotrauma
|
||||
|
||||
public virtual bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
|
||||
{
|
||||
var foundItems = Array.FindAll(items, i => i != null);
|
||||
var foundItems = Array.FindAll(Items, i => i != null);
|
||||
message.Write((byte)foundItems.Count());
|
||||
foreach (Item item in foundItems)
|
||||
{
|
||||
@@ -340,10 +345,10 @@ namespace Barotrauma
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (items[i] == null) continue;
|
||||
if (!newItemIDs.Contains(items[i].ID))
|
||||
if (Items[i] == null) continue;
|
||||
if (!newItemIDs.Contains(Items[i].ID))
|
||||
{
|
||||
items[i].Drop(null, false);
|
||||
Items[i].Drop(null, false);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace Barotrauma
|
||||
get
|
||||
{
|
||||
ItemContainer c = GetComponent<ItemContainer>();
|
||||
return (c == null) ? null : Array.FindAll(c.inventory.items, i=>i!=null);
|
||||
return (c == null) ? null : Array.FindAll(c.inventory.Items, i=>i!=null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ namespace Barotrauma
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
//item is already in the inventory!
|
||||
if (items[i] == item) return -1;
|
||||
if (Items[i] == item) return -1;
|
||||
}
|
||||
|
||||
if (!container.CanBeContained(item)) return -1;
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (items[i] == null) return i;
|
||||
if (Items[i] == null) return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -40,8 +40,8 @@ namespace Barotrauma
|
||||
|
||||
public override bool CanBePut(Item item, int i)
|
||||
{
|
||||
if (i < 0 || i >= items.Length) return false;
|
||||
return (item!=null && items[i]==null && container.CanBeContained(item));
|
||||
if (i < 0 || i >= Items.Length) return false;
|
||||
return (item!=null && Items[i]==null && container.CanBeContained(item));
|
||||
}
|
||||
|
||||
public override bool TryPutItem(Item item, int i, bool createNetworkEvent)
|
||||
|
||||
@@ -161,8 +161,8 @@ namespace Barotrauma
|
||||
name = ToolBox.GetAttributeString(element, "name", "");
|
||||
if (name == "") DebugConsole.ThrowError("Unnamed item in "+filePath+"!");
|
||||
|
||||
pickThroughWalls = ToolBox.GetAttributeBool(element, "pickthroughwalls", false);
|
||||
pickDistance = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "pickdistance", 0.0f));
|
||||
pickThroughWalls = ToolBox.GetAttributeBool(element, "pickthroughwalls", false);
|
||||
pickDistance = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "pickdistance", 0.0f));
|
||||
|
||||
isLinkable = ToolBox.GetAttributeBool(element, "linkable", false);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Barotrauma
|
||||
break;
|
||||
case RelationType.Picked:
|
||||
if (character == null || character.Inventory==null) return false;
|
||||
foreach (Item pickedItem in character.Inventory.items)
|
||||
foreach (Item pickedItem in character.Inventory.Items)
|
||||
{
|
||||
if (pickedItem == null) continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user