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
@@ -389,12 +389,11 @@ namespace Barotrauma.RuinGeneration
prop.Prefab as StructurePrefab, null).MoveWithLevel = true;
}
}
//generate doors & sensors that close them -------------------------------------------------------------
var sensorPrefab = ItemPrefab.list.Find(ip => ip.Name == "Alien Motion Sensor") as ItemPrefab;
var wirePrefab = ItemPrefab.list.Find(ip => ip.Name == "Wire") as ItemPrefab;
var sensorPrefab = MapEntityPrefab.Find("Alien Motion Sensor") as ItemPrefab;
var wirePrefab = MapEntityPrefab.Find("Wire") as ItemPrefab;
foreach (Corridor corridor in corridors)
{
@@ -27,26 +27,26 @@ namespace Barotrauma.RuinGeneration
private RuinStructure(XElement element)
{
string prefab = element.GetAttributeString("prefab", "").ToLowerInvariant();
Prefab = MapEntityPrefab.list.Find(s => s.Name.ToLowerInvariant() == prefab);
string name = element.GetAttributeString("prefab", "");
Prefab = MapEntityPrefab.Find(name);
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;
}
string alignmentStr = element.GetAttributeString("alignment","Bottom");
string alignmentStr = element.GetAttributeString("alignment", "Bottom");
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","");
if (!Enum.TryParse<RuinStructureType>(typeStr,true, out Type))
string typeStr = element.GetAttributeString("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;
}