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) if (wiringMode)
{ {
CreateDummyCharacter(); CreateDummyCharacter();
var item = new Item(MapEntityPrefab.Find("Screwdriver") as ItemPrefab, Vector2.Zero, null);
var screwdriverPrefab = ItemPrefab.list.Find(ip => ip.Name == "Screwdriver") as ItemPrefab;
var item = new Item(screwdriverPrefab, Vector2.Zero, null);
dummyCharacter.Inventory.TryPutItem(item, null, new List<InvSlotType>() { InvSlotType.RightHand }); dummyCharacter.Inventory.TryPutItem(item, null, new List<InvSlotType>() { InvSlotType.RightHand });
wiringToolPanel = CreateWiringPanel(); wiringToolPanel = CreateWiringPanel();
} }
else else
@@ -764,7 +759,8 @@ namespace Barotrauma
foreach (MapEntityPrefab ep in MapEntityPrefab.list) foreach (MapEntityPrefab ep in MapEntityPrefab.list)
{ {
var itemPrefab = ep as ItemPrefab; 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); GUIFrame imgFrame = new GUIFrame(new Rectangle(0, 0, (int)itemPrefab.sprite.size.X, (int)itemPrefab.sprite.size.Y), null, listBox);
imgFrame.UserData = itemPrefab; imgFrame.UserData = itemPrefab;
@@ -98,7 +98,7 @@ namespace Barotrauma
{ {
string itemName = itemElement.GetAttributeString("name", ""); string itemName = itemElement.GetAttributeString("name", "");
ItemPrefab itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab; ItemPrefab itemPrefab = MapEntityPrefab.Find(itemName) as ItemPrefab;
if (itemPrefab == null) if (itemPrefab == null)
{ {
DebugConsole.ThrowError("Tried to spawn \"" + Name + "\" with the item \"" + itemName + "\". Matching item prefab not found."); DebugConsole.ThrowError("Tried to spawn \"" + Name + "\" with the item \"" + itemName + "\". Matching item prefab not found.");
@@ -124,7 +124,7 @@ namespace Barotrauma
character.Inventory.TryPutItem(item, null, item.AllowedSlots); character.Inventory.TryPutItem(item, null, item.AllowedSlots);
} }
if (item.Prefab.Name == "ID Card" && spawnPoint != null) if (item.Prefab.NameMatches("ID Card") && spawnPoint != null)
{ {
foreach (string s in spawnPoint.IdCardTags) foreach (string s in spawnPoint.IdCardTags)
{ {
@@ -213,7 +213,7 @@ namespace Barotrauma
string itemName = string.Join(" ", args.Take(args.Length - extraParams)).ToLowerInvariant(); string itemName = string.Join(" ", args.Take(args.Length - extraParams)).ToLowerInvariant();
var itemPrefab = MapEntityPrefab.list.Find(ip => ip.Name.ToLowerInvariant() == itemName) as ItemPrefab; var itemPrefab = MapEntityPrefab.Find(itemName) as ItemPrefab;
if (itemPrefab == null) if (itemPrefab == null)
{ {
ThrowError("Item \"" + itemName + "\" not found!"); ThrowError("Item \"" + itemName + "\" not found!");
@@ -14,19 +14,18 @@ namespace Barotrauma
public override string ToString() public override string ToString()
{ {
return "ScriptedEvent (" + (itemPrefab==null ? "null" : itemPrefab.Name) + ")"; return "ScriptedEvent (" + (itemPrefab == null ? "null" : itemPrefab.Name) + ")";
} }
public ArtifactEvent(XElement element) public ArtifactEvent(XElement element)
: base(element) : base(element)
{ {
string itemName = element.GetAttributeString("itemname", ""); string itemName = element.GetAttributeString("itemname", "");
itemPrefab = MapEntityPrefab.Find(itemName) as ItemPrefab;
itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
if (itemPrefab == null) if (itemPrefab == null)
{ {
DebugConsole.ThrowError("Error in SalvageMission: couldn't find an item prefab with the name "+itemName); DebugConsole.ThrowError("Error in SalvageMission: couldn't find an item prefab with the name " + itemName);
} }
} }
@@ -43,15 +43,15 @@ namespace Barotrauma
{ {
string itemName = element.GetAttributeString("name", ""); string itemName = element.GetAttributeString("name", "");
ItemPrefab itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab; ItemPrefab itemPrefab = MapEntityPrefab.Find(itemName) as ItemPrefab;
if (itemPrefab==null) if (itemPrefab == null)
{ {
DebugConsole.ThrowError("Couldn't spawn item for cargo mission: item prefab \""+element.Name.ToString()+"\" not found"); DebugConsole.ThrowError("Couldn't spawn item for cargo mission: item prefab \"" + element.Name.ToString() + "\" not found");
return; return;
} }
WayPoint cargoSpawnPos = WayPoint.GetRandom(SpawnType.Cargo, null, Submarine.MainSub, true); WayPoint cargoSpawnPos = WayPoint.GetRandom(SpawnType.Cargo, null, Submarine.MainSub, true);
if (cargoSpawnPos==null) if (cargoSpawnPos == null)
{ {
DebugConsole.ThrowError("Couldn't spawn items for cargo mission, cargo spawnpoint not found"); DebugConsole.ThrowError("Couldn't spawn items for cargo mission, cargo spawnpoint not found");
return; return;
@@ -28,7 +28,12 @@ namespace Barotrauma
{ {
string itemName = element.GetAttributeString("itemname", ""); string itemName = element.GetAttributeString("itemname", "");
itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab; itemPrefab = MapEntityPrefab.Find(itemName) as ItemPrefab;
if (itemPrefab == null)
{
DebugConsole.ThrowError("Error in SalvageMission: couldn't find an item prefab with the name " + itemName);
return;
}
string spawnPositionTypeStr = element.GetAttributeString("spawntype", ""); string spawnPositionTypeStr = element.GetAttributeString("spawntype", "");
@@ -37,11 +42,6 @@ namespace Barotrauma
{ {
spawnPositionType = Level.PositionType.Cave | Level.PositionType.Ruin; spawnPositionType = Level.PositionType.Cave | Level.PositionType.Ruin;
} }
if (itemPrefab == null)
{
DebugConsole.ThrowError("Error in SalvageMission: couldn't find an item prefab with the name "+itemName);
}
} }
public override void Start(Level level) public override void Start(Level level)
@@ -390,7 +390,7 @@ namespace Barotrauma.Items.Components
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
hullRects[i].Location -= MathUtils.ToPoint((subs[i].WorldPosition - subs[i].HiddenSubPosition)); hullRects[i].Location -= MathUtils.ToPoint((subs[i].WorldPosition - subs[i].HiddenSubPosition));
hulls[i] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRects[i], subs[i]); hulls[i] = new Hull(MapEntityPrefab.Find("Hull"), hullRects[i], subs[i]);
hulls[i].AddToGrid(subs[i]); hulls[i].AddToGrid(subs[i]);
for (int j = 0; j < 2; j++) for (int j = 0; j < 2; j++)
@@ -420,7 +420,7 @@ namespace Barotrauma.Items.Components
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
hullRects[i].Location -= MathUtils.ToPoint((subs[i].WorldPosition - subs[i].HiddenSubPosition)); hullRects[i].Location -= MathUtils.ToPoint((subs[i].WorldPosition - subs[i].HiddenSubPosition));
hulls[i] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRects[i], subs[i]); hulls[i] = new Hull(MapEntityPrefab.Find("Hull"), hullRects[i], subs[i]);
hulls[i].AddToGrid(subs[i]); hulls[i].AddToGrid(subs[i]);
if (hullIds[i] != null) hulls[i].ID = (ushort)hullIds[i]; if (hullIds[i] != null) hulls[i].ID = (ushort)hullIds[i];
@@ -59,7 +59,7 @@ namespace Barotrauma.Items.Components
{ {
if (deconstructProduct.RequireFullCondition && targetItem.Condition < targetItem.Prefab.Health) continue; if (deconstructProduct.RequireFullCondition && targetItem.Condition < targetItem.Prefab.Health) continue;
var itemPrefab = MapEntityPrefab.list.FirstOrDefault(ip => ip.Name.ToLowerInvariant() == deconstructProduct.ItemPrefabName.ToLowerInvariant()) as ItemPrefab; var itemPrefab = MapEntityPrefab.Find(deconstructProduct.ItemPrefabName) as ItemPrefab;
if (itemPrefab == null) if (itemPrefab == null)
{ {
DebugConsole.ThrowError("Tried to deconstruct item \"" + targetItem.Name + "\" but couldn't find item prefab \"" + deconstructProduct + "\"!"); DebugConsole.ThrowError("Tried to deconstruct item \"" + targetItem.Name + "\" but couldn't find item prefab \"" + deconstructProduct + "\"!");
@@ -22,7 +22,7 @@ namespace Barotrauma.Items.Components
{ {
string name = element.GetAttributeString("name", ""); string name = element.GetAttributeString("name", "");
TargetItem = MapEntityPrefab.list.Find(ip => ip.Name.ToLowerInvariant() == name.ToLowerInvariant()) as ItemPrefab; TargetItem = MapEntityPrefab.Find(name) as ItemPrefab;
if (TargetItem == null) if (TargetItem == null)
{ {
@@ -30,9 +30,7 @@ namespace Barotrauma.Items.Components
} }
RequiredSkills = new List<Skill>(); RequiredSkills = new List<Skill>();
RequiredTime = element.GetAttributeFloat("requiredtime", 1.0f); RequiredTime = element.GetAttributeFloat("requiredtime", 1.0f);
RequiredItems = new List<Tuple<ItemPrefab, int>>(); RequiredItems = new List<Tuple<ItemPrefab, int>>();
string[] requiredItemNames = element.GetAttributeString("requireditems", "").Split(','); string[] requiredItemNames = element.GetAttributeString("requireditems", "").Split(',');
@@ -40,25 +38,22 @@ namespace Barotrauma.Items.Components
{ {
if (string.IsNullOrWhiteSpace(requiredItemName)) continue; if (string.IsNullOrWhiteSpace(requiredItemName)) continue;
ItemPrefab requiredItem = ItemPrefab.list.Find(ip => ip.Name.ToLowerInvariant() == requiredItemName.Trim().ToLowerInvariant()) as ItemPrefab; ItemPrefab requiredItem = MapEntityPrefab.Find(requiredItemName.Trim()) as ItemPrefab;
if (requiredItem == null) if (requiredItem == null)
{ {
DebugConsole.ThrowError("Error in fabricable item " + name + "! Required item \"" + requiredItemName + "\" not found."); DebugConsole.ThrowError("Error in fabricable item " + name + "! Required item \"" + requiredItemName + "\" not found.");
continue; continue;
} }
var existing = RequiredItems.Find(r => r.Item1 == requiredItem); var existing = RequiredItems.Find(r => r.Item1 == requiredItem);
if (existing == null) if (existing == null)
{ {
RequiredItems.Add(new Tuple<ItemPrefab, int>(requiredItem, 1)); RequiredItems.Add(new Tuple<ItemPrefab, int>(requiredItem, 1));
} }
else else
{ {
RequiredItems.Remove(existing); RequiredItems.Remove(existing);
RequiredItems.Add(new Tuple<ItemPrefab, int>(requiredItem, existing.Item2+1)); RequiredItems.Add(new Tuple<ItemPrefab, int>(requiredItem, existing.Item2 + 1));
} }
} }
@@ -1489,10 +1489,7 @@ namespace Barotrauma
//---------------------------------------- //----------------------------------------
var prefab = MapEntityPrefab.list.Find(me => me.Name == itemName); var itemPrefab = MapEntityPrefab.Find(itemName) as ItemPrefab;
if (prefab == null) return null;
var itemPrefab = prefab as ItemPrefab;
if (itemPrefab == null) return null; if (itemPrefab == null) return null;
Inventory inventory = null; Inventory inventory = null;
@@ -1592,68 +1589,64 @@ namespace Barotrauma
public static void Load(XElement element, Submarine submarine) public static void Load(XElement element, Submarine submarine)
{ {
Rectangle rect = element.GetAttributeRect("rect", Rectangle.Empty);
string name = element.Attribute("name").Value; string name = element.Attribute("name").Value;
foreach (MapEntityPrefab ep in MapEntityPrefab.list) ItemPrefab prefab = MapEntityPrefab.Find(name) as ItemPrefab;
if (prefab == null)
{ {
ItemPrefab ip = ep as ItemPrefab; DebugConsole.ThrowError("Error loading item - item prefab \"" + name + "\" not found.");
if (ip == null) continue; return;
}
if (ip.Name != name && (ip.Aliases == null || !ip.Aliases.Contains(name))) continue; Rectangle rect = element.GetAttributeRect("rect", Rectangle.Empty);
if (rect.Width == 0 && rect.Height == 0)
{
rect.Width = (int)prefab.Size.X;
rect.Height = (int)prefab.Size.Y;
}
if (rect.Width == 0 && rect.Height == 0) Item item = new Item(rect, prefab, submarine);
item.Submarine = submarine;
item.ID = (ushort)int.Parse(element.Attribute("ID").Value);
item.linkedToID = new List<ushort>();
foreach (XAttribute attribute in element.Attributes())
{
SerializableProperty property = null;
if (!item.properties.TryGetValue(attribute.Name.ToString(), out property)) continue;
bool shouldBeLoaded = false;
foreach (var propertyAttribute in property.Attributes.OfType<Serialize>())
{ {
rect.Width = (int)ip.Size.X; if (propertyAttribute.isSaveable)
rect.Height = (int)ip.Size.Y;
}
Item item = new Item(rect, ip, submarine);
item.Submarine = submarine;
item.ID = (ushort)int.Parse(element.Attribute("ID").Value);
item.linkedToID = new List<ushort>();
foreach (XAttribute attribute in element.Attributes())
{
SerializableProperty property = null;
if (!item.properties.TryGetValue(attribute.Name.ToString(), out property)) continue;
bool shouldBeLoaded = false;
foreach (var propertyAttribute in property.Attributes.OfType<Serialize>())
{ {
if (propertyAttribute.isSaveable) shouldBeLoaded = true;
{ break;
shouldBeLoaded = true;
break;
}
}
if (shouldBeLoaded) property.TrySetValue(attribute.Value);
}
string linkedToString = element.GetAttributeString("linked", "");
if (linkedToString!="")
{
string[] linkedToIds = linkedToString.Split(',');
for (int i = 0; i<linkedToIds.Length;i++)
{
item.linkedToID.Add((ushort)int.Parse(linkedToIds[i]));
} }
} }
foreach (XElement subElement in element.Elements()) if (shouldBeLoaded) property.TrySetValue(attribute.Value);
}
string linkedToString = element.GetAttributeString("linked", "");
if (linkedToString != "")
{
string[] linkedToIds = linkedToString.Split(',');
for (int i = 0; i < linkedToIds.Length; i++)
{ {
ItemComponent component = item.components.Find(x => x.Name == subElement.Name.ToString()); item.linkedToID.Add((ushort)int.Parse(linkedToIds[i]));
if (component == null) continue;
component.Load(subElement);
} }
}
break; foreach (XElement subElement in element.Elements())
{
ItemComponent component = item.components.Find(x => x.Name == subElement.Name.ToString());
if (component == null) continue;
component.Load(subElement);
} }
} }
@@ -101,7 +101,7 @@ namespace Barotrauma
{ } { }
public Gap(Rectangle newRect, bool isHorizontal, Submarine submarine) public Gap(Rectangle newRect, bool isHorizontal, Submarine submarine)
: base (MapEntityPrefab.list.Find(m=> m.Name == "Gap"), submarine) : base (MapEntityPrefab.Find("Gap"), submarine)
{ {
rect = newRect; rect = newRect;
linkedTo = new ObservableCollection<MapEntity>(); linkedTo = new ObservableCollection<MapEntity>();
@@ -255,7 +255,7 @@ namespace Barotrauma
public override MapEntity Clone() public override MapEntity Clone()
{ {
return new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), rect, Submarine); return new Hull(MapEntityPrefab.Find("Hull"), rect, Submarine);
} }
public static EntityGrid GenerateEntityGrid(Submarine submarine) public static EntityGrid GenerateEntityGrid(Submarine submarine)
@@ -722,7 +722,7 @@ namespace Barotrauma
int.Parse(element.Attribute("height").Value)); int.Parse(element.Attribute("height").Value));
} }
Hull h = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), rect, submarine); Hull h = new Hull(MapEntityPrefab.Find("Hull"), rect, submarine);
h.waterVolume = element.GetAttributeFloat("pressure", 0.0f); h.waterVolume = element.GetAttributeFloat("pressure", 0.0f);
@@ -390,11 +390,10 @@ namespace Barotrauma.RuinGeneration
} }
} }
//generate doors & sensors that close them ------------------------------------------------------------- //generate doors & sensors that close them -------------------------------------------------------------
var sensorPrefab = ItemPrefab.list.Find(ip => ip.Name == "Alien Motion Sensor") as ItemPrefab; var sensorPrefab = MapEntityPrefab.Find("Alien Motion Sensor") as ItemPrefab;
var wirePrefab = ItemPrefab.list.Find(ip => ip.Name == "Wire") as ItemPrefab; var wirePrefab = MapEntityPrefab.Find("Wire") as ItemPrefab;
foreach (Corridor corridor in corridors) foreach (Corridor corridor in corridors)
{ {
@@ -27,26 +27,26 @@ namespace Barotrauma.RuinGeneration
private RuinStructure(XElement element) private RuinStructure(XElement element)
{ {
string prefab = element.GetAttributeString("prefab", "").ToLowerInvariant(); string name = element.GetAttributeString("prefab", "");
Prefab = MapEntityPrefab.list.Find(s => s.Name.ToLowerInvariant() == prefab); Prefab = MapEntityPrefab.Find(name);
if (Prefab == null) if (Prefab == null)
{ {
DebugConsole.ThrowError("Loading ruin structure failed - structure prefab \""+prefab+" not found"); DebugConsole.ThrowError("Loading ruin structure failed - structure prefab \"" + name + " not found");
return; return;
} }
string alignmentStr = element.GetAttributeString("alignment","Bottom"); string alignmentStr = element.GetAttributeString("alignment", "Bottom");
if (!Enum.TryParse<Alignment>(alignmentStr, true, out Alignment)) if (!Enum.TryParse<Alignment>(alignmentStr, true, out Alignment))
{ {
DebugConsole.ThrowError("Error in ruin structure \""+prefab+"\" - "+alignmentStr+" is not a valid alignment"); DebugConsole.ThrowError("Error in ruin structure \"" + name + "\" - " + alignmentStr + " is not a valid alignment");
} }
string typeStr = element.GetAttributeString("type",""); string typeStr = element.GetAttributeString("type", "");
if (!Enum.TryParse<RuinStructureType>(typeStr,true, out Type)) if (!Enum.TryParse<RuinStructureType>(typeStr, true, out Type))
{ {
DebugConsole.ThrowError("Error in ruin structure \"" + prefab + "\" - " + typeStr + " is not a valid type"); DebugConsole.ThrowError("Error in ruin structure \"" + name + "\" - " + typeStr + " is not a valid type");
return; return;
} }
@@ -1,6 +1,7 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Reflection; using System.Reflection;
namespace Barotrauma namespace Barotrauma
@@ -191,6 +192,43 @@ namespace Barotrauma
} }
} }
public static MapEntityPrefab Find(string name, bool caseSensitive = false)
{
if (caseSensitive)
{
foreach (MapEntityPrefab prefab in list)
{
if (prefab.name == name || (prefab.Aliases != null && prefab.Aliases.Contains(name))) return prefab;
}
}
else
{
name = name.ToLowerInvariant();
foreach (MapEntityPrefab prefab in list)
{
if (prefab.name.ToLowerInvariant() == name || (prefab.Aliases != null && prefab.Aliases.Any(a => a.ToLowerInvariant() == name))) return prefab;
}
}
return null;
}
/// <summary>
/// Check if the name or any of the aliases of this prefab match the given name.
/// </summary>
public bool NameMatches(string name, bool caseSensitive = false)
{
if (caseSensitive)
{
return this.name == name || (Aliases != null && Aliases.Any(a => a == name));
}
else
{
name = name.ToLowerInvariant();
return this.name.ToLowerInvariant() == name || (Aliases != null && Aliases.Any(a => a.ToLowerInvariant() == name));
}
}
//a method that allows the GUIListBoxes to check through a delegate if the entityprefab is still selected //a method that allows the GUIListBoxes to check through a delegate if the entityprefab is still selected
public static object GetSelected() public static object GetSelected()
{ {
@@ -824,29 +824,20 @@ namespace Barotrauma
public static void Load(XElement element, Submarine submarine) public static void Load(XElement element, Submarine submarine)
{ {
Rectangle rect = element.GetAttributeRect("rect", Rectangle.Empty);
string name = element.Attribute("name").Value; string name = element.Attribute("name").Value;
Structure s = null; StructurePrefab prefab = MapEntityPrefab.Find(name) as StructurePrefab;
if (prefab == null)
foreach (MapEntityPrefab ep in MapEntityPrefab.list)
{ {
if (ep.Name == name || (ep.Aliases != null && ep.Aliases.Contains(name))) DebugConsole.ThrowError("Error loading structure - structure prefab " + name + " not found.");
{
s = new Structure(rect, (StructurePrefab)ep, submarine);
s.Submarine = submarine;
s.ID = (ushort)int.Parse(element.Attribute("ID").Value);
break;
}
}
if (s == null)
{
DebugConsole.ThrowError("Structure prefab " + name + " not found.");
return; return;
} }
Rectangle rect = element.GetAttributeRect("rect", Rectangle.Empty);
Structure s = new Structure(rect, prefab, submarine);
s.Submarine = submarine;
s.ID = (ushort)int.Parse(element.Attribute("ID").Value);
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString()) switch (subElement.Name.ToString())
@@ -429,10 +429,10 @@ namespace Barotrauma.Networking
//(in order to give them appropriate ID card tags) //(in order to give them appropriate ID card tags)
var mainSubSpawnPoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSub); var mainSubSpawnPoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSub);
ItemPrefab divingSuitPrefab = ItemPrefab.list.Find(ip => ip.Name == "Diving Suit") as ItemPrefab; ItemPrefab divingSuitPrefab = MapEntityPrefab.Find("Diving Suit") as ItemPrefab;
ItemPrefab oxyPrefab = ItemPrefab.list.Find(ip => ip.Name == "Oxygen Tank") as ItemPrefab; ItemPrefab oxyPrefab = MapEntityPrefab.Find("Oxygen Tank") as ItemPrefab;
ItemPrefab scooterPrefab = ItemPrefab.list.Find(ip => ip.Name == "Underwater Scooter") as ItemPrefab; ItemPrefab scooterPrefab = MapEntityPrefab.Find("Underwater Scooter") as ItemPrefab;
ItemPrefab batteryPrefab = ItemPrefab.list.Find(ip => ip.Name == "Battery Cell") as ItemPrefab; ItemPrefab batteryPrefab = MapEntityPrefab.Find("Battery Cell") as ItemPrefab;
var cargoSp = WayPoint.WayPointList.Find(wp => wp.Submarine == respawnShuttle && wp.SpawnType == SpawnType.Cargo); var cargoSp = WayPoint.WayPointList.Find(wp => wp.Submarine == respawnShuttle && wp.SpawnType == SpawnType.Cargo);