From 12dc494e422bd5a16318f429328c530189ffc0a8 Mon Sep 17 00:00:00 2001 From: Regalis Date: Thu, 21 Apr 2016 17:17:32 +0300 Subject: [PATCH] Displaying the condition of contained items in the inventory slot of the parent item (i.e. the amount of oxygen left in a diving suit is visible without highlighting the suit), some debug logging, colored speech bubbles --- .../AI/Objectives/AIObjectiveGetItem.cs | 8 ++--- Subsurface/Source/Characters/Character.cs | 26 ++++++++++---- Subsurface/Source/Characters/CharacterHUD.cs | 2 +- Subsurface/Source/Characters/Jobs/Job.cs | 5 ++- Subsurface/Source/DebugConsole.cs | 12 +++++++ Subsurface/Source/GameMain.cs | 7 ++-- .../GameModes/Tutorials/TutorialType.cs | 5 +++ Subsurface/Source/GameSettings.cs | 8 ++++- Subsurface/Source/Items/CharacterInventory.cs | 34 +++++++++---------- .../Items/Components/Holdable/Pickable.cs | 12 +++---- Subsurface/Source/Items/Inventory.cs | 30 +++++++++++----- Subsurface/Source/Items/Item.cs | 4 +-- Subsurface/Source/Items/ItemPrefab.cs | 11 +++--- Subsurface/Source/Networking/NetworkMember.cs | 8 +++-- Subsurface/Source/Screens/EditMapScreen.cs | 4 +-- 15 files changed, 114 insertions(+), 62 deletions(-) diff --git a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs index 46959fd9d..2a9b649c1 100644 --- a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs +++ b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs @@ -65,9 +65,9 @@ namespace Barotrauma { var pickable = targetItem.GetComponent(); //check if all the slots required by the item are free - foreach (LimbSlot slots in pickable.AllowedSlots) + foreach (InvSlotType slots in pickable.AllowedSlots) { - if (slots.HasFlag(LimbSlot.Any)) continue; + if (slots.HasFlag(InvSlotType.Any)) continue; for (int i = 0; i() { LimbSlot.Any }, false)) continue; + if (character.Inventory.TryPutItem(character.Inventory.Items[i], new List() { InvSlotType.Any }, false)) continue; //if everything else fails, simply drop the existing item character.Inventory.Items[i].Drop(); @@ -90,7 +90,7 @@ namespace Barotrauma targetItem.Pick(character, false, true); - if (targetSlot > -1 && character.Inventory.IsInLimbSlot(targetItem, LimbSlot.Any)) + if (targetSlot > -1 && character.Inventory.IsInLimbSlot(targetItem, InvSlotType.Any)) { character.Inventory.TryPutItem(targetItem, targetSlot, true, false); } diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 1b60e6bf6..e948afa6d 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -156,7 +156,8 @@ namespace Barotrauma get { return inventory; } } - public float SpeechBubbleTimer; + private Color speechBubbleColor; + private float speechBubbleTimer; private float lockHandsTimer; public bool LockHands @@ -694,6 +695,11 @@ namespace Barotrauma } } + public bool HasEquippedItem(Item item) + { + return !inventory.IsInLimbSlot(item, InvSlotType.Any); + } + public bool HasSelectedItem(Item item) { return selectedItems.Contains(item); @@ -701,8 +707,8 @@ namespace Barotrauma public bool TrySelectItem(Item item) { - bool rightHand = ((CharacterInventory)inventory).IsInLimbSlot(item, LimbSlot.RightHand); - bool leftHand = ((CharacterInventory)inventory).IsInLimbSlot(item, LimbSlot.LeftHand); + bool rightHand = inventory.IsInLimbSlot(item, InvSlotType.RightHand); + bool leftHand = inventory.IsInLimbSlot(item, InvSlotType.LeftHand); bool selected = false; if (rightHand && SelectedItems[0] == null) @@ -956,7 +962,7 @@ namespace Barotrauma { if (!Enabled) return; - SpeechBubbleTimer = Math.Max(0.0f, SpeechBubbleTimer - deltaTime); + speechBubbleTimer = Math.Max(0.0f, speechBubbleTimer - deltaTime); obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f); @@ -1086,6 +1092,12 @@ namespace Barotrauma aiTarget.SightRange = Mass*10.0f + AnimController.RefLimb.LinearVelocity.Length()*500.0f; } + public void ShowSpeechBubble(float duration, Color color) + { + speechBubbleTimer = Math.Max(speechBubbleTimer, duration); + speechBubbleColor = color; + } + public void Draw(SpriteBatch spriteBatch) { if (!Enabled) return; @@ -1136,9 +1148,11 @@ namespace Barotrauma GUI.DrawProgressBar(spriteBatch, healthBarPos, new Vector2(100.0f, 15.0f), health / maxHealth, Color.Lerp(Color.Red, Color.Green, health / maxHealth) * 0.8f); - if (SpeechBubbleTimer > 0.0f) + if (speechBubbleTimer > 0.0f) { - GUI.SpeechBubbleIcon.Draw(spriteBatch, pos - Vector2.UnitY * 100.0f, Color.White * Math.Min(SpeechBubbleTimer, 1.0f)); + GUI.SpeechBubbleIcon.Draw(spriteBatch, pos - Vector2.UnitY * 100.0f, + speechBubbleColor * Math.Min(speechBubbleTimer, 1.0f), 0.0f, + Math.Min((float)speechBubbleTimer, 1.0f)); } } diff --git a/Subsurface/Source/Characters/CharacterHUD.cs b/Subsurface/Source/Characters/CharacterHUD.cs index 511a3de86..b9f39d07e 100644 --- a/Subsurface/Source/Characters/CharacterHUD.cs +++ b/Subsurface/Source/Characters/CharacterHUD.cs @@ -65,7 +65,7 @@ namespace Barotrauma for (int i = 0; i< character.Inventory.Items.Length-1; i++) { var item = character.Inventory.Items[i]; - if (item == null || CharacterInventory.limbSlots[i]==LimbSlot.Any) continue; + if (item == null || CharacterInventory.limbSlots[i]==InvSlotType.Any) continue; //var statusHUD = item.GetComponent(); //if (statusHUD == null) continue; foreach (ItemComponent ic in item.components) diff --git a/Subsurface/Source/Characters/Jobs/Job.cs b/Subsurface/Source/Characters/Jobs/Job.cs index d0e162094..d15453aa0 100644 --- a/Subsurface/Source/Characters/Jobs/Job.cs +++ b/Subsurface/Source/Characters/Jobs/Job.cs @@ -89,7 +89,6 @@ namespace Barotrauma foreach (XElement itemElement in SpawnItems.Elements()) { InitializeJobItem(character, spawnPoint, itemElement); - } } @@ -108,8 +107,8 @@ namespace Barotrauma if (ToolBox.GetAttributeBool(itemElement, "equip", false)) { - List allowedSlots = new List(item.AllowedSlots); - allowedSlots.Remove(LimbSlot.Any); + List allowedSlots = new List(item.AllowedSlots); + allowedSlots.Remove(InvSlotType.Any); character.Inventory.TryPutItem(item, allowedSlots, false); } diff --git a/Subsurface/Source/DebugConsole.cs b/Subsurface/Source/DebugConsole.cs index 9060e0479..d746326b0 100644 --- a/Subsurface/Source/DebugConsole.cs +++ b/Subsurface/Source/DebugConsole.cs @@ -27,6 +27,8 @@ namespace Barotrauma static class DebugConsole { + const int MaxMessages = 100; + public static List Messages = new List(); static bool isOpen; @@ -600,11 +602,21 @@ namespace Barotrauma return; } + if (Messages.Count > MaxMessages) + { + Messages.RemoveRange(0, Messages.Count - MaxMessages); + } + //messages.Add(new ColoredText(msg, color)); selectedIndex = listBox.children.Count; } + public static void Log(string message) + { + if (GameSettings.VerboseLogging) NewMessage(message, Color.Gray); + } + public static void ThrowError(string error, Exception e = null) { if (e != null) error += " {" + e.Message + "}"; diff --git a/Subsurface/Source/GameMain.cs b/Subsurface/Source/GameMain.cs index 8c9f48c62..a5491c403 100644 --- a/Subsurface/Source/GameMain.cs +++ b/Subsurface/Source/GameMain.cs @@ -189,12 +189,11 @@ namespace Barotrauma GUIComponent.Init(Window); DebugConsole.Init(Window); - yield return CoroutineStatus.Running; + DebugConsole.Log(SelectedPackage == null ? "No content package selected" : "Content package ''" + SelectedPackage.Name + "'' selected"); + yield return CoroutineStatus.Running; LightManager = new Lights.LightManager(GraphicsDevice); - - Hull.renderer = new WaterRenderer(GraphicsDevice, Content); TitleScreen.LoadState = 1.0f; yield return CoroutineStatus.Running; @@ -223,7 +222,7 @@ namespace Barotrauma while (!SoundPlayer.Initialized) { i++; - TitleScreen.LoadState = Math.Min((float)TitleScreen.LoadState + 40.0f/41, 70.0f); + TitleScreen.LoadState = Math.Min((float)TitleScreen.LoadState + 40.0f / 41, 70.0f); yield return CoroutineStatus.Running; } diff --git a/Subsurface/Source/GameSession/GameModes/Tutorials/TutorialType.cs b/Subsurface/Source/GameSession/GameModes/Tutorials/TutorialType.cs index 50d06c99f..76ce124a6 100644 --- a/Subsurface/Source/GameSession/GameModes/Tutorials/TutorialType.cs +++ b/Subsurface/Source/GameSession/GameModes/Tutorials/TutorialType.cs @@ -63,6 +63,11 @@ namespace Barotrauma.Tutorials character.GiveJobItems(null); var idCard = character.Inventory.FindItem("ID Card"); + if (idCard == null) + { + DebugConsole.ThrowError("Item prefab ''ID Card'' not found!"); + return; + } idCard.AddTag("com"); idCard.AddTag("eng"); diff --git a/Subsurface/Source/GameSettings.cs b/Subsurface/Source/GameSettings.cs index f15c828ac..073db5e17 100644 --- a/Subsurface/Source/GameSettings.cs +++ b/Subsurface/Source/GameSettings.cs @@ -47,6 +47,8 @@ namespace Barotrauma public bool AutoCheckUpdates { get; set; } public bool WasGameUpdated { get; set; } + public static bool VerboseLogging { get; set; } + public bool UnsavedSettings { get @@ -130,6 +132,8 @@ namespace Barotrauma SoundVolume = ToolBox.GetAttributeFloat(doc.Root, "soundvolume", 1.0f); MusicVolume = ToolBox.GetAttributeFloat(doc.Root, "musicvolume", 0.3f); + VerboseLogging = ToolBox.GetAttributeBool(doc.Root, "verboselogging", false); + keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length]; keyMapping[(int)InputType.Up] = new KeyOrMouse(Keys.W); keyMapping[(int)InputType.Down] = new KeyOrMouse(Keys.S); @@ -145,13 +149,15 @@ namespace Barotrauma keyMapping[(int)InputType.Use] = new KeyOrMouse(0); keyMapping[(int)InputType.Aim] = new KeyOrMouse(1); - + foreach (XElement subElement in doc.Root.Elements()) { switch (subElement.Name.ToString().ToLower()) { case "contentpackage": string path = ToolBox.GetAttributeString(subElement, "path", ""); + + SelectedContentPackage = ContentPackage.list.Find(cp => cp.Path == path); if (SelectedContentPackage == null) SelectedContentPackage = new ContentPackage(path); diff --git a/Subsurface/Source/Items/CharacterInventory.cs b/Subsurface/Source/Items/CharacterInventory.cs index ab9784bcf..f6062b65d 100644 --- a/Subsurface/Source/Items/CharacterInventory.cs +++ b/Subsurface/Source/Items/CharacterInventory.cs @@ -9,7 +9,7 @@ using System.Collections.Generic; namespace Barotrauma { [Flags] - public enum LimbSlot + public enum InvSlotType { None = 0, Any = 1, RightHand = 2, LeftHand = 4, Head = 8, Torso = 16, Legs = 32, Face=64 }; @@ -20,10 +20,10 @@ namespace Barotrauma private Character character; - public static LimbSlot[] limbSlots = new LimbSlot[] { - LimbSlot.Head, LimbSlot.Torso, LimbSlot.Legs, LimbSlot.LeftHand, LimbSlot.RightHand, LimbSlot.Face, - LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, - LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any}; + public static InvSlotType[] limbSlots = new InvSlotType[] { + InvSlotType.Head, InvSlotType.Torso, InvSlotType.Legs, InvSlotType.LeftHand, InvSlotType.RightHand, InvSlotType.Face, + InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, + InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any}; public Vector2[] SlotPositions; @@ -111,7 +111,7 @@ namespace Barotrauma } } - public int FindLimbSlot(LimbSlot limbSlot) + public int FindLimbSlot(InvSlotType limbSlot) { for (int i = 0; i < Items.Length; i++) { @@ -120,7 +120,7 @@ namespace Barotrauma return -1; } - public bool IsInLimbSlot(Item item, LimbSlot limbSlot) + public bool IsInLimbSlot(Item item, InvSlotType limbSlot) { for (int i = 0; i /// If there is room, puts the item in the inventory and returns true, otherwise returns false /// - public override bool TryPutItem(Item item, List allowedSlots = null, bool createNetworkEvent = true) + public override bool TryPutItem(Item item, List allowedSlots = null, bool createNetworkEvent = true) { if (allowedSlots == null) return false; //try to place the item in LimBlot.Any slot if that's allowed - if (allowedSlots.Contains(LimbSlot.Any)) + if (allowedSlots.Contains(InvSlotType.Any)) { for (int i = 0; i < capacity; i++) { - if (Items[i] != null || limbSlots[i] != LimbSlot.Any) continue; + if (Items[i] != null || limbSlots[i] != InvSlotType.Any) continue; PutItem(item, i, createNetworkEvent); item.Unequip(character); @@ -150,7 +150,7 @@ namespace Barotrauma } bool placed = false; - foreach (LimbSlot allowedSlot in allowedSlots) + foreach (InvSlotType allowedSlot in allowedSlots) { //check if all the required slots are free bool free = true; @@ -235,20 +235,20 @@ namespace Barotrauma return combined; } - if (limbSlots[index] == LimbSlot.Any) + if (limbSlots[index] == InvSlotType.Any) { - if (!item.AllowedSlots.Contains(LimbSlot.Any)) return false; + if (!item.AllowedSlots.Contains(InvSlotType.Any)) return false; if (Items[index] != null) return Items[index] == item; PutItem(item, index, createNetworkEvent, true); return true; } - LimbSlot placeToSlots = LimbSlot.None; + InvSlotType placeToSlots = InvSlotType.None; bool slotsFree = true; - List allowedSlots = item.AllowedSlots; - foreach (LimbSlot allowedSlot in allowedSlots) + List allowedSlots = item.AllowedSlots; + foreach (InvSlotType allowedSlot in allowedSlots) { if (!allowedSlot.HasFlag(limbSlots[index])) continue; @@ -266,7 +266,7 @@ namespace Barotrauma if (!slotsFree) return false; - return TryPutItem(item, new List() {placeToSlots}, createNetworkEvent); + return TryPutItem(item, new List() {placeToSlots}, createNetworkEvent); } public void DrawOwn(SpriteBatch spriteBatch, Vector2 offset) diff --git a/Subsurface/Source/Items/Components/Holdable/Pickable.cs b/Subsurface/Source/Items/Components/Holdable/Pickable.cs index 84857cabc..274fe8d92 100644 --- a/Subsurface/Source/Items/Components/Holdable/Pickable.cs +++ b/Subsurface/Source/Items/Components/Holdable/Pickable.cs @@ -11,12 +11,12 @@ namespace Barotrauma.Items.Components { protected Character picker; - protected List allowedSlots; + protected List allowedSlots; private float pickTimer; - public List AllowedSlots + public List AllowedSlots { get { return allowedSlots; } } @@ -29,23 +29,23 @@ namespace Barotrauma.Items.Components public Pickable(Item item, XElement element) : base(item, element) { - allowedSlots = new List(); + allowedSlots = new List(); string slotString = ToolBox.GetAttributeString(element, "slots", "Any"); string[] slotCombinations = slotString.Split(','); foreach (string slotCombination in slotCombinations) { string[] slots = slotCombination.Split('+'); - LimbSlot allowedSlot = LimbSlot.None; + InvSlotType allowedSlot = InvSlotType.None; foreach (string slot in slots) { if (slot.ToLower()=="bothhands") { - allowedSlot = LimbSlot.LeftHand | LimbSlot.RightHand; + allowedSlot = InvSlotType.LeftHand | InvSlotType.RightHand; } else { - allowedSlot = allowedSlot | (LimbSlot)Enum.Parse(typeof(LimbSlot), slot.Trim()); + allowedSlot = allowedSlot | (InvSlotType)Enum.Parse(typeof(InvSlotType), slot.Trim()); } } allowedSlots.Add(allowedSlot); diff --git a/Subsurface/Source/Items/Inventory.cs b/Subsurface/Source/Items/Inventory.cs index ef220341f..4767be4d6 100644 --- a/Subsurface/Source/Items/Inventory.cs +++ b/Subsurface/Source/Items/Inventory.cs @@ -27,8 +27,6 @@ namespace Barotrauma protected int capacity; - - private Vector2 centerPos; protected int selectedSlot; @@ -95,7 +93,7 @@ namespace Barotrauma /// /// If there is room, puts the item in the inventory and returns true, otherwise returns false /// - public virtual bool TryPutItem(Item item, List allowedSlots = null, bool createNetworkEvent = true) + public virtual bool TryPutItem(Item item, List allowedSlots = null, bool createNetworkEvent = true) { int slot = FindAllowedSlot(item); if (slot < 0) return false; @@ -334,14 +332,30 @@ namespace Barotrauma { GUI.DrawRectangle(spriteBatch, rect, (isHighLighted ? Color.Red : Color.White) * alpha*0.75f, true); - if (item != null && item.Condition < 100.0f) + if (item != null) { - GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, rect.Bottom - 4, rect.Width, 4), Color.Black, true); - GUI.DrawRectangle(spriteBatch, - new Rectangle(rect.X, rect.Bottom - 4, (int)(rect.Width * item.Condition / 100.0f), 4), - Color.Lerp(Color.Red, Color.Green, item.Condition / 100.0f), true); + if (item.Condition < 100.0f) + { + GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, rect.Bottom - 8, rect.Width, 8), Color.Black*0.8f, true); + GUI.DrawRectangle(spriteBatch, + new Rectangle(rect.X, rect.Bottom - 8, (int)(rect.Width * item.Condition / 100.0f), 8), + Color.Lerp(Color.Red, Color.Green, item.Condition / 100.0f)*0.8f, true); + } + + if (!isHighLighted) + { + var containedItems = item.ContainedItems; + if (containedItems != null && containedItems.Length == 1 && containedItems[0].Condition < 100.0f) + { + GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, rect.Y, rect.Width, 8), Color.Black*0.8f, true); + GUI.DrawRectangle(spriteBatch, + new Rectangle(rect.X, rect.Y, (int)(rect.Width * containedItems[0].Condition / 100.0f), 8), + Color.Lerp(Color.Red, Color.Green, containedItems[0].Condition / 100.0f)*0.8f, true); + } + } } + GUI.DrawRectangle(spriteBatch, rect, (isHighLighted ? Color.Red : Color.White) * alpha, false); if (item == null || !drawItem) return; diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 3592f75e1..c2202bcab 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -236,12 +236,12 @@ namespace Barotrauma } //which type of inventory slots (head, torso, any, etc) the item can be placed in - public List AllowedSlots + public List AllowedSlots { get { Pickable p = GetComponent(); - return (p==null) ? new List() { LimbSlot.Any } : p.AllowedSlots; + return (p==null) ? new List() { InvSlotType.Any } : p.AllowedSlots; } } diff --git a/Subsurface/Source/Items/ItemPrefab.cs b/Subsurface/Source/Items/ItemPrefab.cs index 10342da36..0327e798b 100644 --- a/Subsurface/Source/Items/ItemPrefab.cs +++ b/Subsurface/Source/Items/ItemPrefab.cs @@ -175,10 +175,12 @@ namespace Barotrauma public static void LoadAll(List filePaths) { - //string[] files = Directory.GetFiles(contentFolder, "*.xml", SearchOption.AllDirectories); + DebugConsole.Log("Loading item prefabs: "); foreach (string filePath in filePaths) { + DebugConsole.Log("*** "+filePath+" ***"); + XDocument doc = ToolBox.TryLoadXml(filePath); if (doc == null) return; @@ -200,12 +202,13 @@ namespace Barotrauma public ItemPrefab (XElement element, string filePath) { - configFile = filePath; name = ToolBox.GetAttributeString(element, "name", ""); if (name == "") DebugConsole.ThrowError("Unnamed item in "+filePath+"!"); + DebugConsole.Log(" "+name); + Description = ToolBox.GetAttributeString(element, "description", ""); pickThroughWalls = ToolBox.GetAttributeBool(element, "pickthroughwalls", false); @@ -226,13 +229,11 @@ namespace Barotrauma ImpactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 0.0f); - string categoriesStr = ToolBox.GetAttributeString(element, "category", "Misc"); string[] categories = categoriesStr.Split(','); - for (int i = 0; i i != null && i.GetComponent() != null); - if (radio == null) return false; - + if (radio == null || !sender.HasEquippedItem(radio)) return false; + var radioComponent = radio.GetComponent(); return radioComponent.HasRequiredContainedItems(false); } @@ -236,6 +236,8 @@ namespace Barotrauma.Networking var radio = message.Sender.Inventory.Items.First(i => i != null && i.GetComponent() != null); if (radio == null) return; + message.Sender.ShowSpeechBubble(2.0f, ChatMessage.MessageColor[(int)ChatMessageType.Radio]); + var radioComponent = radio.GetComponent(); radioComponent.Transmit(message.TextWithSender); return; @@ -251,7 +253,7 @@ namespace Barotrauma.Networking if (string.IsNullOrWhiteSpace(displayedText)) return; } - message.Sender.SpeechBubbleTimer = Math.Max(message.Sender.SpeechBubbleTimer, 2.0f); + message.Sender.ShowSpeechBubble(2.0f, ChatMessage.MessageColor[(int)ChatMessageType.Default]); } GameMain.NetLobbyScreen.NewChatMessage(message); diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs index e752eb90e..0de7b51b5 100644 --- a/Subsurface/Source/Screens/EditMapScreen.cs +++ b/Subsurface/Source/Screens/EditMapScreen.cs @@ -469,7 +469,7 @@ namespace Barotrauma var item = new Item(screwdriverPrefab, Vector2.Zero, null); - dummyCharacter.Inventory.TryPutItem(item, new List() {LimbSlot.RightHand}, false); + dummyCharacter.Inventory.TryPutItem(item, new List() {InvSlotType.RightHand}, false); wiringToolPanel = CreateWiringPanel(); } @@ -537,7 +537,7 @@ namespace Barotrauma var wire = new Item(userData as ItemPrefab, Vector2.Zero, null); - int slotIndex = dummyCharacter.Inventory.FindLimbSlot(LimbSlot.LeftHand); + int slotIndex = dummyCharacter.Inventory.FindLimbSlot(InvSlotType.LeftHand); //if there's some other type of wire in the inventory, remove it existingWire = dummyCharacter.Inventory.Items[slotIndex];