Replaced instances where MapEntityPrefabs are searched for based on the name with a static Find method that takes the aliases of the prefabs into account.

This commit is contained in:
Joonas Rikkonen
2017-11-14 21:40:43 +02:00
parent d072713936
commit 5f4bf48449
17 changed files with 141 additions and 130 deletions
@@ -718,13 +718,8 @@ namespace Barotrauma
if (wiringMode)
{
CreateDummyCharacter();
var screwdriverPrefab = ItemPrefab.list.Find(ip => ip.Name == "Screwdriver") as ItemPrefab;
var item = new Item(screwdriverPrefab, Vector2.Zero, null);
var item = new Item(MapEntityPrefab.Find("Screwdriver") as ItemPrefab, Vector2.Zero, null);
dummyCharacter.Inventory.TryPutItem(item, null, new List<InvSlotType>() { InvSlotType.RightHand });
wiringToolPanel = CreateWiringPanel();
}
else
@@ -760,11 +755,12 @@ namespace Barotrauma
GUIListBox listBox = new GUIListBox(Rectangle.Empty, "", frame);
listBox.OnSelected = SelectWire;
foreach (MapEntityPrefab ep in MapEntityPrefab.list)
{
var itemPrefab = ep as ItemPrefab;
if (itemPrefab == null || itemPrefab.Name == null || !itemPrefab.Name.Contains("Wire")) continue;
if (itemPrefab == null || itemPrefab.Name == null) continue;
if (!itemPrefab.Name.Contains("Wire") && (itemPrefab.Aliases == null || !itemPrefab.Aliases.Any(a => a.Contains("Wire")))) continue;
GUIFrame imgFrame = new GUIFrame(new Rectangle(0, 0, (int)itemPrefab.sprite.size.X, (int)itemPrefab.sprite.size.Y), null, listBox);
imgFrame.UserData = itemPrefab;