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))
{
@@ -48,16 +48,16 @@ namespace Barotrauma
{
this.character = character;
stepSize = ToolBox.GetAttributeVector2(element, "stepsize", Vector2.One);
stepSize = element.GetAttributeVector2("stepsize", Vector2.One);
stepSize = ConvertUnits.ToSimUnits(stepSize);
walkSpeed = ToolBox.GetAttributeFloat(element, "walkspeed", 1.0f);
swimSpeed = ToolBox.GetAttributeFloat(element, "swimspeed", 1.0f);
walkSpeed = element.GetAttributeFloat("walkspeed", 1.0f);
swimSpeed = element.GetAttributeFloat("swimspeed", 1.0f);
RunSpeedMultiplier = ToolBox.GetAttributeFloat(element, "runspeedmultiplier", 2f);
SwimSpeedMultiplier = ToolBox.GetAttributeFloat(element, "swimspeedmultiplier", 1.5f);
RunSpeedMultiplier = element.GetAttributeFloat("runspeedmultiplier", 2f);
SwimSpeedMultiplier = element.GetAttributeFloat("swimspeedmultiplier", 1.5f);
legTorque = ToolBox.GetAttributeFloat(element, "legtorque", 0.0f);
legTorque = element.GetAttributeFloat("legtorque", 0.0f);
}
public virtual void UpdateAnim(float deltaTime) { }
@@ -28,15 +28,15 @@ namespace Barotrauma
public FishAnimController(Character character, XElement element)
: base(character, element)
{
waveAmplitude = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "waveamplitude", 0.0f));
waveLength = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "wavelength", 0.0f));
waveAmplitude = ConvertUnits.ToSimUnits(element.GetAttributeFloat("waveamplitude", 0.0f));
waveLength = ConvertUnits.ToSimUnits(element.GetAttributeFloat("wavelength", 0.0f));
steerTorque = ToolBox.GetAttributeFloat(element, "steertorque", 25.0f);
steerTorque = element.GetAttributeFloat("steertorque", 25.0f);
flip = ToolBox.GetAttributeBool(element, "flip", true);
mirror = ToolBox.GetAttributeBool(element, "mirror", false);
flip = element.GetAttributeBool("flip", true);
mirror = element.GetAttributeBool("mirror", false);
float footRot = ToolBox.GetAttributeFloat(element, "footrotation", float.NaN);
float footRot = element.GetAttributeFloat("footrotation", float.NaN);
if (float.IsNaN(footRot))
{
footRotation = null;
@@ -46,7 +46,7 @@ namespace Barotrauma
footRotation = MathHelper.ToRadians(footRot);
}
rotateTowardsMovement = ToolBox.GetAttributeBool(element, "rotatetowardsmovement", true);
rotateTowardsMovement = element.GetAttributeBool("rotatetowardsmovement", true);
}
public override void UpdateAnim(float deltaTime)
@@ -63,12 +63,12 @@ namespace Barotrauma
public HumanoidAnimController(Character character, XElement element)
: base(character, element)
{
walkAnimSpeed = ToolBox.GetAttributeFloat(element, "walkanimspeed", 4.0f);
walkAnimSpeed = element.GetAttributeFloat("walkanimspeed", 4.0f);
walkAnimSpeed = MathHelper.ToRadians(walkAnimSpeed);
movementLerp = ToolBox.GetAttributeFloat(element, "movementlerp", 0.4f);
movementLerp = element.GetAttributeFloat("movementlerp", 0.4f);
thighTorque = ToolBox.GetAttributeFloat(element, "thightorque", -5.0f);
thighTorque = element.GetAttributeFloat("thightorque", -5.0f);
}
public override void UpdateAnim(float deltaTime)
@@ -279,25 +279,25 @@ namespace Barotrauma
dir = Direction.Right;
float scale = ToolBox.GetAttributeFloat(element, "scale", 1.0f);
float scale = element.GetAttributeFloat("scale", 1.0f);
Limbs = new Limb[element.Elements("limb").Count()];
LimbJoints = new LimbJoint[element.Elements("joint").Count()];
limbDictionary = new Dictionary<LimbType, Limb>();
headPosition = ToolBox.GetAttributeFloat(element, "headposition", 50.0f);
headPosition = element.GetAttributeFloat("headposition", 50.0f);
headPosition = ConvertUnits.ToSimUnits(headPosition);
headAngle = MathHelper.ToRadians(ToolBox.GetAttributeFloat(element, "headangle", 0.0f));
headAngle = MathHelper.ToRadians(element.GetAttributeFloat("headangle", 0.0f));
torsoPosition = ToolBox.GetAttributeFloat(element, "torsoposition", 50.0f);
torsoPosition = element.GetAttributeFloat("torsoposition", 50.0f);
torsoPosition = ConvertUnits.ToSimUnits(torsoPosition);
torsoAngle = MathHelper.ToRadians(ToolBox.GetAttributeFloat(element, "torsoangle", 0.0f));
torsoAngle = MathHelper.ToRadians(element.GetAttributeFloat("torsoangle", 0.0f));
ImpactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 50.0f);
ImpactTolerance = element.GetAttributeFloat("impacttolerance", 50.0f);
CanEnterSubmarine = ToolBox.GetAttributeBool(element, "canentersubmarine", true);
CanEnterSubmarine = element.GetAttributeBool("canentersubmarine", true);
colliderHeightFromFloor = ToolBox.GetAttributeFloat(element, "colliderheightfromfloor", 45.0f);
colliderHeightFromFloor = element.GetAttributeFloat("colliderheightfromfloor", 45.0f);
colliderHeightFromFloor = ConvertUnits.ToSimUnits(colliderHeightFromFloor);
collider = new List<PhysicsBody>();
@@ -382,14 +382,14 @@ namespace Barotrauma
byte limb1ID = Convert.ToByte(subElement.Attribute("limb1").Value);
byte limb2ID = Convert.ToByte(subElement.Attribute("limb2").Value);
Vector2 limb1Pos = ToolBox.GetAttributeVector2(subElement, "limb1anchor", Vector2.Zero) * scale;
Vector2 limb1Pos = subElement.GetAttributeVector2("limb1anchor", Vector2.Zero) * scale;
limb1Pos = ConvertUnits.ToSimUnits(limb1Pos);
Vector2 limb2Pos = ToolBox.GetAttributeVector2(subElement, "limb2anchor", Vector2.Zero) * scale;
Vector2 limb2Pos = subElement.GetAttributeVector2("limb2anchor", Vector2.Zero) * scale;
limb2Pos = ConvertUnits.ToSimUnits(limb2Pos);
LimbJoint joint = new LimbJoint(Limbs[limb1ID], Limbs[limb2ID], limb1Pos, limb2Pos);
joint.CanBeSevered = ToolBox.GetAttributeBool(subElement, "canbesevered", true);
joint.CanBeSevered = subElement.GetAttributeBool("canbesevered", true);
if (subElement.Attribute("lowerlimit") != null)
{
@@ -87,34 +87,34 @@ namespace Barotrauma
{
try
{
DamageType = (DamageType)Enum.Parse(typeof(DamageType), ToolBox.GetAttributeString(element, "damagetype", "None"), true);
DamageType = (DamageType)Enum.Parse(typeof(DamageType), element.GetAttributeString("damagetype", "None"), true);
}
catch
{
DamageType = DamageType.None;
}
damage = ToolBox.GetAttributeFloat(element, "damage", 0.0f);
structureDamage = ToolBox.GetAttributeFloat(element, "structuredamage", 0.0f);
bleedingDamage = ToolBox.GetAttributeFloat(element, "bleedingdamage", 0.0f);
Stun = ToolBox.GetAttributeFloat(element, "stun", 0.0f);
damage = element.GetAttributeFloat("damage", 0.0f);
structureDamage = element.GetAttributeFloat("structuredamage", 0.0f);
bleedingDamage = element.GetAttributeFloat("bleedingdamage", 0.0f);
Stun = element.GetAttributeFloat("stun", 0.0f);
SeverLimbsProbability = ToolBox.GetAttributeFloat(element, "severlimbsprobability", 0.0f);
SeverLimbsProbability = element.GetAttributeFloat("severlimbsprobability", 0.0f);
Force = ToolBox.GetAttributeFloat(element, "force", 0.0f);
TargetForce = ToolBox.GetAttributeFloat(element, "targetforce", 0.0f);
Torque = ToolBox.GetAttributeFloat(element, "torque", 0.0f);
Force = element.GetAttributeFloat("force", 0.0f);
TargetForce = element.GetAttributeFloat("targetforce", 0.0f);
Torque = element.GetAttributeFloat("torque", 0.0f);
Range = ToolBox.GetAttributeFloat(element, "range", 0.0f);
Duration = ToolBox.GetAttributeFloat(element, "duration", 0.0f);
Range = element.GetAttributeFloat("range", 0.0f);
Duration = element.GetAttributeFloat("duration", 0.0f);
priority = ToolBox.GetAttributeFloat(element, "priority", 1.0f);
priority = element.GetAttributeFloat("priority", 1.0f);
onlyHumans = ToolBox.GetAttributeBool(element, "onlyhumans", false);
onlyHumans = element.GetAttributeBool("onlyhumans", false);
InitProjSpecific(element);
string limbIndicesStr = ToolBox.GetAttributeString(element, "applyforceonlimbs", "");
string limbIndicesStr = element.GetAttributeString("applyforceonlimbs", "");
if (!string.IsNullOrWhiteSpace(limbIndicesStr))
{
ApplyForceOnLimbs = new List<int>();
@@ -545,14 +545,14 @@ namespace Barotrauma
Info = new CharacterInfo(file);
}
XDocument doc = ToolBox.TryLoadXml(file);
XDocument doc = XMLExtensions.TryLoadXml(file);
if (doc == null || doc.Root == null) return;
InitProjSpecific(doc);
SpeciesName = ToolBox.GetAttributeString(doc.Root, "name", "Unknown");
SpeciesName = doc.Root.GetAttributeString("name", "Unknown");
IsHumanoid = ToolBox.GetAttributeBool(doc.Root, "humanoid", false);
IsHumanoid = doc.Root.GetAttributeBool("humanoid", false);
if (IsHumanoid)
{
@@ -568,14 +568,14 @@ namespace Barotrauma
AnimController.SetPosition(ConvertUnits.ToSimUnits(position));
maxHealth = ToolBox.GetAttributeFloat(doc.Root, "health", 100.0f);
maxHealth = doc.Root.GetAttributeFloat("health", 100.0f);
health = maxHealth;
DoesBleed = ToolBox.GetAttributeBool(doc.Root, "doesbleed", true);
BleedingDecreaseSpeed = ToolBox.GetAttributeFloat(doc.Root, "bleedingdecreasespeed", 0.05f);
DoesBleed = doc.Root.GetAttributeBool("doesbleed", true);
BleedingDecreaseSpeed = doc.Root.GetAttributeFloat("bleedingdecreasespeed", 0.05f);
needsAir = ToolBox.GetAttributeBool(doc.Root, "needsair", false);
drowningTime = ToolBox.GetAttributeFloat(doc.Root, "drowningtime", 10.0f);
needsAir = doc.Root.GetAttributeBool("needsair", false);
drowningTime = doc.Root.GetAttributeFloat("drowningtime", 10.0f);
if (file == humanConfigFile)
{
@@ -105,14 +105,14 @@ namespace Barotrauma
//ID = -1;
XDocument doc = ToolBox.TryLoadXml(file);
XDocument doc = XMLExtensions.TryLoadXml(file);
if (doc == null) return;
if (ToolBox.GetAttributeBool(doc.Root, "genders", false))
if (doc.Root.GetAttributeBool("genders", false))
{
if (gender == Gender.None)
{
float femaleRatio = ToolBox.GetAttributeFloat(doc.Root, "femaleratio", 0.5f);
float femaleRatio = doc.Root.GetAttributeFloat("femaleratio", 0.5f);
this.gender = (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < femaleRatio) ? Gender.Female : Gender.Male;
}
else
@@ -121,12 +121,12 @@ namespace Barotrauma
}
}
headSpriteRange[0] = ToolBox.GetAttributeVector2(doc.Root, "headid", Vector2.Zero);
headSpriteRange[0] = doc.Root.GetAttributeVector2("headid", Vector2.Zero);
headSpriteRange[1] = headSpriteRange[0];
if (headSpriteRange[0] == Vector2.Zero)
{
headSpriteRange[0] = ToolBox.GetAttributeVector2(doc.Root, "maleheadid", Vector2.Zero);
headSpriteRange[1] = ToolBox.GetAttributeVector2(doc.Root, "femaleheadid", Vector2.Zero);
headSpriteRange[0] = doc.Root.GetAttributeVector2("maleheadid", Vector2.Zero);
headSpriteRange[1] = doc.Root.GetAttributeVector2("femaleheadid", Vector2.Zero);
}
int genderIndex = (this.gender == Gender.Female) ? 1 : 0;
@@ -147,14 +147,14 @@ namespace Barotrauma
if (doc.Root.Element("name") != null)
{
string firstNamePath = ToolBox.GetAttributeString(doc.Root.Element("name"), "firstname", "");
string firstNamePath = doc.Root.Element("name").GetAttributeString("firstname", "");
if (firstNamePath != "")
{
firstNamePath = firstNamePath.Replace("[GENDER]", (this.gender == Gender.Female) ? "f" : "");
this.Name = ToolBox.GetRandomLine(firstNamePath);
}
string lastNamePath = ToolBox.GetAttributeString(doc.Root.Element("name"), "lastname", "");
string lastNamePath = doc.Root.Element("name").GetAttributeString("lastname", "");
if (lastNamePath != "")
{
lastNamePath = lastNamePath.Replace("[GENDER]", (this.gender == Gender.Female) ? "f" : "");
@@ -168,13 +168,13 @@ namespace Barotrauma
private void LoadHeadSprite()
{
XDocument doc = ToolBox.TryLoadXml(File);
XDocument doc = XMLExtensions.TryLoadXml(File);
if (doc == null) return;
XElement ragdollElement = doc.Root.Element("ragdoll");
foreach (XElement limbElement in ragdollElement.Elements())
{
if (ToolBox.GetAttributeString(limbElement, "type", "").ToLowerInvariant() != "head") continue;
if (limbElement.GetAttributeString("type", "").ToLowerInvariant() != "head") continue;
XElement spriteElement = limbElement.Element("sprite");
@@ -221,22 +221,22 @@ namespace Barotrauma
public CharacterInfo(XElement element)
{
Name = ToolBox.GetAttributeString(element, "name", "unnamed");
Name = element.GetAttributeString("name", "unnamed");
string genderStr = ToolBox.GetAttributeString(element, "gender", "male").ToLowerInvariant();
string genderStr = element.GetAttributeString("gender", "male").ToLowerInvariant();
gender = (genderStr == "m") ? Gender.Male : Gender.Female;
File = ToolBox.GetAttributeString(element, "file", "");
Salary = ToolBox.GetAttributeInt(element, "salary", 1000);
headSpriteId = ToolBox.GetAttributeInt(element, "headspriteid", 1);
StartItemsGiven = ToolBox.GetAttributeBool(element, "startitemsgiven", false);
File = element.GetAttributeString("file", "");
Salary = element.GetAttributeInt("salary", 1000);
headSpriteId = element.GetAttributeInt("headspriteid", 1);
StartItemsGiven = element.GetAttributeBool("startitemsgiven", false);
int hullId = ToolBox.GetAttributeInt(element, "hull", -1);
int hullId = element.GetAttributeInt("hull", -1);
if (hullId > 0 && hullId <= ushort.MaxValue) this.HullID = (ushort)hullId;
pickedItems = new List<ushort>();
string pickedItemString = ToolBox.GetAttributeString(element, "items", "");
string pickedItemString = element.GetAttributeString("items", "");
if (!string.IsNullOrEmpty(pickedItemString))
{
string[] itemIds = pickedItemString.Split(',');
@@ -23,7 +23,7 @@ namespace Barotrauma
public DelayedEffect(XElement element)
: base(element)
{
delay = ToolBox.GetAttributeFloat(element, "delay", 1.0f);
delay = element.GetAttributeFloat("delay", 1.0f);
}
public override void Apply(ActionType type, float deltaTime, Entity entity, List<IPropertyObject> targets)
@@ -100,7 +100,7 @@ namespace Barotrauma
private void AttachHuskAppendage(Character character)
{
XDocument doc = ToolBox.TryLoadXml(Path.Combine("Content", "Characters", "Human", "huskappendage.xml"));
XDocument doc = XMLExtensions.TryLoadXml(Path.Combine("Content", "Characters", "Human", "huskappendage.xml"));
if (doc == null || doc.Root == null) return;
var limbElement = doc.Root.Element("limb");
@@ -54,18 +54,18 @@ namespace Barotrauma
public Job(XElement element)
{
string name = ToolBox.GetAttributeString(element, "name", "").ToLowerInvariant();
string name = element.GetAttributeString("name", "").ToLowerInvariant();
prefab = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == name);
skills = new Dictionary<string, Skill>();
foreach (XElement subElement in element.Elements())
{
if (subElement.Name.ToString().ToLowerInvariant() != "skill") continue;
string skillName = ToolBox.GetAttributeString(subElement, "name", "");
string skillName = subElement.GetAttributeString("name", "");
if (string.IsNullOrEmpty(name)) continue;
skills.Add(
skillName,
new Skill(skillName, ToolBox.GetAttributeInt(subElement, "level", 0)));
new Skill(skillName, subElement.GetAttributeInt("level", 0)));
}
}
@@ -96,7 +96,7 @@ namespace Barotrauma
private void InitializeJobItem(Character character, WayPoint spawnPoint, XElement itemElement, Item parentItem = null)
{
string itemName = ToolBox.GetAttributeString(itemElement, "name", "");
string itemName = itemElement.GetAttributeString("name", "");
ItemPrefab itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
if (itemPrefab == null)
@@ -112,7 +112,7 @@ namespace Barotrauma
Entity.Spawner.CreateNetworkEvent(item, false);
}
if (ToolBox.GetAttributeBool(itemElement, "equip", false))
if (itemElement.GetAttributeBool("equip", false))
{
List<InvSlotType> allowedSlots = new List<InvSlotType>(item.AllowedSlots);
allowedSlots.Remove(InvSlotType.Any);
@@ -55,16 +55,16 @@ namespace Barotrauma
public JobPrefab(XElement element)
{
Name = ToolBox.GetAttributeString(element, "name", "name not found");
Name = element.GetAttributeString("name", "name not found");
Description = ToolBox.GetAttributeString(element, "description", "");
Description = element.GetAttributeString("description", "");
MinNumber = ToolBox.GetAttributeInt(element, "minnumber", 0);
MaxNumber = ToolBox.GetAttributeInt(element, "maxnumber", 10);
MinNumber = element.GetAttributeInt("minnumber", 0);
MaxNumber = element.GetAttributeInt("maxnumber", 10);
Commonness = ToolBox.GetAttributeInt(element, "commonness", 10);
Commonness = element.GetAttributeInt("commonness", 10);
AllowAlways = ToolBox.GetAttributeBool(element, "allowalways", false);
AllowAlways = element.GetAttributeBool("allowalways", false);
ItemNames = new List<string>();
@@ -78,7 +78,7 @@ namespace Barotrauma
Items = subElement;
foreach (XElement itemElement in subElement.Elements())
{
string itemName = ToolBox.GetAttributeString(itemElement, "name", "");
string itemName = itemElement.GetAttributeString("name", "");
if (!string.IsNullOrWhiteSpace(itemName)) ItemNames.Add(itemName);
}
break;
@@ -105,7 +105,7 @@ namespace Barotrauma
foreach (string filePath in filePaths)
{
XDocument doc = ToolBox.TryLoadXml(filePath);
XDocument doc = XMLExtensions.TryLoadXml(filePath);
if (doc == null || doc.Root == null) return;
foreach (XElement element in doc.Root.Elements())
@@ -28,12 +28,12 @@ namespace Barotrauma
public SkillPrefab(XElement element)
{
name = ToolBox.GetAttributeString(element, "name", "");
name = element.GetAttributeString("name", "");
var levelString = ToolBox.GetAttributeString(element, "level", "");
var levelString = element.GetAttributeString("level", "");
if (levelString.Contains(","))
{
levelRange = ToolBox.ParseToVector2(levelString, false);
levelRange = XMLExtensions.ParseToVector2(levelString, false);
}
else
{
@@ -195,13 +195,13 @@ namespace Barotrauma
dir = Direction.Right;
doesFlip = ToolBox.GetAttributeBool(element, "flip", false);
doesFlip = element.GetAttributeBool("flip", false);
this.scale = scale;
body = new PhysicsBody(element, scale);
if (ToolBox.GetAttributeBool(element, "ignorecollisions", false))
if (element.GetAttributeBool("ignorecollisions", false))
{
body.CollisionCategories = Category.None;
body.CollidesWith = Category.None;
@@ -234,13 +234,13 @@ namespace Barotrauma
}
pullJointPos = ToolBox.GetAttributeVector2(element, "pullpos", Vector2.Zero) * scale;
pullJointPos = element.GetAttributeVector2("pullpos", Vector2.Zero) * scale;
pullJointPos = ConvertUnits.ToSimUnits(pullJointPos);
stepOffset = ToolBox.GetAttributeVector2(element, "stepoffset", Vector2.Zero) * scale;
stepOffset = element.GetAttributeVector2("stepoffset", Vector2.Zero) * scale;
stepOffset = ConvertUnits.ToSimUnits(stepOffset);
refJointIndex = ToolBox.GetAttributeInt(element, "refjoint", -1);
refJointIndex = element.GetAttributeInt("refjoint", -1);
}
else
@@ -254,19 +254,19 @@ namespace Barotrauma
GameMain.World.AddJoint(pullJoint);
steerForce = ToolBox.GetAttributeFloat(element, "steerforce", 0.0f);
steerForce = element.GetAttributeFloat("steerforce", 0.0f);
//maxHealth = Math.Max(ToolBox.GetAttributeFloat(element, "health", 100.0f),1.0f);
armorSector = ToolBox.GetAttributeVector2(element, "armorsector", Vector2.Zero);
armorSector = element.GetAttributeVector2("armorsector", Vector2.Zero);
armorSector.X = MathHelper.ToRadians(armorSector.X);
armorSector.Y = MathHelper.ToRadians(armorSector.Y);
armorValue = Math.Max(ToolBox.GetAttributeFloat(element, "armor", 0.0f), 0.0f);
armorValue = Math.Max(element.GetAttributeFloat("armor", 0.0f), 0.0f);
if (element.Attribute("mouthpos") != null)
{
MouthPos = ConvertUnits.ToSimUnits(ToolBox.GetAttributeVector2(element, "mouthpos", Vector2.Zero));
MouthPos = ConvertUnits.ToSimUnits(element.GetAttributeVector2("mouthpos", Vector2.Zero));
}
body.BodyType = BodyType.Dynamic;
@@ -117,10 +117,10 @@ namespace Barotrauma
break;
case "disabledeltatime":
disableDeltaTime = ToolBox.GetAttributeBool(attribute, false);
disableDeltaTime = attribute.GetAttributeBool(false);
break;
case "setvalue":
setValue = ToolBox.GetAttributeBool(attribute, false);
setValue = attribute.GetAttributeBool(false);
break;
case "targetnames":
string[] names = attribute.Value.Split(',');
@@ -131,7 +131,7 @@ namespace Barotrauma
}
break;
case "duration":
duration = ToolBox.GetAttributeFloat(attribute, 0.0f);
duration = attribute.GetAttributeFloat(0.0f);
break;
case "sound":
DebugConsole.ThrowError("Error in StatusEffect " + element.Parent.Name.ToString() +
@@ -151,7 +151,7 @@ namespace Barotrauma
foreach (XAttribute attribute in propertyAttributes)
{
propertyNames[n] = attribute.Name.ToString().ToLowerInvariant();
propertyEffects[n] = ToolBox.GetAttributeObject(attribute);
propertyEffects[n] = XMLExtensions.GetAttributeObject(attribute);
n++;
}
@@ -163,7 +163,7 @@ namespace Barotrauma
explosion = new Explosion(subElement);
break;
case "fire":
FireSize = ToolBox.GetAttributeFloat(subElement,"size",10.0f);
FireSize = subElement.GetAttributeFloat("size",10.0f);
break;
case "use":
case "useitem":
@@ -183,7 +183,7 @@ namespace Barotrauma
break;
case "sound":
sound = Sound.Load(subElement);
loopSound = ToolBox.GetAttributeBool(subElement, "loop", false);
loopSound = subElement.GetAttributeBool("loop", false);
break;
#endif
}