Converted the GetAttribute methods in the ToolBox class to extension methods

This commit is contained in:
Joonas Rikkonen
2017-10-04 18:38:40 +03:00
parent 6c7c97a875
commit 1ff2054ca8
99 changed files with 854 additions and 875 deletions
@@ -79,30 +79,30 @@ namespace Barotrauma
{
targetMemories = new Dictionary<AITarget, AITargetMemory>();
XDocument doc = ToolBox.TryLoadXml(file);
XDocument doc = XMLExtensions.TryLoadXml(file);
if (doc == null || doc.Root == null) return;
XElement aiElement = doc.Root.Element("ai");
if (aiElement == null) return;
attackRooms = ToolBox.GetAttributeFloat(aiElement, 0.0f, "attackrooms", "attackpriorityrooms") / 100.0f;
attackHumans = ToolBox.GetAttributeFloat(aiElement, 0.0f, "attackhumans", "attackpriorityhumans") / 100.0f;
attackWeaker = ToolBox.GetAttributeFloat(aiElement, 0.0f, "attackweaker", "attackpriorityweaker") / 100.0f;
attackStronger = ToolBox.GetAttributeFloat(aiElement, 0.0f, "attackstronger", "attackprioritystronger") / 100.0f;
eatDeadPriority = ToolBox.GetAttributeFloat(aiElement, "eatpriority", 0.0f) / 100.0f;
attackRooms = aiElement.GetAttributeFloat(0.0f, "attackrooms", "attackpriorityrooms") / 100.0f;
attackHumans = aiElement.GetAttributeFloat(0.0f, "attackhumans", "attackpriorityhumans") / 100.0f;
attackWeaker = aiElement.GetAttributeFloat(0.0f, "attackweaker", "attackpriorityweaker") / 100.0f;
attackStronger = aiElement.GetAttributeFloat(0.0f, "attackstronger", "attackprioritystronger") / 100.0f;
eatDeadPriority = aiElement.GetAttributeFloat("eatpriority", 0.0f) / 100.0f;
combatStrength = ToolBox.GetAttributeFloat(aiElement, "combatstrength", 1.0f);
combatStrength = aiElement.GetAttributeFloat("combatstrength", 1.0f);
attackCoolDown = ToolBox.GetAttributeFloat(aiElement, "attackcooldown", 5.0f);
attackCoolDown = aiElement.GetAttributeFloat("attackcooldown", 5.0f);
sight = ToolBox.GetAttributeFloat(aiElement, "sight", 0.0f);
hearing = ToolBox.GetAttributeFloat(aiElement, "hearing", 0.0f);
sight = aiElement.GetAttributeFloat("sight", 0.0f);
hearing = aiElement.GetAttributeFloat("hearing", 0.0f);
attackWhenProvoked = ToolBox.GetAttributeBool(aiElement, "attackwhenprovoked", false);
attackWhenProvoked = aiElement.GetAttributeBool("attackwhenprovoked", false);
fleeHealthThreshold = ToolBox.GetAttributeFloat(aiElement, "fleehealththreshold", 0.0f);
fleeHealthThreshold = aiElement.GetAttributeFloat("fleehealththreshold", 0.0f);
attachToWalls = ToolBox.GetAttributeBool(aiElement, "attachtowalls", false);
attachToWalls = aiElement.GetAttributeBool("attachtowalls", false);
outsideSteering = new SteeringManager(this);
insideSteering = new IndoorsSteeringManager(this, false);
@@ -33,7 +33,7 @@ namespace Barotrauma
{
PrefabList = new List<Order>();
XDocument doc = ToolBox.TryLoadXml(ConfigFile);
XDocument doc = XMLExtensions.TryLoadXml(ConfigFile);
if (doc == null || doc.Root == null) return;
foreach (XElement orderElement in doc.Root.Elements())
@@ -57,10 +57,10 @@ namespace Barotrauma
private Order(XElement orderElement)
{
Name = ToolBox.GetAttributeString(orderElement, "name", "Name not found");
DoingText = ToolBox.GetAttributeString(orderElement, "doingtext", "");
Name = orderElement.GetAttributeString("name", "Name not found");
DoingText = orderElement.GetAttributeString("doingtext", "");
string targetItemName = ToolBox.GetAttributeString(orderElement, "targetitemtype", "");
string targetItemName = orderElement.GetAttributeString("targetitemtype", "");
if (!string.IsNullOrWhiteSpace(targetItemName))
{
@@ -75,13 +75,13 @@ namespace Barotrauma
}
}
ItemName = ToolBox.GetAttributeString(orderElement, "targetitemname", "");
ItemName = orderElement.GetAttributeString("targetitemname", "");
Color = new Color(ToolBox.GetAttributeVector4(orderElement, "color", new Vector4(1.0f, 1.0f, 1.0f, 1.0f)));
Color = new Color(orderElement.GetAttributeVector4("color", new Vector4(1.0f, 1.0f, 1.0f, 1.0f)));
UseController = ToolBox.GetAttributeBool(orderElement, "usecontroller", false);
UseController = orderElement.GetAttributeBool("usecontroller", false);
string optionStr = ToolBox.GetAttributeString(orderElement, "options", "");
string optionStr = orderElement.GetAttributeString("options", "");
if (string.IsNullOrWhiteSpace(optionStr))
{