Converted the GetAttribute methods in the ToolBox class to extension methods
This commit is contained in:
@@ -50,8 +50,8 @@ namespace Barotrauma.Items.Components
|
||||
[HasDefaultValue("32.0,32.0", false)]
|
||||
public string DistanceTolerance
|
||||
{
|
||||
get { return ToolBox.Vector2ToString(distanceTolerance); }
|
||||
set { distanceTolerance = ToolBox.ParseToVector2(value); }
|
||||
get { return XMLExtensions.Vector2ToString(distanceTolerance); }
|
||||
set { distanceTolerance = XMLExtensions.ParseToVector2(value); }
|
||||
}
|
||||
|
||||
[HasDefaultValue(32.0f, false)]
|
||||
@@ -104,7 +104,7 @@ namespace Barotrauma.Items.Components
|
||||
// isOpen = false;
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
string texturePath = ToolBox.GetAttributeString(subElement, "texture", "");
|
||||
string texturePath = subElement.GetAttributeString("texture", "");
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "sprite":
|
||||
|
||||
@@ -91,11 +91,11 @@ namespace Barotrauma.Items.Components
|
||||
[HasDefaultValue("0.0,0.0,0.0,0.0", false)]
|
||||
public string Window
|
||||
{
|
||||
get { return ToolBox.Vector4ToString(new Vector4(window.X, window.Y, window.Width, window.Height)); }
|
||||
get { return XMLExtensions.Vector4ToString(new Vector4(window.X, window.Y, window.Width, window.Height)); }
|
||||
set
|
||||
{
|
||||
Vector4 vector = ToolBox.ParseToVector4(value);
|
||||
if (vector.Z!=0.0f || vector.W !=0.0f)
|
||||
Vector4 vector = XMLExtensions.ParseToVector4(value);
|
||||
if (vector.Z != 0.0f || vector.W != 0.0f)
|
||||
{
|
||||
window = new Rectangle((int)vector.X, (int)vector.Y, (int)vector.Z, (int)vector.W);
|
||||
}
|
||||
@@ -141,12 +141,12 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
//Vector2 position = new Vector2(newRect.X, newRect.Y);
|
||||
|
||||
isHorizontal = ToolBox.GetAttributeBool(element, "horizontal", false);
|
||||
isHorizontal = element.GetAttributeBool("horizontal", false);
|
||||
|
||||
// isOpen = false;
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
string texturePath = ToolBox.GetAttributeString(subElement, "texture", "");
|
||||
string texturePath = subElement.GetAttributeString("texture", "");
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "sprite":
|
||||
|
||||
@@ -60,15 +60,15 @@ namespace Barotrauma.Items.Components
|
||||
[HasDefaultValue("0.0,0.0", false)]
|
||||
public string HoldPos
|
||||
{
|
||||
get { return ToolBox.Vector2ToString(ConvertUnits.ToDisplayUnits(holdPos)); }
|
||||
set { holdPos = ConvertUnits.ToSimUnits(ToolBox.ParseToVector2(value)); }
|
||||
get { return XMLExtensions.Vector2ToString(ConvertUnits.ToDisplayUnits(holdPos)); }
|
||||
set { holdPos = ConvertUnits.ToSimUnits(XMLExtensions.ParseToVector2(value)); }
|
||||
}
|
||||
|
||||
[HasDefaultValue("0.0,0.0", false)]
|
||||
public string AimPos
|
||||
{
|
||||
get { return ToolBox.Vector2ToString(ConvertUnits.ToDisplayUnits(aimPos)); }
|
||||
set { aimPos = ConvertUnits.ToSimUnits(ToolBox.ParseToVector2(value)); }
|
||||
get { return XMLExtensions.Vector2ToString(ConvertUnits.ToDisplayUnits(aimPos)); }
|
||||
set { aimPos = ConvertUnits.ToSimUnits(XMLExtensions.ParseToVector2(value)); }
|
||||
}
|
||||
|
||||
[HasDefaultValue(0.0f, false)]
|
||||
@@ -87,7 +87,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
handlePos[i - 1] = ToolBox.GetAttributeVector2(element, "handle" + i, Vector2.Zero);
|
||||
handlePos[i - 1] = element.GetAttributeVector2("handle" + i, Vector2.Zero);
|
||||
|
||||
handlePos[i - 1] = ConvertUnits.ToSimUnits(handlePos[i - 1]);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
allowedSlots = new List<InvSlotType>();
|
||||
|
||||
string slotString = ToolBox.GetAttributeString(element, "slots", "Any");
|
||||
string slotString = element.GetAttributeString("slots", "Any");
|
||||
string[] slotCombinations = slotString.Split(',');
|
||||
foreach (string slotCombination in slotCombinations)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Barotrauma.Items.Components
|
||||
public Propulsion(Item item, XElement element)
|
||||
: base(item,element)
|
||||
{
|
||||
switch (ToolBox.GetAttributeString(element, "usablein", "both").ToLowerInvariant())
|
||||
switch (element.GetAttributeString("usablein", "both").ToLowerInvariant())
|
||||
{
|
||||
case "air":
|
||||
usableIn = UsableIn.Air;
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace Barotrauma.Items.Components
|
||||
[HasDefaultValue("0.0,0.0", false)]
|
||||
public string BarrelPos
|
||||
{
|
||||
get { return ToolBox.Vector2ToString(ConvertUnits.ToDisplayUnits(barrelPos)); }
|
||||
set { barrelPos = ConvertUnits.ToSimUnits(ToolBox.ParseToVector2(value)); }
|
||||
get { return XMLExtensions.Vector2ToString(ConvertUnits.ToDisplayUnits(barrelPos)); }
|
||||
set { barrelPos = ConvertUnits.ToSimUnits(XMLExtensions.ParseToVector2(value)); }
|
||||
}
|
||||
|
||||
[HasDefaultValue(1.0f, false)]
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace Barotrauma.Items.Components
|
||||
[HasDefaultValue("0.0,0.0", false)]
|
||||
public string BarrelPos
|
||||
{
|
||||
get { return ToolBox.Vector2ToString(barrelPos); }
|
||||
set { barrelPos = ToolBox.ParseToVector2(value); }
|
||||
get { return XMLExtensions.Vector2ToString(barrelPos); }
|
||||
set { barrelPos = XMLExtensions.ParseToVector2(value); }
|
||||
}
|
||||
|
||||
public Vector2 TransformedBarrelPos
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
try
|
||||
{
|
||||
string selectKeyStr = ToolBox.GetAttributeString(element, "selectkey", "Select");
|
||||
string selectKeyStr = element.GetAttributeString("selectkey", "Select");
|
||||
selectKeyStr = ToolBox.ConvertInputType(selectKeyStr);
|
||||
SelectKey = (InputType)Enum.Parse(typeof(InputType), selectKeyStr, true);
|
||||
}
|
||||
@@ -196,7 +196,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
try
|
||||
{
|
||||
string pickKeyStr = ToolBox.GetAttributeString(element, "selectkey", "Select");
|
||||
string pickKeyStr = element.GetAttributeString("selectkey", "Select");
|
||||
pickKeyStr = ToolBox.ConvertInputType(pickKeyStr);
|
||||
PickKey = (InputType)Enum.Parse(typeof(InputType),pickKeyStr, true);
|
||||
}
|
||||
@@ -219,8 +219,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
case "requiredskill":
|
||||
case "requiredskills":
|
||||
string skillName = ToolBox.GetAttributeString(subElement, "name", "");
|
||||
requiredSkills.Add(new Skill(skillName, ToolBox.GetAttributeInt(subElement, "level", 0)));
|
||||
string skillName = subElement.GetAttributeString("name", "");
|
||||
requiredSkills.Add(new Skill(skillName, subElement.GetAttributeInt("level", 0)));
|
||||
break;
|
||||
case "statuseffect":
|
||||
var statusEffect = StatusEffect.Load(subElement);
|
||||
|
||||
@@ -50,8 +50,8 @@ namespace Barotrauma.Items.Components
|
||||
[HasDefaultValue("0.0,0.0", false)]
|
||||
public string ItemPos
|
||||
{
|
||||
get { return ToolBox.Vector2ToString(itemPos); }
|
||||
set { itemPos = ToolBox.ParseToVector2(value); }
|
||||
get { return XMLExtensions.Vector2ToString(itemPos); }
|
||||
set { itemPos = XMLExtensions.ParseToVector2(value); }
|
||||
}
|
||||
private Vector2 itemPos;
|
||||
|
||||
@@ -59,8 +59,8 @@ namespace Barotrauma.Items.Components
|
||||
[HasDefaultValue("0.0,0.0", false)]
|
||||
public string ItemInterval
|
||||
{
|
||||
get { return ToolBox.Vector2ToString(itemInterval); }
|
||||
set { itemInterval = ToolBox.ParseToVector2(value); }
|
||||
get { return XMLExtensions.Vector2ToString(itemInterval); }
|
||||
set { itemInterval = XMLExtensions.ParseToVector2(value); }
|
||||
}
|
||||
private Vector2 itemInterval;
|
||||
|
||||
@@ -76,10 +76,10 @@ namespace Barotrauma.Items.Components
|
||||
[HasDefaultValue("0.5,0.9", false)]
|
||||
public string HudPos
|
||||
{
|
||||
get { return ToolBox.Vector2ToString(hudPos); }
|
||||
get { return XMLExtensions.Vector2ToString(hudPos); }
|
||||
set
|
||||
{
|
||||
hudPos = ToolBox.ParseToVector2(value);
|
||||
hudPos = XMLExtensions.ParseToVector2(value);
|
||||
//inventory.CenterPos = hudPos;
|
||||
}
|
||||
}
|
||||
@@ -228,7 +228,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
base.Load(componentElement);
|
||||
|
||||
string containedString = ToolBox.GetAttributeString(componentElement, "contained", "");
|
||||
string containedString = componentElement.GetAttributeString("contained", "");
|
||||
|
||||
string[] itemIdStrings = containedString.Split(',');
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
limbPositions = new List<LimbPos>();
|
||||
|
||||
userPos = ToolBox.GetAttributeVector2(element, "UserPos", Vector2.Zero);
|
||||
userPos = element.GetAttributeVector2("UserPos", Vector2.Zero);
|
||||
|
||||
Enum.TryParse<Direction>(ToolBox.GetAttributeString(element, "direction", "None"), out dir);
|
||||
Enum.TryParse<Direction>(element.GetAttributeString("direction", "None"), out dir);
|
||||
|
||||
foreach (XElement el in element.Elements())
|
||||
{
|
||||
@@ -63,7 +63,7 @@ namespace Barotrauma.Items.Components
|
||||
DebugConsole.ThrowError("Error in " + element + ": " + e.Message, e);
|
||||
}
|
||||
|
||||
lp.position = ToolBox.GetAttributeVector2(el, "position", Vector2.Zero);
|
||||
lp.position = el.GetAttributeVector2("position", Vector2.Zero);
|
||||
|
||||
limbPositions.Add(lp);
|
||||
}
|
||||
@@ -189,7 +189,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (focusTarget == null)
|
||||
{
|
||||
item.SendSignal(0, ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out", character);
|
||||
item.SendSignal(0, XMLExtensions.Vector2ToString(character.CursorWorldPosition), "position_out", character);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (!character.IsRemotePlayer || character.ViewTarget == focusTarget)
|
||||
{
|
||||
item.SendSignal(0, ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out", character);
|
||||
item.SendSignal(0, XMLExtensions.Vector2ToString(character.CursorWorldPosition), "position_out", character);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public FabricableItem(XElement element)
|
||||
{
|
||||
string name = ToolBox.GetAttributeString(element, "name", "");
|
||||
string name = element.GetAttributeString("name", "");
|
||||
|
||||
TargetItem = ItemPrefab.list.Find(ip => ip.Name.ToLowerInvariant() == name.ToLowerInvariant()) as ItemPrefab;
|
||||
if (TargetItem == null)
|
||||
@@ -31,11 +31,11 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
RequiredSkills = new List<Skill>();
|
||||
|
||||
RequiredTime = ToolBox.GetAttributeFloat(element, "requiredtime", 1.0f);
|
||||
RequiredTime = element.GetAttributeFloat("requiredtime", 1.0f);
|
||||
|
||||
RequiredItems = new List<Tuple<ItemPrefab, int>>();
|
||||
|
||||
string[] requiredItemNames = ToolBox.GetAttributeString(element, "requireditems", "").Split(',');
|
||||
string[] requiredItemNames = element.GetAttributeString("requireditems", "").Split(',');
|
||||
foreach (string requiredItemName in requiredItemNames)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(requiredItemName)) continue;
|
||||
@@ -68,8 +68,8 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
case "requiredskill":
|
||||
RequiredSkills.Add(new Skill(
|
||||
ToolBox.GetAttributeString(subElement, "name", ""),
|
||||
ToolBox.GetAttributeInt(subElement, "level", 0)));
|
||||
subElement.GetAttributeString("name", ""),
|
||||
subElement.GetAttributeInt("level", 0)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Barotrauma.Items.Components
|
||||
radarBlips = new List<RadarBlip>();
|
||||
#endif
|
||||
|
||||
displayBorderSize = ToolBox.GetAttributeFloat(element, "displaybordersize", 0.0f);
|
||||
displayBorderSize = element.GetAttributeFloat("displaybordersize", 0.0f);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
|
||||
@@ -336,7 +336,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (connection.Name == "velocity_in")
|
||||
{
|
||||
currVelocity = ToolBox.ParseToVector2(signal, false);
|
||||
currVelocity = XMLExtensions.ParseToVector2(signal, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -62,19 +62,19 @@ namespace Barotrauma.Items.Components
|
||||
public Rope(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
string spritePath = ToolBox.GetAttributeString(element, "sprite", "");
|
||||
string spritePath = element.GetAttributeString("sprite", "");
|
||||
if (spritePath == "") DebugConsole.ThrowError("Sprite "+spritePath+" in "+element+" not found!");
|
||||
|
||||
float length = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "length", 200.0f));
|
||||
float length = ConvertUnits.ToSimUnits(element.GetAttributeFloat("length", 200.0f));
|
||||
|
||||
pullForce = ToolBox.GetAttributeFloat(element, "pullforce", 10.0f);
|
||||
pullForce = element.GetAttributeFloat("pullforce", 10.0f);
|
||||
|
||||
projectileAnchor = Vector2.Zero;
|
||||
projectileAnchor.X = ToolBox.GetAttributeFloat(element, "projectileanchorx", 0.0f);
|
||||
projectileAnchor.Y = ToolBox.GetAttributeFloat(element, "projectileanchory", 0.0f);
|
||||
projectileAnchor.X = element.GetAttributeFloat("projectileanchorx", 0.0f);
|
||||
projectileAnchor.Y = element.GetAttributeFloat("projectileanchory", 0.0f);
|
||||
projectileAnchor = ConvertUnits.ToSimUnits(projectileAnchor);
|
||||
|
||||
characterUsable = ToolBox.GetAttributeBool(element, "characterusable", false);
|
||||
characterUsable = element.GetAttributeBool("characterusable", false);
|
||||
|
||||
sprite = new Sprite(spritePath, new Vector2(0.5f,0.5f));
|
||||
sectionLength = ConvertUnits.ToSimUnits(sprite.size.X);
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Barotrauma.Items.Components
|
||||
Wires = new Wire[MaxLinked];
|
||||
|
||||
IsOutput = (element.Name.ToString() == "output");
|
||||
Name = ToolBox.GetAttributeString(element, "name", (IsOutput) ? "output" : "input");
|
||||
Name = element.GetAttributeString("name", (IsOutput) ? "output" : "input");
|
||||
|
||||
IsPower = Name == "power_in" || Name == "power" || Name == "power_out";
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
if (index == -1) break;
|
||||
|
||||
int id = ToolBox.GetAttributeInt(subElement, "w", 0);
|
||||
int id = subElement.GetAttributeInt("w", 0);
|
||||
if (id < 0) id = 0;
|
||||
wireId[index] = (ushort)id;
|
||||
|
||||
|
||||
@@ -70,10 +70,10 @@ namespace Barotrauma.Items.Components
|
||||
[InGameEditable, HasDefaultValue("1.0,1.0,1.0,1.0", true)]
|
||||
public string LightColor
|
||||
{
|
||||
get { return ToolBox.Vector4ToString(lightColor.ToVector4(), "0.00"); }
|
||||
get { return XMLExtensions.Vector4ToString(lightColor.ToVector4(), "0.00"); }
|
||||
set
|
||||
{
|
||||
Vector4 newColor = ToolBox.ParseToVector4(value, false);
|
||||
Vector4 newColor = XMLExtensions.ParseToVector4(value, false);
|
||||
newColor.X = MathHelper.Clamp(newColor.X, 0.0f, 1.0f);
|
||||
newColor.Y = MathHelper.Clamp(newColor.Y, 0.0f, 1.0f);
|
||||
newColor.Z = MathHelper.Clamp(newColor.Z, 0.0f, 1.0f);
|
||||
|
||||
@@ -451,7 +451,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
base.Load(componentElement);
|
||||
|
||||
string nodeString = ToolBox.GetAttributeString(componentElement, "nodes", "");
|
||||
string nodeString = componentElement.GetAttributeString("nodes", "");
|
||||
if (nodeString == "") return;
|
||||
|
||||
string[] nodeCoords = nodeString.Split(';');
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
get
|
||||
{
|
||||
return ToolBox.Vector2ToString(barrelPos);
|
||||
return XMLExtensions.Vector2ToString(barrelPos);
|
||||
}
|
||||
set
|
||||
{
|
||||
barrelPos = ToolBox.ParseToVector2(value);
|
||||
barrelPos = XMLExtensions.ParseToVector2(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,11 +62,11 @@ namespace Barotrauma.Items.Components
|
||||
limits.X = MathHelper.ToDegrees(limits.X);
|
||||
limits.Y = MathHelper.ToDegrees(limits.Y);
|
||||
|
||||
return ToolBox.Vector2ToString(limits);
|
||||
return XMLExtensions.Vector2ToString(limits);
|
||||
}
|
||||
set
|
||||
{
|
||||
Vector2 vector = ToolBox.ParseToVector2(value);
|
||||
Vector2 vector = XMLExtensions.ParseToVector2(value);
|
||||
minRotation = MathHelper.ToRadians(vector.X);
|
||||
maxRotation = MathHelper.ToRadians(vector.Y);
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
IsActive = true;
|
||||
|
||||
string barrelSpritePath = ToolBox.GetAttributeString(element, "barrelsprite", "");
|
||||
string barrelSpritePath = element.GetAttributeString("barrelsprite", "");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(barrelSpritePath))
|
||||
{
|
||||
@@ -90,7 +90,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
barrelSprite = new Sprite(
|
||||
barrelSpritePath,
|
||||
ToolBox.GetAttributeVector2(element, "origin", Vector2.Zero));
|
||||
element.GetAttributeVector2("origin", Vector2.Zero));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ namespace Barotrauma.Items.Components
|
||||
switch (connection.Name)
|
||||
{
|
||||
case "position_in":
|
||||
Vector2 receivedPos = ToolBox.ParseToVector2(signal, false);
|
||||
Vector2 receivedPos = XMLExtensions.ParseToVector2(signal, false);
|
||||
|
||||
Vector2 centerPos = new Vector2(item.WorldRect.X + barrelPos.X, item.WorldRect.Y - barrelPos.Y);
|
||||
|
||||
|
||||
@@ -45,10 +45,10 @@ namespace Barotrauma.Items.Components
|
||||
[HasDefaultValue("0.0,360.0", false)]
|
||||
public string ArmorSector
|
||||
{
|
||||
get { return ToolBox.Vector2ToString(armorSector); }
|
||||
get { return XMLExtensions.Vector2ToString(armorSector); }
|
||||
set
|
||||
{
|
||||
armorSector = ToolBox.ParseToVector2(value);
|
||||
armorSector = XMLExtensions.ParseToVector2(value);
|
||||
armorSector.X = MathHelper.ToRadians(armorSector.X);
|
||||
armorSector.Y = MathHelper.ToRadians(armorSector.Y);
|
||||
}
|
||||
@@ -90,12 +90,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
var sprite = new Sprite(subElement, "", spritePath);
|
||||
wearableSprites[i] = new WearableSprite(this, sprite,
|
||||
ToolBox.GetAttributeBool(subElement, "hidelimb", false),
|
||||
ToolBox.GetAttributeBool(subElement, "inheritlimbdepth", true),
|
||||
(LimbType)Enum.Parse(typeof(LimbType), ToolBox.GetAttributeString(subElement, "depthlimb", "None"), true));
|
||||
subElement.GetAttributeBool("hidelimb", false),
|
||||
subElement.GetAttributeBool("inheritlimbdepth", true),
|
||||
(LimbType)Enum.Parse(typeof(LimbType), subElement.GetAttributeString("depthlimb", "None"), true));
|
||||
|
||||
limbType[i] = (LimbType)Enum.Parse(typeof(LimbType),
|
||||
ToolBox.GetAttributeString(subElement, "limb", "Head"), true);
|
||||
subElement.GetAttributeString("limb", "Head"), true);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Barotrauma
|
||||
|
||||
public FixRequirement(XElement element)
|
||||
{
|
||||
name = ToolBox.GetAttributeString(element, "name", "");
|
||||
name = element.GetAttributeString("name", "");
|
||||
|
||||
requiredSkills = new List<Skill>();
|
||||
requiredItems = new List<string>();
|
||||
@@ -24,13 +24,13 @@ namespace Barotrauma
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "skill":
|
||||
string skillName = ToolBox.GetAttributeString(subElement, "name", "");
|
||||
int level = ToolBox.GetAttributeInt(subElement, "level", 1);
|
||||
string skillName = subElement.GetAttributeString("name", "");
|
||||
int level = subElement.GetAttributeInt("level", 1);
|
||||
|
||||
requiredSkills.Add(new Skill(skillName, level));
|
||||
break;
|
||||
case "item":
|
||||
string itemName = ToolBox.GetAttributeString(subElement, "name", "");
|
||||
string itemName = subElement.GetAttributeString("name", "");
|
||||
|
||||
requiredItems.Add(itemName);
|
||||
break;
|
||||
|
||||
@@ -172,10 +172,10 @@ namespace Barotrauma
|
||||
[Editable, HasDefaultValue("1.0,1.0,1.0,1.0", true)]
|
||||
public string SpriteColor
|
||||
{
|
||||
get { return ToolBox.Vector4ToString(spriteColor.ToVector4()); }
|
||||
get { return XMLExtensions.Vector4ToString(spriteColor.ToVector4()); }
|
||||
set
|
||||
{
|
||||
spriteColor = new Color(ToolBox.ParseToVector4(value));
|
||||
spriteColor = new Color(XMLExtensions.ParseToVector4(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,8 +378,8 @@ namespace Barotrauma
|
||||
break;
|
||||
case "aitarget":
|
||||
aiTarget = new AITarget(this);
|
||||
aiTarget.SightRange = ToolBox.GetAttributeFloat(subElement, "sightrange", 1000.0f);
|
||||
aiTarget.SoundRange = ToolBox.GetAttributeFloat(subElement, "soundrange", 0.0f);
|
||||
aiTarget.SightRange = subElement.GetAttributeFloat("sightrange", 1000.0f);
|
||||
aiTarget.SoundRange = subElement.GetAttributeFloat("soundrange", 0.0f);
|
||||
break;
|
||||
case "fixrequirement":
|
||||
FixRequirements.Add(new FixRequirement(subElement));
|
||||
@@ -1595,7 +1595,7 @@ namespace Barotrauma
|
||||
|
||||
public static void Load(XElement element, Submarine submarine)
|
||||
{
|
||||
string rectString = ToolBox.GetAttributeString(element, "rect", "0,0,0,0");
|
||||
string rectString = element.GetAttributeString("rect", "0,0,0,0");
|
||||
string[] rectValues = rectString.Split(',');
|
||||
Rectangle rect = Rectangle.Empty;
|
||||
if (rectValues.Length==4)
|
||||
@@ -1655,7 +1655,7 @@ namespace Barotrauma
|
||||
if (shouldBeLoaded) property.TrySetValue(attribute.Value);
|
||||
}
|
||||
|
||||
string linkedToString = ToolBox.GetAttributeString(element, "linked", "");
|
||||
string linkedToString = element.GetAttributeString("linked", "");
|
||||
if (linkedToString!="")
|
||||
{
|
||||
string[] linkedToIds = linkedToString.Split(',');
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace Barotrauma
|
||||
DebugConsole.Log("*** " + filePath + " ***");
|
||||
}
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(filePath);
|
||||
if (doc == null) return;
|
||||
|
||||
if (doc.Root.Name.ToString().ToLowerInvariant() == "item")
|
||||
@@ -244,35 +244,35 @@ namespace Barotrauma
|
||||
configFile = filePath;
|
||||
ConfigElement = element;
|
||||
|
||||
name = ToolBox.GetAttributeString(element, "name", "");
|
||||
name = element.GetAttributeString("name", "");
|
||||
if (name == "") DebugConsole.ThrowError("Unnamed item in "+filePath+"!");
|
||||
|
||||
DebugConsole.Log(" "+name);
|
||||
|
||||
Description = ToolBox.GetAttributeString(element, "description", "");
|
||||
Description = element.GetAttributeString("description", "");
|
||||
|
||||
interactThroughWalls = ToolBox.GetAttributeBool(element, "interactthroughwalls", false);
|
||||
interactDistance = ToolBox.GetAttributeFloat(element, "interactdistance", 120.0f); // Default to 120 as the new item picking method is tuned to this number
|
||||
interactPriority = ToolBox.GetAttributeFloat(element, "interactpriority", 0.0f);
|
||||
interactThroughWalls = element.GetAttributeBool("interactthroughwalls", false);
|
||||
interactDistance = element.GetAttributeFloat("interactdistance", 120.0f); // Default to 120 as the new item picking method is tuned to this number
|
||||
interactPriority = element.GetAttributeFloat("interactpriority", 0.0f);
|
||||
|
||||
isLinkable = ToolBox.GetAttributeBool(element, "linkable", false);
|
||||
isLinkable = element.GetAttributeBool("linkable", false);
|
||||
|
||||
resizeHorizontal = ToolBox.GetAttributeBool(element, "resizehorizontal", false);
|
||||
resizeVertical = ToolBox.GetAttributeBool(element, "resizevertical", false);
|
||||
resizeHorizontal = element.GetAttributeBool("resizehorizontal", false);
|
||||
resizeVertical = element.GetAttributeBool("resizevertical", false);
|
||||
|
||||
focusOnSelected = ToolBox.GetAttributeBool(element, "focusonselected", false);
|
||||
focusOnSelected = element.GetAttributeBool("focusonselected", false);
|
||||
|
||||
offsetOnSelected = ToolBox.GetAttributeFloat(element, "offsetonselected", 0.0f);
|
||||
offsetOnSelected = element.GetAttributeFloat("offsetonselected", 0.0f);
|
||||
|
||||
CanUseOnSelf = ToolBox.GetAttributeBool(element, "canuseonself", false);
|
||||
CanUseOnSelf = element.GetAttributeBool("canuseonself", false);
|
||||
|
||||
|
||||
Health = ToolBox.GetAttributeFloat(element, "health", 100.0f);
|
||||
Indestructible = ToolBox.GetAttributeBool(element, "indestructible", false);
|
||||
FireProof = ToolBox.GetAttributeBool(element, "fireproof", false);
|
||||
ImpactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 0.0f);
|
||||
Health = element.GetAttributeFloat("health", 100.0f);
|
||||
Indestructible = element.GetAttributeBool("indestructible", false);
|
||||
FireProof = element.GetAttributeBool("fireproof", false);
|
||||
ImpactTolerance = element.GetAttributeFloat("impacttolerance", 0.0f);
|
||||
|
||||
string aliases = ToolBox.GetAttributeString(element, "aliases", "");
|
||||
string aliases = element.GetAttributeString("aliases", "");
|
||||
if (!string.IsNullOrWhiteSpace(aliases))
|
||||
{
|
||||
Aliases = aliases.Split(',');
|
||||
@@ -280,7 +280,7 @@ namespace Barotrauma
|
||||
|
||||
MapEntityCategory category;
|
||||
|
||||
if (!Enum.TryParse(ToolBox.GetAttributeString(element, "category", "Misc"), true, out category))
|
||||
if (!Enum.TryParse(element.GetAttributeString("category", "Misc"), true, out category))
|
||||
{
|
||||
category = MapEntityCategory.Misc;
|
||||
}
|
||||
@@ -288,10 +288,10 @@ namespace Barotrauma
|
||||
Category = category;
|
||||
|
||||
|
||||
string spriteColorStr = ToolBox.GetAttributeString(element, "spritecolor", "1.0,1.0,1.0,1.0");
|
||||
SpriteColor = new Color(ToolBox.ParseToVector4(spriteColorStr));
|
||||
string spriteColorStr = element.GetAttributeString("spritecolor", "1.0,1.0,1.0,1.0");
|
||||
SpriteColor = new Color(XMLExtensions.ParseToVector4(spriteColorStr));
|
||||
|
||||
price = ToolBox.GetAttributeInt(element, "price", 0);
|
||||
price = element.GetAttributeInt("price", 0);
|
||||
|
||||
Triggers = new List<Rectangle>();
|
||||
|
||||
@@ -299,7 +299,7 @@ namespace Barotrauma
|
||||
DeconstructTime = 1.0f;
|
||||
|
||||
tags = new List<string>();
|
||||
tags.AddRange(ToolBox.GetAttributeString(element, "tags", "").Split(','));
|
||||
tags.AddRange(element.GetAttributeString("tags", "").Split(','));
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
@@ -307,24 +307,24 @@ namespace Barotrauma
|
||||
{
|
||||
case "sprite":
|
||||
string spriteFolder = "";
|
||||
if (!ToolBox.GetAttributeString(subElement, "texture", "").Contains("/"))
|
||||
if (!subElement.GetAttributeString("texture", "").Contains("/"))
|
||||
{
|
||||
spriteFolder = Path.GetDirectoryName(filePath);
|
||||
}
|
||||
|
||||
canSpriteFlipX = ToolBox.GetAttributeBool(subElement, "canflipx", true);
|
||||
canSpriteFlipX = subElement.GetAttributeBool("canflipx", true);
|
||||
|
||||
sprite = new Sprite(subElement, spriteFolder);
|
||||
size = sprite.size;
|
||||
break;
|
||||
case "deconstruct":
|
||||
DeconstructTime = ToolBox.GetAttributeFloat(subElement, "time", 10.0f);
|
||||
DeconstructTime = subElement.GetAttributeFloat("time", 10.0f);
|
||||
|
||||
foreach (XElement deconstructItem in subElement.Elements())
|
||||
{
|
||||
|
||||
string deconstructItemName = ToolBox.GetAttributeString(deconstructItem, "name", "not found");
|
||||
bool requireFullCondition = ToolBox.GetAttributeBool(deconstructItem, "requirefullcondition", false);
|
||||
string deconstructItemName = deconstructItem.GetAttributeString("name", "not found");
|
||||
bool requireFullCondition = deconstructItem.GetAttributeBool("requirefullcondition", false);
|
||||
|
||||
DeconstructItems.Add(new DeconstructItem(deconstructItemName, requireFullCondition));
|
||||
|
||||
@@ -334,11 +334,11 @@ namespace Barotrauma
|
||||
case "trigger":
|
||||
Rectangle trigger = new Rectangle(0, 0, 10,10);
|
||||
|
||||
trigger.X = ToolBox.GetAttributeInt(subElement, "x", 0);
|
||||
trigger.Y = ToolBox.GetAttributeInt(subElement, "y", 0);
|
||||
trigger.X = subElement.GetAttributeInt("x", 0);
|
||||
trigger.Y = subElement.GetAttributeInt("y", 0);
|
||||
|
||||
trigger.Width = ToolBox.GetAttributeInt(subElement, "width", 0);
|
||||
trigger.Height = ToolBox.GetAttributeInt(subElement, "height", 0);
|
||||
trigger.Width = subElement.GetAttributeInt("width", 0);
|
||||
trigger.Height = subElement.GetAttributeInt("height", 0);
|
||||
|
||||
Triggers.Add(trigger);
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Barotrauma
|
||||
|
||||
public static RelatedItem Load(XElement element)
|
||||
{
|
||||
string nameString = ToolBox.GetAttributeString(element, "name", "");
|
||||
string nameString = element.GetAttributeString("name", "");
|
||||
if (nameString == "") return null;
|
||||
|
||||
string[] names = nameString.Split(',');
|
||||
@@ -136,7 +136,7 @@ namespace Barotrauma
|
||||
|
||||
try
|
||||
{
|
||||
ri.type = (RelationType)Enum.Parse(typeof(RelationType), ToolBox.GetAttributeString(element, "type", "None"));
|
||||
ri.type = (RelationType)Enum.Parse(typeof(RelationType), element.GetAttributeString("type", "None"));
|
||||
}
|
||||
|
||||
catch
|
||||
@@ -144,7 +144,7 @@ namespace Barotrauma
|
||||
ri.type = RelationType.None;
|
||||
}
|
||||
|
||||
ri.Msg = ToolBox.GetAttributeString(element, "msg", "");
|
||||
ri.Msg = element.GetAttributeString("msg", "");
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user