Converted the GetAttribute methods in the ToolBox class to extension methods
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Barotrauma
|
||||
{
|
||||
itemConfig = element.Element("Items");
|
||||
|
||||
requiredDeliveryAmount = ToolBox.GetAttributeInt(element, "requireddeliveryamount", 0);
|
||||
requiredDeliveryAmount = element.GetAttributeInt("requireddeliveryamount", 0);
|
||||
}
|
||||
|
||||
private void InitItems()
|
||||
@@ -41,7 +41,7 @@ namespace Barotrauma
|
||||
|
||||
private void LoadItemAsChild(XElement element, Item parent)
|
||||
{
|
||||
string itemName = ToolBox.GetAttributeString(element, "name", "");
|
||||
string itemName = element.GetAttributeString("name", "");
|
||||
|
||||
ItemPrefab itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
|
||||
if (itemPrefab==null)
|
||||
@@ -79,7 +79,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
int amount = ToolBox.GetAttributeInt(subElement, "amount", 1);
|
||||
int amount = subElement.GetAttributeInt("amount", 1);
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
LoadItemAsChild(subElement, item);
|
||||
|
||||
@@ -58,9 +58,9 @@ namespace Barotrauma
|
||||
{
|
||||
descriptions = new string[]
|
||||
{
|
||||
ToolBox.GetAttributeString(element, "descriptionneutral", ""),
|
||||
ToolBox.GetAttributeString(element, "description1", ""),
|
||||
ToolBox.GetAttributeString(element, "description2", "")
|
||||
element.GetAttributeString("descriptionneutral", ""),
|
||||
element.GetAttributeString("description1", ""),
|
||||
element.GetAttributeString("description2", "")
|
||||
};
|
||||
|
||||
for (int i = 0; i < descriptions.Length; i++)
|
||||
@@ -73,8 +73,8 @@ namespace Barotrauma
|
||||
|
||||
teamNames = new string[]
|
||||
{
|
||||
ToolBox.GetAttributeString(element, "teamname1", "Team A"),
|
||||
ToolBox.GetAttributeString(element, "teamname2", "Team B")
|
||||
element.GetAttributeString("teamname1", "Team A"),
|
||||
element.GetAttributeString("teamname2", "Team B")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Barotrauma
|
||||
var files = GameMain.SelectedPackage.GetFilesOfType(ContentType.Missions);
|
||||
foreach (string file in files)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(file);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(file);
|
||||
if (doc == null || doc.Root == null) continue;
|
||||
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
@@ -94,26 +94,26 @@ namespace Barotrauma
|
||||
|
||||
public Mission(XElement element, Location[] locations)
|
||||
{
|
||||
name = ToolBox.GetAttributeString(element, "name", "");
|
||||
name = element.GetAttributeString("name", "");
|
||||
|
||||
description = ToolBox.GetAttributeString(element, "description", "");
|
||||
description = element.GetAttributeString("description", "");
|
||||
|
||||
reward = ToolBox.GetAttributeInt(element, "reward", 1);
|
||||
reward = element.GetAttributeInt("reward", 1);
|
||||
|
||||
successMessage = ToolBox.GetAttributeString(element, "successmessage",
|
||||
successMessage = element.GetAttributeString("successmessage",
|
||||
"Mission completed successfully");
|
||||
failureMessage = ToolBox.GetAttributeString(element, "failuremessage",
|
||||
failureMessage = element.GetAttributeString("failuremessage",
|
||||
"Mission failed");
|
||||
|
||||
radarLabel = ToolBox.GetAttributeString(element, "radarlabel", "");
|
||||
radarLabel = element.GetAttributeString("radarlabel", "");
|
||||
|
||||
messages = new List<string>();
|
||||
headers = new List<string>();
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().ToLowerInvariant() != "message") continue;
|
||||
headers.Add(ToolBox.GetAttributeString(subElement, "header", ""));
|
||||
messages.Add(ToolBox.GetAttributeString(subElement, "text", ""));
|
||||
headers.Add(subElement.GetAttributeString("header", ""));
|
||||
messages.Add(subElement.GetAttributeString("text", ""));
|
||||
}
|
||||
|
||||
for (int n = 0; n < 2; n++)
|
||||
@@ -137,7 +137,7 @@ namespace Barotrauma
|
||||
var files = GameMain.SelectedPackage.GetFilesOfType(ContentType.Missions);
|
||||
string configFile = files[rand.Next(files.Count)];
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml(configFile);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile);
|
||||
if (doc == null) return null;
|
||||
|
||||
int eventCount = doc.Root.Elements().Count();
|
||||
@@ -167,17 +167,17 @@ namespace Barotrauma
|
||||
|
||||
if (isSinglePlayer)
|
||||
{
|
||||
matchingElements.RemoveAll(m => ToolBox.GetAttributeBool(m, "multiplayeronly", false));
|
||||
matchingElements.RemoveAll(m => m.GetAttributeBool("multiplayeronly", false));
|
||||
}
|
||||
else
|
||||
{
|
||||
matchingElements.RemoveAll(m => ToolBox.GetAttributeBool(m, "singleplayeronly", false));
|
||||
matchingElements.RemoveAll(m => m.GetAttributeBool("singleplayeronly", false));
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
foreach (XElement element in matchingElements)
|
||||
{
|
||||
eventProbability[i] = ToolBox.GetAttributeInt(element, "commonness", 1);
|
||||
eventProbability[i] = element.GetAttributeInt("commonness", 1);
|
||||
|
||||
probabilitySum += eventProbability[i];
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Barotrauma
|
||||
public MonsterMission(XElement element, Location[] locations)
|
||||
: base(element, locations)
|
||||
{
|
||||
monsterFile = ToolBox.GetAttributeString(element, "monsterfile", "");
|
||||
monsterFile = element.GetAttributeString("monsterfile", "");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace Barotrauma
|
||||
public SalvageMission(XElement element, Location[] locations)
|
||||
: base(element, locations)
|
||||
{
|
||||
string itemName = ToolBox.GetAttributeString(element, "itemname", "");
|
||||
string itemName = element.GetAttributeString("itemname", "");
|
||||
|
||||
itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
|
||||
|
||||
string spawnPositionTypeStr = ToolBox.GetAttributeString(element, "spawntype", "");
|
||||
string spawnPositionTypeStr = element.GetAttributeString("spawntype", "");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(spawnPositionTypeStr) ||
|
||||
!Enum.TryParse<Level.PositionType>(spawnPositionTypeStr, true, out spawnPositionType))
|
||||
|
||||
Reference in New Issue
Block a user