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
@@ -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)
{