Converted the GetAttribute methods in the ToolBox class to extension methods
This commit is contained in:
@@ -33,17 +33,17 @@ namespace Barotrauma
|
||||
{
|
||||
attack = new Attack(element);
|
||||
|
||||
force = ToolBox.GetAttributeFloat(element, "force", 0.0f);
|
||||
force = element.GetAttributeFloat("force", 0.0f);
|
||||
|
||||
sparks = ToolBox.GetAttributeBool(element, "sparks", true);
|
||||
shockwave = ToolBox.GetAttributeBool(element, "shockwave", true);
|
||||
flames = ToolBox.GetAttributeBool(element, "flames", true);
|
||||
smoke = ToolBox.GetAttributeBool(element, "smoke", true);
|
||||
sparks = element.GetAttributeBool("sparks", true);
|
||||
shockwave = element.GetAttributeBool("shockwave", true);
|
||||
flames = element.GetAttributeBool("flames", true);
|
||||
smoke = element.GetAttributeBool("smoke", true);
|
||||
|
||||
decal = ToolBox.GetAttributeString(element, "decal", "");
|
||||
decalSize = ToolBox.GetAttributeFloat(element, "decalSize", 1.0f);
|
||||
decal = element.GetAttributeString("decal", "");
|
||||
decalSize = element.GetAttributeFloat("decalSize", 1.0f);
|
||||
|
||||
CameraShake = ToolBox.GetAttributeFloat(element, "camerashake", attack.Range * 0.1f);
|
||||
CameraShake = element.GetAttributeFloat("camerashake", attack.Range * 0.1f);
|
||||
}
|
||||
|
||||
public void Explode(Vector2 worldPosition)
|
||||
|
||||
@@ -655,7 +655,7 @@ namespace Barotrauma
|
||||
|
||||
if (element.Attribute("rect") != null)
|
||||
{
|
||||
string rectString = ToolBox.GetAttributeString(element, "rect", "0,0,0,0");
|
||||
string rectString = element.GetAttributeString("rect", "0,0,0,0");
|
||||
string[] rectValues = rectString.Split(',');
|
||||
|
||||
rect = new Rectangle(
|
||||
|
||||
@@ -711,7 +711,7 @@ namespace Barotrauma
|
||||
|
||||
if (element.Attribute("rect") != null)
|
||||
{
|
||||
string rectString = ToolBox.GetAttributeString(element, "rect", "0,0,0,0");
|
||||
string rectString = element.GetAttributeString("rect", "0,0,0,0");
|
||||
string[] rectValues = rectString.Split(',');
|
||||
|
||||
rect = new Rectangle(
|
||||
@@ -731,7 +731,7 @@ namespace Barotrauma
|
||||
|
||||
Hull h = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), rect, submarine);
|
||||
|
||||
h.volume = ToolBox.GetAttributeFloat(element, "pressure", 0.0f);
|
||||
h.volume = element.GetAttributeFloat("pressure", 0.0f);
|
||||
|
||||
h.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Barotrauma
|
||||
|
||||
if (prefab.LevelTriggerElement != null)
|
||||
{
|
||||
Vector2 triggerPosition = ToolBox.GetAttributeVector2(prefab.LevelTriggerElement, "position", Vector2.Zero) * scale;
|
||||
Vector2 triggerPosition = prefab.LevelTriggerElement.GetAttributeVector2("position", Vector2.Zero) * scale;
|
||||
|
||||
if (rotation != 0.0f)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ namespace Barotrauma
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(configPath);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configPath);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
|
||||
@@ -40,16 +40,16 @@ namespace Barotrauma
|
||||
|
||||
public BackgroundSpritePrefab(XElement element)
|
||||
{
|
||||
string alignmentStr = ToolBox.GetAttributeString(element, "alignment", "");
|
||||
string alignmentStr = element.GetAttributeString("alignment", "");
|
||||
|
||||
if (string.IsNullOrEmpty(alignmentStr) || !Enum.TryParse(alignmentStr, out Alignment))
|
||||
{
|
||||
Alignment = Alignment.Top | Alignment.Bottom | Alignment.Left | Alignment.Right;
|
||||
}
|
||||
|
||||
Commonness = ToolBox.GetAttributeInt(element, "commonness", 1);
|
||||
Commonness = element.GetAttributeInt("commonness", 1);
|
||||
|
||||
string[] spawnPosStrs = ToolBox.GetAttributeString(element, "spawnpos", "Wall").Split(',');
|
||||
string[] spawnPosStrs = element.GetAttributeString("spawnpos", "Wall").Split(',');
|
||||
foreach (string spawnPosStr in spawnPosStrs)
|
||||
{
|
||||
SpawnPosType parsedSpawnPos;
|
||||
@@ -59,18 +59,18 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
Scale.X = ToolBox.GetAttributeFloat(element, "minsize", 1.0f);
|
||||
Scale.Y = ToolBox.GetAttributeFloat(element, "maxsize", 1.0f);
|
||||
Scale.X = element.GetAttributeFloat("minsize", 1.0f);
|
||||
Scale.Y = element.GetAttributeFloat("maxsize", 1.0f);
|
||||
|
||||
DepthRange = ToolBox.GetAttributeVector2(element, "depthrange", new Vector2(0.0f, 1.0f));
|
||||
DepthRange = element.GetAttributeVector2("depthrange", new Vector2(0.0f, 1.0f));
|
||||
|
||||
AlignWithSurface = ToolBox.GetAttributeBool(element, "alignwithsurface", false);
|
||||
AlignWithSurface = element.GetAttributeBool("alignwithsurface", false);
|
||||
|
||||
RandomRotation = ToolBox.GetAttributeVector2(element, "randomrotation", Vector2.Zero);
|
||||
RandomRotation = element.GetAttributeVector2("randomrotation", Vector2.Zero);
|
||||
RandomRotation.X = MathHelper.ToRadians(RandomRotation.X);
|
||||
RandomRotation.Y = MathHelper.ToRadians(RandomRotation.Y);
|
||||
|
||||
SwingAmount = MathHelper.ToRadians(ToolBox.GetAttributeFloat(element, "swingamount", 0.0f));
|
||||
SwingAmount = MathHelper.ToRadians(element.GetAttributeFloat("swingamount", 0.0f));
|
||||
|
||||
OverrideCommonness = new Dictionary<string, int>();
|
||||
|
||||
@@ -82,10 +82,10 @@ namespace Barotrauma
|
||||
Sprite = new Sprite(subElement);
|
||||
break;
|
||||
case "overridecommonness":
|
||||
string levelType = ToolBox.GetAttributeString(subElement, "leveltype", "");
|
||||
string levelType = subElement.GetAttributeString("leveltype", "");
|
||||
if (!OverrideCommonness.ContainsKey(levelType))
|
||||
{
|
||||
OverrideCommonness.Add(levelType, ToolBox.GetAttributeInt(subElement, "commonness", 1));
|
||||
OverrideCommonness.Add(levelType, subElement.GetAttributeInt("commonness", 1));
|
||||
}
|
||||
break;
|
||||
case "leveltrigger":
|
||||
@@ -101,11 +101,11 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
ParticleEmitterPrefabs.Add(new Particles.ParticleEmitterPrefab(subElement));
|
||||
EmitterPositions.Add(ToolBox.GetAttributeVector2(subElement, "position", Vector2.Zero));
|
||||
EmitterPositions.Add(subElement.GetAttributeVector2("position", Vector2.Zero));
|
||||
break;
|
||||
case "sound":
|
||||
SoundElement = subElement;
|
||||
SoundPosition = ToolBox.GetAttributeVector2(subElement, "position", Vector2.Zero);
|
||||
SoundPosition = subElement.GetAttributeVector2("position", Vector2.Zero);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ namespace Barotrauma
|
||||
|
||||
public Biome(XElement element)
|
||||
{
|
||||
Name = ToolBox.GetAttributeString(element, "name", "Biome");
|
||||
Description = ToolBox.GetAttributeString(element, "description", "");
|
||||
Name = element.GetAttributeString("name", "Biome");
|
||||
Description = element.GetAttributeString("description", "");
|
||||
|
||||
string[] placementsStrs = ToolBox.GetAttributeString(element, "MapPlacement", "Default").Split(',');
|
||||
string[] placementsStrs = element.GetAttributeString("MapPlacement", "Default").Split(',');
|
||||
foreach (string placementStr in placementsStrs)
|
||||
{
|
||||
MapPlacement parsedPlacement;
|
||||
@@ -280,21 +280,21 @@ namespace Barotrauma
|
||||
Name = element == null ? "default" : element.Name.ToString();
|
||||
ObjectProperties = ObjectProperty.InitProperties(this, element);
|
||||
|
||||
Vector3 colorVector = ToolBox.GetAttributeVector3(element, "BackgroundColor", new Vector3(50, 46, 20));
|
||||
Vector3 colorVector = element.GetAttributeVector3("BackgroundColor", new Vector3(50, 46, 20));
|
||||
BackgroundColor = new Color((int)colorVector.X, (int)colorVector.Y, (int)colorVector.Z);
|
||||
|
||||
colorVector = ToolBox.GetAttributeVector3(element, "WallColor", new Vector3(255,255,255));
|
||||
colorVector = element.GetAttributeVector3("WallColor", new Vector3(255,255,255));
|
||||
WallColor = new Color((int)colorVector.X, (int)colorVector.Y, (int)colorVector.Z);
|
||||
|
||||
VoronoiSiteInterval = ToolBox.GetAttributeVector2(element, "VoronoiSiteInterval", new Vector2(3000, 3000));
|
||||
VoronoiSiteInterval = element.GetAttributeVector2("VoronoiSiteInterval", new Vector2(3000, 3000));
|
||||
|
||||
VoronoiSiteVariance = ToolBox.GetAttributeVector2(element, "VoronoiSiteVariance", new Vector2(voronoiSiteInterval.X, voronoiSiteInterval.Y) * 0.4f);
|
||||
VoronoiSiteVariance = element.GetAttributeVector2("VoronoiSiteVariance", new Vector2(voronoiSiteInterval.X, voronoiSiteInterval.Y) * 0.4f);
|
||||
|
||||
MainPathNodeIntervalRange = ToolBox.GetAttributeVector2(element, "MainPathNodeIntervalRange", new Vector2(5000.0f, 10000.0f));
|
||||
MainPathNodeIntervalRange = element.GetAttributeVector2("MainPathNodeIntervalRange", new Vector2(5000.0f, 10000.0f));
|
||||
|
||||
SmallTunnelLengthRange = ToolBox.GetAttributeVector2(element, "SmallTunnelLengthRange", new Vector2(5000.0f, 10000.0f));
|
||||
SmallTunnelLengthRange = element.GetAttributeVector2("SmallTunnelLengthRange", new Vector2(5000.0f, 10000.0f));
|
||||
|
||||
string biomeStr = ToolBox.GetAttributeString(element, "biomes", "");
|
||||
string biomeStr = element.GetAttributeString("biomes", "");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(biomeStr))
|
||||
{
|
||||
@@ -334,7 +334,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(file);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(file);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
|
||||
@@ -57,9 +57,9 @@ namespace Barotrauma
|
||||
|
||||
physicsBody.SetTransform(ConvertUnits.ToSimUnits(position), rotation);
|
||||
|
||||
cameraShake = ToolBox.GetAttributeFloat(element, "camerashake", 0.0f);
|
||||
cameraShake = element.GetAttributeFloat("camerashake", 0.0f);
|
||||
|
||||
force = ToolBox.GetAttributeVector2(element, "force", Vector2.Zero);
|
||||
force = element.GetAttributeVector2("force", Vector2.Zero);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Barotrauma.RuinGeneration
|
||||
|
||||
private RuinStructure(XElement element)
|
||||
{
|
||||
string prefab = ToolBox.GetAttributeString(element, "prefab", "").ToLowerInvariant();
|
||||
string prefab = element.GetAttributeString("prefab", "").ToLowerInvariant();
|
||||
Prefab = MapEntityPrefab.list.Find(s => s.Name.ToLowerInvariant() == prefab);
|
||||
|
||||
if (Prefab == null)
|
||||
@@ -36,21 +36,21 @@ namespace Barotrauma.RuinGeneration
|
||||
return;
|
||||
}
|
||||
|
||||
string alignmentStr = ToolBox.GetAttributeString(element,"alignment","Bottom");
|
||||
string alignmentStr = element.GetAttributeString("alignment","Bottom");
|
||||
if (!Enum.TryParse<Alignment>(alignmentStr, true, out Alignment))
|
||||
{
|
||||
DebugConsole.ThrowError("Error in ruin structure \""+prefab+"\" - "+alignmentStr+" is not a valid alignment");
|
||||
}
|
||||
|
||||
|
||||
string typeStr = ToolBox.GetAttributeString(element,"type","");
|
||||
string typeStr = element.GetAttributeString("type","");
|
||||
if (!Enum.TryParse<RuinStructureType>(typeStr,true, out Type))
|
||||
{
|
||||
DebugConsole.ThrowError("Error in ruin structure \"" + prefab + "\" - " + typeStr + " is not a valid type");
|
||||
return;
|
||||
}
|
||||
|
||||
commonness = ToolBox.GetAttributeInt(element, "commonness", 1);
|
||||
commonness = element.GetAttributeInt("commonness", 1);
|
||||
|
||||
list.Add(this);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace Barotrauma.RuinGeneration
|
||||
{
|
||||
list = new List<RuinStructure>();
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml(ConfigFile);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(ConfigFile);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
|
||||
@@ -111,10 +111,10 @@ namespace Barotrauma
|
||||
{
|
||||
if (element.Name != "Structure") continue;
|
||||
|
||||
string name = ToolBox.GetAttributeString(element, "name", "");
|
||||
string name = element.GetAttributeString("name", "");
|
||||
if (!wallPrefabs.Any(wp => wp.Name == name)) continue;
|
||||
|
||||
var rect = ToolBox.GetAttributeVector4(element, "rect", Vector4.Zero);
|
||||
var rect = element.GetAttributeVector4("rect", Vector4.Zero);
|
||||
|
||||
points.Add(new Vector2(rect.X, rect.Y));
|
||||
points.Add(new Vector2(rect.X + rect.Z, rect.Y));
|
||||
@@ -127,7 +127,7 @@ namespace Barotrauma
|
||||
|
||||
public static void Load(XElement element, Submarine submarine)
|
||||
{
|
||||
Vector2 pos = ToolBox.GetAttributeVector2(element, "pos", Vector2.Zero);
|
||||
Vector2 pos = element.GetAttributeVector2("pos", Vector2.Zero);
|
||||
|
||||
LinkedSubmarine linkedSub = null;
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace Barotrauma
|
||||
linkedSub = new LinkedSubmarine(submarine);
|
||||
linkedSub.saveElement = element;
|
||||
|
||||
string levelSeed = ToolBox.GetAttributeString(element, "location", "");
|
||||
string levelSeed = element.GetAttributeString("location", "");
|
||||
if (!string.IsNullOrWhiteSpace(levelSeed) && GameMain.GameSession.Level != null && GameMain.GameSession.Level.Seed != levelSeed)
|
||||
{
|
||||
linkedSub.loadSub = false;
|
||||
@@ -155,9 +155,9 @@ namespace Barotrauma
|
||||
linkedSub.rect.Location = MathUtils.ToPoint(pos);
|
||||
}
|
||||
|
||||
linkedSub.filePath = ToolBox.GetAttributeString(element, "filepath", "");
|
||||
linkedSub.filePath = element.GetAttributeString("filepath", "");
|
||||
|
||||
string linkedToString = ToolBox.GetAttributeString(element, "linkedto", "");
|
||||
string linkedToString = element.GetAttributeString("linkedto", "");
|
||||
if (linkedToString != "")
|
||||
{
|
||||
string[] linkedToIds = linkedToString.Split(',');
|
||||
@@ -175,7 +175,7 @@ namespace Barotrauma
|
||||
|
||||
sub = Submarine.Load(saveElement, false);
|
||||
|
||||
Vector2 worldPos = ToolBox.GetAttributeVector2(saveElement, "worldpos", Vector2.Zero);
|
||||
Vector2 worldPos = saveElement.GetAttributeVector2("worldpos", Vector2.Zero);
|
||||
if (worldPos != Vector2.Zero)
|
||||
{
|
||||
sub.SetPosition(worldPos);
|
||||
@@ -259,7 +259,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
if (saveElement.Attribute("pos") != null) saveElement.Attribute("pos").Remove();
|
||||
saveElement.Add(new XAttribute("pos", ToolBox.Vector2ToString(Position - Submarine.HiddenSubPosition)));
|
||||
saveElement.Add(new XAttribute("pos", XMLExtensions.Vector2ToString(Position - Submarine.HiddenSubPosition)));
|
||||
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Barotrauma
|
||||
if (leaveBehind)
|
||||
{
|
||||
saveElement.SetAttributeValue("location", Level.Loaded.Seed);
|
||||
saveElement.SetAttributeValue("worldpos", ToolBox.Vector2ToString(sub.SubBody.Position));
|
||||
saveElement.SetAttributeValue("worldpos", XMLExtensions.Vector2ToString(sub.SubBody.Position));
|
||||
|
||||
}
|
||||
else
|
||||
@@ -309,7 +309,7 @@ namespace Barotrauma
|
||||
if (saveElement.Attribute("worldpos") != null) saveElement.Attribute("worldpos").Remove();
|
||||
}
|
||||
|
||||
saveElement.SetAttributeValue("pos", ToolBox.Vector2ToString(Position - Submarine.HiddenSubPosition));
|
||||
saveElement.SetAttributeValue("pos", XMLExtensions.Vector2ToString(Position - Submarine.HiddenSubPosition));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Barotrauma
|
||||
{
|
||||
name = element.Name.ToString();
|
||||
|
||||
commonness = ToolBox.GetAttributeInt(element, "commonness", 1);
|
||||
commonness = element.GetAttributeInt("commonness", 1);
|
||||
totalWeight += commonness;
|
||||
|
||||
nameFormats = new List<string>();
|
||||
@@ -70,7 +70,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (subElement.Name.ToString().ToLowerInvariant() != "hireable") continue;
|
||||
|
||||
string jobName = ToolBox.GetAttributeString(subElement, "name", "");
|
||||
string jobName = subElement.GetAttributeString("name", "");
|
||||
|
||||
JobPrefab jobPrefab = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == jobName.ToLowerInvariant());
|
||||
if (jobPrefab==null)
|
||||
@@ -78,7 +78,7 @@ namespace Barotrauma
|
||||
DebugConsole.ThrowError("Invalid job name ("+jobName+") in location type "+name);
|
||||
}
|
||||
|
||||
float jobCommonness = ToolBox.GetAttributeFloat(subElement, "commonness", 1.0f);
|
||||
float jobCommonness = subElement.GetAttributeFloat("commonness", 1.0f);
|
||||
totalHireableWeight += jobCommonness;
|
||||
|
||||
Tuple<JobPrefab, float> hireableJob = new Tuple<JobPrefab, float>(jobPrefab, jobCommonness);
|
||||
@@ -86,10 +86,10 @@ namespace Barotrauma
|
||||
hireableJobs.Add(hireableJob);
|
||||
}
|
||||
|
||||
string spritePath = ToolBox.GetAttributeString(element, "symbol", "Content/Map/beaconSymbol.png");
|
||||
string spritePath = element.GetAttributeString("symbol", "Content/Map/beaconSymbol.png");
|
||||
symbolSprite = new Sprite(spritePath, new Vector2(0.5f, 0.5f));
|
||||
|
||||
string backgroundPath = ToolBox.GetAttributeString(element, "background", "");
|
||||
string backgroundPath = element.GetAttributeString("background", "");
|
||||
backGround = new Sprite(backgroundPath, Vector2.Zero);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (string file in locationTypeFiles)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(file);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(file);
|
||||
|
||||
if (doc==null)
|
||||
{
|
||||
|
||||
@@ -396,9 +396,9 @@ namespace Barotrauma
|
||||
|
||||
public static Map LoadNew(XElement element)
|
||||
{
|
||||
string mapSeed = ToolBox.GetAttributeString(element, "seed", "a");
|
||||
string mapSeed = element.GetAttributeString("seed", "a");
|
||||
|
||||
int size = ToolBox.GetAttributeInt(element, "size", 1000);
|
||||
int size = element.GetAttributeInt("size", 1000);
|
||||
Map map = new Map(mapSeed, size);
|
||||
map.Load(element);
|
||||
|
||||
@@ -407,9 +407,9 @@ namespace Barotrauma
|
||||
|
||||
public void Load(XElement element)
|
||||
{
|
||||
SetLocation(ToolBox.GetAttributeInt(element, "currentlocation", 0));
|
||||
SetLocation(element.GetAttributeInt("currentlocation", 0));
|
||||
|
||||
string discoveredStr = ToolBox.GetAttributeString(element, "discovered", "");
|
||||
string discoveredStr = element.GetAttributeString("discovered", "");
|
||||
|
||||
string[] discoveredStrs = discoveredStr.Split(',');
|
||||
for (int i = 0; i < discoveredStrs.Length; i++)
|
||||
@@ -418,7 +418,7 @@ namespace Barotrauma
|
||||
if (int.TryParse(discoveredStrs[i], out index)) locations[index].Discovered = true;
|
||||
}
|
||||
|
||||
string passedStr = ToolBox.GetAttributeString(element, "passed", "");
|
||||
string passedStr = element.GetAttributeString("passed", "");
|
||||
string[] passedStrs = passedStr.Split(',');
|
||||
for (int i = 0; i < passedStrs.Length; i++)
|
||||
{
|
||||
|
||||
@@ -808,7 +808,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 = new Rectangle(
|
||||
@@ -843,13 +843,13 @@ namespace Barotrauma
|
||||
switch (subElement.Name.ToString())
|
||||
{
|
||||
case "section":
|
||||
int index = ToolBox.GetAttributeInt(subElement, "i", -1);
|
||||
int index = subElement.GetAttributeInt("i", -1);
|
||||
if (index == -1) continue;
|
||||
|
||||
s.sections[index].damage =
|
||||
ToolBox.GetAttributeFloat(subElement, "damage", 0.0f);
|
||||
subElement.GetAttributeFloat("damage", 0.0f);
|
||||
|
||||
s.sections[index].GapID = ToolBox.GetAttributeInt(subElement, "gap", -1);
|
||||
s.sections[index].GapID = subElement.GetAttributeInt("gap", -1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,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 el in doc.Root.Elements())
|
||||
@@ -87,7 +87,7 @@ namespace Barotrauma
|
||||
sp.name = element.Name.ToString();
|
||||
|
||||
sp.tags = new List<string>();
|
||||
sp.tags.AddRange(ToolBox.GetAttributeString(element, "tags", "").Split(','));
|
||||
sp.tags.AddRange(element.GetAttributeString("tags", "").Split(','));
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
@@ -96,20 +96,20 @@ namespace Barotrauma
|
||||
case "sprite":
|
||||
sp.sprite = new Sprite(subElement);
|
||||
|
||||
if (ToolBox.GetAttributeBool(subElement, "fliphorizontal", false))
|
||||
if (subElement.GetAttributeBool("fliphorizontal", false))
|
||||
sp.sprite.effects = SpriteEffects.FlipHorizontally;
|
||||
if (ToolBox.GetAttributeBool(subElement, "flipvertical", false))
|
||||
if (subElement.GetAttributeBool("flipvertical", false))
|
||||
sp.sprite.effects = SpriteEffects.FlipVertically;
|
||||
|
||||
sp.canSpriteFlipX = ToolBox.GetAttributeBool(subElement, "canflipx", true);
|
||||
sp.canSpriteFlipX = subElement.GetAttributeBool("canflipx", true);
|
||||
|
||||
break;
|
||||
case "backgroundsprite":
|
||||
sp.BackgroundSprite = new Sprite(subElement);
|
||||
|
||||
if (ToolBox.GetAttributeBool(subElement, "fliphorizontal", false))
|
||||
if (subElement.GetAttributeBool("fliphorizontal", false))
|
||||
sp.BackgroundSprite.effects = SpriteEffects.FlipHorizontally;
|
||||
if (ToolBox.GetAttributeBool(subElement, "flipvertical", false))
|
||||
if (subElement.GetAttributeBool("flipvertical", false))
|
||||
sp.BackgroundSprite.effects = SpriteEffects.FlipVertically;
|
||||
|
||||
break;
|
||||
@@ -118,33 +118,33 @@ namespace Barotrauma
|
||||
|
||||
MapEntityCategory category;
|
||||
|
||||
if (!Enum.TryParse(ToolBox.GetAttributeString(element, "category", "Structure"), true, out category))
|
||||
if (!Enum.TryParse(element.GetAttributeString("category", "Structure"), true, out category))
|
||||
{
|
||||
category = MapEntityCategory.Structure;
|
||||
}
|
||||
|
||||
sp.Category = category;
|
||||
|
||||
sp.Description = ToolBox.GetAttributeString(element, "description", "");
|
||||
sp.Description = element.GetAttributeString("description", "");
|
||||
|
||||
sp.size = Vector2.Zero;
|
||||
sp.size.X = ToolBox.GetAttributeFloat(element, "width", 0.0f);
|
||||
sp.size.Y = ToolBox.GetAttributeFloat(element, "height", 0.0f);
|
||||
sp.size.X = element.GetAttributeFloat("width", 0.0f);
|
||||
sp.size.Y = element.GetAttributeFloat("height", 0.0f);
|
||||
|
||||
string spriteColorStr = ToolBox.GetAttributeString(element, "spritecolor", "1.0,1.0,1.0,1.0");
|
||||
sp.SpriteColor = new Color(ToolBox.ParseToVector4(spriteColorStr));
|
||||
string spriteColorStr = element.GetAttributeString("spritecolor", "1.0,1.0,1.0,1.0");
|
||||
sp.SpriteColor = new Color(XMLExtensions.ParseToVector4(spriteColorStr));
|
||||
|
||||
sp.maxHealth = ToolBox.GetAttributeFloat(element, "health", 100.0f);
|
||||
sp.maxHealth = element.GetAttributeFloat("health", 100.0f);
|
||||
|
||||
sp.resizeHorizontal = ToolBox.GetAttributeBool(element, "resizehorizontal", false);
|
||||
sp.resizeVertical = ToolBox.GetAttributeBool(element, "resizevertical", false);
|
||||
sp.resizeHorizontal = element.GetAttributeBool("resizehorizontal", false);
|
||||
sp.resizeVertical = element.GetAttributeBool("resizevertical", false);
|
||||
|
||||
sp.isPlatform = ToolBox.GetAttributeBool(element, "platform", false);
|
||||
sp.stairDirection = (Direction)Enum.Parse(typeof(Direction), ToolBox.GetAttributeString(element, "stairdirection", "None"), true);
|
||||
sp.isPlatform = element.GetAttributeBool("platform", false);
|
||||
sp.stairDirection = (Direction)Enum.Parse(typeof(Direction), element.GetAttributeString("stairdirection", "None"), true);
|
||||
|
||||
sp.castShadow = ToolBox.GetAttributeBool(element, "castshadow", false);
|
||||
sp.castShadow = element.GetAttributeBool("castshadow", false);
|
||||
|
||||
sp.hasBody = ToolBox.GetAttributeBool(element, "body", false);
|
||||
sp.hasBody = element.GetAttributeBool("body", false);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
@@ -267,8 +267,8 @@ namespace Barotrauma
|
||||
|
||||
if (doc != null && doc.Root != null)
|
||||
{
|
||||
Description = ToolBox.GetAttributeString(doc.Root, "description", "");
|
||||
Enum.TryParse(ToolBox.GetAttributeString(doc.Root, "tags", ""), out tags);
|
||||
Description = doc.Root.GetAttributeString("description", "");
|
||||
Enum.TryParse(doc.Root.GetAttributeString("tags", ""), out tags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,8 +949,8 @@ namespace Barotrauma
|
||||
submarineElement = doc.Root;
|
||||
}
|
||||
|
||||
Description = ToolBox.GetAttributeString(submarineElement, "description", "");
|
||||
Enum.TryParse(ToolBox.GetAttributeString(submarineElement, "tags", ""), out tags);
|
||||
Description = submarineElement.GetAttributeString("description", "");
|
||||
Enum.TryParse(submarineElement.GetAttributeString("tags", ""), out tags);
|
||||
|
||||
//place the sub above the top of the level
|
||||
HiddenSubPosition = HiddenSubStartPosition;
|
||||
@@ -1081,7 +1081,7 @@ namespace Barotrauma
|
||||
|
||||
//tryload -> false
|
||||
|
||||
Submarine sub = new Submarine(ToolBox.GetAttributeString(element, "name", ""), "", false);
|
||||
Submarine sub = new Submarine(element.GetAttributeString("name", ""), "", false);
|
||||
sub.Load(unloadPrevious, element);
|
||||
|
||||
return sub;
|
||||
|
||||
@@ -568,22 +568,22 @@ namespace Barotrauma
|
||||
|
||||
w.ID = (ushort)int.Parse(element.Attribute("ID").Value);
|
||||
|
||||
Enum.TryParse<SpawnType>(ToolBox.GetAttributeString(element, "spawn", "Path"), out w.spawnType);
|
||||
Enum.TryParse<SpawnType>(element.GetAttributeString("spawn", "Path"), out w.spawnType);
|
||||
|
||||
string idCardTagString = ToolBox.GetAttributeString(element, "idcardtags", "");
|
||||
string idCardTagString = element.GetAttributeString("idcardtags", "");
|
||||
if (!string.IsNullOrWhiteSpace(idCardTagString))
|
||||
{
|
||||
w.IdCardTags = idCardTagString.Split(',');
|
||||
}
|
||||
|
||||
string jobName = ToolBox.GetAttributeString(element, "job", "").ToLowerInvariant();
|
||||
string jobName = element.GetAttributeString("job", "").ToLowerInvariant();
|
||||
if (!string.IsNullOrWhiteSpace(jobName))
|
||||
{
|
||||
w.assignedJob = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == jobName);
|
||||
}
|
||||
|
||||
w.ladderId = (ushort)ToolBox.GetAttributeInt(element, "ladders", 0);
|
||||
w.gapId = (ushort)ToolBox.GetAttributeInt(element, "gap", 0);
|
||||
w.ladderId = (ushort)element.GetAttributeInt("ladders", 0);
|
||||
w.gapId = (ushort)element.GetAttributeInt("gap", 0);
|
||||
|
||||
w.linkedToID = new List<ushort>();
|
||||
int i = 0;
|
||||
|
||||
Reference in New Issue
Block a user