Converted the GetAttribute methods in the ToolBox class to extension methods
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Barotrauma
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
string soundPath = ToolBox.GetAttributeString(element, "sound", "");
|
||||
string soundPath = element.GetAttributeString("sound", "");
|
||||
if (!string.IsNullOrWhiteSpace(soundPath))
|
||||
{
|
||||
sound = Sound.Load(soundPath);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Barotrauma
|
||||
|
||||
partial void InitProjSpecific(XDocument doc)
|
||||
{
|
||||
soundInterval = ToolBox.GetAttributeFloat(doc.Root, "soundinterval", 10.0f);
|
||||
soundInterval = doc.Root.GetAttributeFloat("soundinterval", 10.0f);
|
||||
|
||||
keys = new Key[Enum.GetNames(typeof(InputType)).Length];
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace Barotrauma
|
||||
public CharacterSound(XElement element)
|
||||
{
|
||||
Sound = Sound.Load(element.Attribute("file").Value);
|
||||
Range = ToolBox.GetAttributeFloat(element, "range", 1000.0f);
|
||||
Range = element.GetAttributeFloat("range", 1000.0f);
|
||||
|
||||
Enum.TryParse<SoundType>(ToolBox.GetAttributeString(element, "state", "Idle"), true, out Type);
|
||||
Enum.TryParse<SoundType>(element.GetAttributeString("state", "Idle"), true, out Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Barotrauma
|
||||
LightSource = new LightSource(subElement);
|
||||
break;
|
||||
case "sound":
|
||||
hitSound = Sound.Load(ToolBox.GetAttributeString(subElement, "file", ""));
|
||||
hitSound = Sound.Load(subElement.GetAttributeString("file", ""));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,21 +72,21 @@ namespace Barotrauma
|
||||
|
||||
ChildStyles = new Dictionary<string, GUIComponentStyle>();
|
||||
|
||||
Padding = ToolBox.GetAttributeVector4(element, "padding", Vector4.Zero);
|
||||
Padding = element.GetAttributeVector4("padding", Vector4.Zero);
|
||||
|
||||
Vector4 colorVector = ToolBox.GetAttributeVector4(element, "color", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
Vector4 colorVector = element.GetAttributeVector4("color", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
Color = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
|
||||
|
||||
colorVector = ToolBox.GetAttributeVector4(element, "textcolor", new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
colorVector = element.GetAttributeVector4("textcolor", new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
textColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
|
||||
|
||||
colorVector = ToolBox.GetAttributeVector4(element, "hovercolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
colorVector = element.GetAttributeVector4("hovercolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
HoverColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
|
||||
|
||||
colorVector = ToolBox.GetAttributeVector4(element, "selectedcolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
colorVector = element.GetAttributeVector4("selectedcolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
SelectedColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
|
||||
|
||||
colorVector = ToolBox.GetAttributeVector4(element, "outlinecolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
colorVector = element.GetAttributeVector4("outlinecolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
OutlineColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
@@ -95,16 +95,16 @@ namespace Barotrauma
|
||||
{
|
||||
case "sprite":
|
||||
Sprite sprite = new Sprite(subElement);
|
||||
bool maintainAspect = ToolBox.GetAttributeBool(subElement, "maintainaspectratio",false);
|
||||
bool tile = ToolBox.GetAttributeBool(subElement, "tile", true);
|
||||
bool maintainAspect = subElement.GetAttributeBool("maintainaspectratio",false);
|
||||
bool tile = subElement.GetAttributeBool("tile", true);
|
||||
|
||||
string stateStr = ToolBox.GetAttributeString(subElement, "state", "None");
|
||||
string stateStr = subElement.GetAttributeString("state", "None");
|
||||
GUIComponent.ComponentState spriteState = GUIComponent.ComponentState.None;
|
||||
Enum.TryParse(stateStr, out spriteState);
|
||||
|
||||
UISprite newSprite = new UISprite(sprite, tile, maintainAspect);
|
||||
|
||||
Vector4 sliceVec = ToolBox.GetAttributeVector4(subElement, "slice", Vector4.Zero);
|
||||
Vector4 sliceVec = subElement.GetAttributeVector4("slice", Vector4.Zero);
|
||||
if (sliceVec != Vector4.Zero)
|
||||
{
|
||||
Rectangle slice = new Rectangle((int)sliceVec.X, (int)sliceVec.Y, (int)(sliceVec.Z - sliceVec.X), (int)(sliceVec.W - sliceVec.Y));
|
||||
|
||||
@@ -332,14 +332,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
campaign.Money = ToolBox.GetAttributeInt(element, "money", 0);
|
||||
campaign.Money = element.GetAttributeInt("money", 0);
|
||||
|
||||
//backwards compatibility with older save files
|
||||
if (campaign.map == null)
|
||||
{
|
||||
string mapSeed = ToolBox.GetAttributeString(element, "mapseed", "a");
|
||||
string mapSeed = element.GetAttributeString("mapseed", "a");
|
||||
campaign.GenerateMap(mapSeed);
|
||||
campaign.map.SetLocation(ToolBox.GetAttributeInt(element, "currentlocation", 0));
|
||||
campaign.map.SetLocation(element.GetAttributeInt("currentlocation", 0));
|
||||
}
|
||||
|
||||
campaign.savedOnStart = true;
|
||||
|
||||
@@ -129,9 +129,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
XElement graphicsMode = doc.Root.Element("graphicsmode");
|
||||
GraphicsWidth = ToolBox.GetAttributeInt(graphicsMode, "width", 0);
|
||||
GraphicsHeight = ToolBox.GetAttributeInt(graphicsMode, "height", 0);
|
||||
VSyncEnabled = ToolBox.GetAttributeBool(graphicsMode, "vsync", true);
|
||||
GraphicsWidth = graphicsMode.GetAttributeInt("width", 0);
|
||||
GraphicsHeight = graphicsMode.GetAttributeInt("height", 0);
|
||||
VSyncEnabled = graphicsMode.GetAttributeBool("vsync", true);
|
||||
|
||||
if (GraphicsWidth == 0 || GraphicsHeight == 0)
|
||||
{
|
||||
@@ -141,16 +141,16 @@ namespace Barotrauma
|
||||
|
||||
//FullScreenEnabled = ToolBox.GetAttributeBool(graphicsMode, "fullscreen", true);
|
||||
|
||||
var windowModeStr = ToolBox.GetAttributeString(graphicsMode, "displaymode", "Fullscreen");
|
||||
var windowModeStr = graphicsMode.GetAttributeString("displaymode", "Fullscreen");
|
||||
if (!Enum.TryParse<WindowMode>(windowModeStr, out windowMode))
|
||||
{
|
||||
windowMode = WindowMode.Fullscreen;
|
||||
}
|
||||
|
||||
SoundVolume = ToolBox.GetAttributeFloat(doc.Root, "soundvolume", 1.0f);
|
||||
MusicVolume = ToolBox.GetAttributeFloat(doc.Root, "musicvolume", 0.3f);
|
||||
SoundVolume = doc.Root.GetAttributeFloat("soundvolume", 1.0f);
|
||||
MusicVolume = doc.Root.GetAttributeFloat("musicvolume", 0.3f);
|
||||
|
||||
EnableSplashScreen = ToolBox.GetAttributeBool(doc.Root, "enablesplashscreen", true);
|
||||
EnableSplashScreen = doc.Root.GetAttributeBool("enablesplashscreen", true);
|
||||
|
||||
keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
|
||||
keyMapping[(int)InputType.Up] = new KeyOrMouse(Keys.W);
|
||||
@@ -198,7 +198,7 @@ namespace Barotrauma
|
||||
JobNamePreferences = new List<string>();
|
||||
foreach (XElement ele in subElement.Element("jobpreferences").Elements("job"))
|
||||
{
|
||||
JobNamePreferences.Add(ToolBox.GetAttributeString(ele, "name", ""));
|
||||
JobNamePreferences.Add(ele.GetAttributeString("name", ""));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -145,26 +145,26 @@ namespace Barotrauma.Items.Components
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "guiframe":
|
||||
string rectStr = ToolBox.GetAttributeString(subElement, "rect", "0.0,0.0,0.5,0.5");
|
||||
string rectStr = subElement.GetAttributeString("rect", "0.0,0.0,0.5,0.5");
|
||||
|
||||
string[] components = rectStr.Split(',');
|
||||
if (components.Length < 4) break;
|
||||
|
||||
Vector4 rect = ToolBox.GetAttributeVector4(subElement, "rect", Vector4.One);
|
||||
Vector4 rect = subElement.GetAttributeVector4("rect", Vector4.One);
|
||||
if (components[0].Contains(".")) rect.X *= GameMain.GraphicsWidth;
|
||||
if (components[1].Contains(".")) rect.Y *= GameMain.GraphicsHeight;
|
||||
if (components[2].Contains(".")) rect.Z *= GameMain.GraphicsWidth;
|
||||
if (components[3].Contains(".")) rect.W *= GameMain.GraphicsHeight;
|
||||
|
||||
string style = ToolBox.GetAttributeString(subElement, "style", "");
|
||||
string style = subElement.GetAttributeString("style", "");
|
||||
|
||||
Vector4 color = ToolBox.GetAttributeVector4(subElement, "color", Vector4.One);
|
||||
Vector4 color = subElement.GetAttributeVector4("color", Vector4.One);
|
||||
|
||||
Alignment alignment = Alignment.Center;
|
||||
try
|
||||
{
|
||||
alignment = (Alignment)Enum.Parse(typeof(Alignment),
|
||||
ToolBox.GetAttributeString(subElement, "alignment", "Center"), true);
|
||||
subElement.GetAttributeString("alignment", "Center"), true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -178,9 +178,9 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
break;
|
||||
case "sound":
|
||||
string filePath = ToolBox.GetAttributeString(subElement, "file", "");
|
||||
string filePath = subElement.GetAttributeString("file", "");
|
||||
|
||||
if (filePath == "") filePath = ToolBox.GetAttributeString(subElement, "sound", "");
|
||||
if (filePath == "") filePath = subElement.GetAttributeString("sound", "");
|
||||
|
||||
if (filePath == "")
|
||||
{
|
||||
@@ -197,7 +197,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
try
|
||||
{
|
||||
type = (ActionType)Enum.Parse(typeof(ActionType), ToolBox.GetAttributeString(subElement, "type", ""), true);
|
||||
type = (ActionType)Enum.Parse(typeof(ActionType), subElement.GetAttributeString("type", ""), true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -207,11 +207,11 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
Sound sound = Sound.Load(filePath);
|
||||
|
||||
float range = ToolBox.GetAttributeFloat(subElement, "range", 800.0f);
|
||||
bool loop = ToolBox.GetAttributeBool(subElement, "loop", false);
|
||||
float range = subElement.GetAttributeFloat("range", 800.0f);
|
||||
bool loop = subElement.GetAttributeBool("loop", false);
|
||||
ItemSound itemSound = new ItemSound(sound, type, range, loop);
|
||||
itemSound.VolumeProperty = ToolBox.GetAttributeString(subElement, "volume", "");
|
||||
itemSound.VolumeMultiplier = ToolBox.GetAttributeFloat(subElement, "volumemultiplier", 1.0f);
|
||||
itemSound.VolumeProperty = subElement.GetAttributeString("volume", "");
|
||||
itemSound.VolumeMultiplier = subElement.GetAttributeFloat("volumemultiplier", 1.0f);
|
||||
|
||||
List<ItemSound> soundList = null;
|
||||
if (!sounds.TryGetValue(itemSound.Type, out soundList))
|
||||
|
||||
@@ -30,10 +30,10 @@ namespace Barotrauma.Items.Components
|
||||
[Editable, HasDefaultValue("0.0,0.0,0.0,1.0", true)]
|
||||
public string TextColor
|
||||
{
|
||||
get { return ToolBox.Vector4ToString(textColor.ToVector4()); }
|
||||
get { return XMLExtensions.Vector4ToString(textColor.ToVector4()); }
|
||||
set
|
||||
{
|
||||
textColor = new Color(ToolBox.ParseToVector4(value));
|
||||
textColor = new Color(XMLExtensions.ParseToVector4(value));
|
||||
if (textBlock != null) textBlock.TextColor = textColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,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())
|
||||
|
||||
@@ -21,18 +21,18 @@ namespace Barotrauma
|
||||
|
||||
public BackgroundCreaturePrefab(XElement element)
|
||||
{
|
||||
Speed = ToolBox.GetAttributeFloat(element, "speed", 1.0f);
|
||||
Speed = element.GetAttributeFloat("speed", 1.0f);
|
||||
|
||||
WanderAmount = ToolBox.GetAttributeFloat(element, "wanderamount", 0.0f);
|
||||
WanderAmount = element.GetAttributeFloat("wanderamount", 0.0f);
|
||||
|
||||
WanderZAmount = ToolBox.GetAttributeFloat(element, "wanderzamount", 0.0f);
|
||||
WanderZAmount = element.GetAttributeFloat("wanderzamount", 0.0f);
|
||||
|
||||
SwarmMin = ToolBox.GetAttributeInt(element, "swarmmin", 1);
|
||||
SwarmMax = ToolBox.GetAttributeInt(element, "swarmmax", 1);
|
||||
SwarmMin = element.GetAttributeInt("swarmmin", 1);
|
||||
SwarmMax = element.GetAttributeInt("swarmmax", 1);
|
||||
|
||||
SwarmRadius = ToolBox.GetAttributeFloat(element, "swarmradius", 200.0f);
|
||||
SwarmRadius = element.GetAttributeFloat("swarmradius", 200.0f);
|
||||
|
||||
DisableRotation = ToolBox.GetAttributeBool(element, "disablerotation", false);
|
||||
DisableRotation = element.GetAttributeBool("disablerotation", false);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
|
||||
@@ -121,10 +121,10 @@ namespace Barotrauma.Lights
|
||||
public LightSource (XElement element)
|
||||
: this(Vector2.Zero, 100.0f, Color.White, null)
|
||||
{
|
||||
range = ToolBox.GetAttributeFloat(element, "range", 100.0f);
|
||||
color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One));
|
||||
range = element.GetAttributeFloat("range", 100.0f);
|
||||
color = new Color(element.GetAttributeVector4("color", Vector4.One));
|
||||
|
||||
CastShadows = ToolBox.GetAttributeBool(element, "castshadows", true);
|
||||
CastShadows = element.GetAttributeBool("castshadows", true);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
|
||||
@@ -1124,7 +1124,7 @@ namespace Barotrauma.Networking
|
||||
if (GameMain.GameSession.Submarine == null)
|
||||
{
|
||||
var gameSessionDoc = SaveUtil.LoadGameSessionDoc(GameMain.GameSession.SavePath);
|
||||
string subPath = Path.Combine(SaveUtil.TempPath, ToolBox.GetAttributeString(gameSessionDoc.Root, "submarine", "")) + ".sub";
|
||||
string subPath = Path.Combine(SaveUtil.TempPath, gameSessionDoc.Root.GetAttributeString("submarine", "")) + ".sub";
|
||||
GameMain.GameSession.Submarine = new Submarine(subPath, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Barotrauma.Particles
|
||||
|
||||
public DecalManager(string configFile)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(configFile);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
prefabs = new Dictionary<string, DecalPrefab>();
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
}
|
||||
|
||||
Color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One));
|
||||
Color = new Color(element.GetAttributeVector4("color", Vector4.One));
|
||||
|
||||
LifeTime = ToolBox.GetAttributeFloat(element, "lifetime", 10.0f);
|
||||
FadeOutTime = Math.Min(LifeTime, ToolBox.GetAttributeFloat(element, "fadeouttime", 1.0f));
|
||||
FadeInTime = Math.Min(LifeTime - FadeOutTime, ToolBox.GetAttributeFloat(element, "fadeintime", 0.0f));
|
||||
LifeTime = element.GetAttributeFloat("lifetime", 10.0f);
|
||||
FadeOutTime = Math.Min(LifeTime, element.GetAttributeFloat("fadeouttime", 1.0f));
|
||||
FadeInTime = Math.Min(LifeTime - FadeOutTime, element.GetAttributeFloat("fadeintime", 0.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,16 +95,16 @@ namespace Barotrauma.Particles
|
||||
{
|
||||
Name = element.Name.ToString();
|
||||
|
||||
ParticlePrefab = GameMain.ParticleManager.FindPrefab(ToolBox.GetAttributeString(element, "particle", ""));
|
||||
ParticlePrefab = GameMain.ParticleManager.FindPrefab(element.GetAttributeString("particle", ""));
|
||||
|
||||
if (element.Attribute("startrotation") == null)
|
||||
{
|
||||
AngleMin = ToolBox.GetAttributeFloat(element, "anglemin", 0.0f);
|
||||
AngleMax = ToolBox.GetAttributeFloat(element, "anglemax", 0.0f);
|
||||
AngleMin = element.GetAttributeFloat("anglemin", 0.0f);
|
||||
AngleMax = element.GetAttributeFloat("anglemax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
AngleMin = ToolBox.GetAttributeFloat(element, "angle", 0.0f);
|
||||
AngleMin = element.GetAttributeFloat("angle", 0.0f);
|
||||
AngleMax = AngleMin;
|
||||
}
|
||||
|
||||
@@ -118,23 +118,23 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
else
|
||||
{
|
||||
ScaleMin = ToolBox.GetAttributeFloat(element,"scalemin",1.0f);
|
||||
ScaleMax = Math.Max(ScaleMin, ToolBox.GetAttributeFloat(element, "scalemax", 1.0f));
|
||||
ScaleMin = element.GetAttributeFloat("scalemin",1.0f);
|
||||
ScaleMax = Math.Max(ScaleMin, element.GetAttributeFloat("scalemax", 1.0f));
|
||||
}
|
||||
|
||||
if (element.Attribute("velocity") == null)
|
||||
{
|
||||
VelocityMin = ToolBox.GetAttributeFloat(element, "velocitymin", 0.0f);
|
||||
VelocityMax = ToolBox.GetAttributeFloat(element, "velocitymax", 0.0f);
|
||||
VelocityMin = element.GetAttributeFloat("velocitymin", 0.0f);
|
||||
VelocityMax = element.GetAttributeFloat("velocitymax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
VelocityMin = ToolBox.GetAttributeFloat(element, "velocity", 0.0f);
|
||||
VelocityMin = element.GetAttributeFloat("velocity", 0.0f);
|
||||
VelocityMax = VelocityMin;
|
||||
}
|
||||
|
||||
ParticlesPerSecond = ToolBox.GetAttributeInt(element, "particlespersecond", 0);
|
||||
ParticleAmount = ToolBox.GetAttributeInt(element, "particleamount", 0);
|
||||
ParticlesPerSecond = element.GetAttributeInt("particlespersecond", 0);
|
||||
ParticleAmount = element.GetAttributeInt("particleamount", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Barotrauma.Particles
|
||||
|
||||
particles = new Particle[MaxParticles];
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml(configFile);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
prefabs = new Dictionary<string, ParticlePrefab>();
|
||||
|
||||
@@ -69,17 +69,17 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
}
|
||||
|
||||
AnimDuration = ToolBox.GetAttributeFloat(element, "animduration", 1.0f);
|
||||
LoopAnim = ToolBox.GetAttributeBool(element, "loopanim", true);
|
||||
AnimDuration = element.GetAttributeFloat("animduration", 1.0f);
|
||||
LoopAnim = element.GetAttributeBool("loopanim", true);
|
||||
|
||||
if (element.Attribute("angularvelocity") == null)
|
||||
{
|
||||
AngularVelocityMin = ToolBox.GetAttributeFloat(element, "angularvelocitymin", 0.0f);
|
||||
AngularVelocityMax = ToolBox.GetAttributeFloat(element, "angularvelocitymax", 0.0f);
|
||||
AngularVelocityMin = element.GetAttributeFloat("angularvelocitymin", 0.0f);
|
||||
AngularVelocityMax = element.GetAttributeFloat("angularvelocitymax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
AngularVelocityMin = ToolBox.GetAttributeFloat(element, "angularvelocity", 0.0f);
|
||||
AngularVelocityMin = element.GetAttributeFloat("angularvelocity", 0.0f);
|
||||
AngularVelocityMax = AngularVelocityMin;
|
||||
}
|
||||
|
||||
@@ -88,33 +88,33 @@ namespace Barotrauma.Particles
|
||||
|
||||
if (element.Attribute("startsize") == null)
|
||||
{
|
||||
StartSizeMin = ToolBox.GetAttributeVector2(element, "startsizemin", Vector2.One);
|
||||
StartSizeMax = ToolBox.GetAttributeVector2(element, "startsizemax", Vector2.One);
|
||||
StartSizeMin = element.GetAttributeVector2("startsizemin", Vector2.One);
|
||||
StartSizeMax = element.GetAttributeVector2("startsizemax", Vector2.One);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartSizeMin = ToolBox.GetAttributeVector2(element, "startsize", Vector2.One);
|
||||
StartSizeMin = element.GetAttributeVector2("startsize", Vector2.One);
|
||||
StartSizeMax = StartSizeMin;
|
||||
}
|
||||
|
||||
if (element.Attribute("sizechange") == null)
|
||||
{
|
||||
SizeChangeMin = ToolBox.GetAttributeVector2(element, "sizechangemin", Vector2.Zero);
|
||||
SizeChangeMax = ToolBox.GetAttributeVector2(element, "sizechangemax", Vector2.Zero);
|
||||
SizeChangeMin = element.GetAttributeVector2("sizechangemin", Vector2.Zero);
|
||||
SizeChangeMax = element.GetAttributeVector2("sizechangemax", Vector2.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
SizeChangeMin = ToolBox.GetAttributeVector2(element, "sizechange", Vector2.Zero);
|
||||
SizeChangeMin = element.GetAttributeVector2("sizechange", Vector2.Zero);
|
||||
SizeChangeMax = SizeChangeMin;
|
||||
}
|
||||
|
||||
Drag = ToolBox.GetAttributeFloat(element, "drag", 0.0f);
|
||||
WaterDrag = ToolBox.GetAttributeFloat(element, "waterdrag", 0.0f);
|
||||
Drag = element.GetAttributeFloat("drag", 0.0f);
|
||||
WaterDrag = element.GetAttributeFloat("waterdrag", 0.0f);
|
||||
|
||||
Friction = ToolBox.GetAttributeFloat(element, "friction", 0.5f);
|
||||
Restitution = ToolBox.GetAttributeFloat(element, "restitution", 0.5f);
|
||||
Friction = element.GetAttributeFloat("friction", 0.5f);
|
||||
Restitution = element.GetAttributeFloat("restitution", 0.5f);
|
||||
|
||||
switch (ToolBox.GetAttributeString(element, "blendstate", "alphablend"))
|
||||
switch (element.GetAttributeString("blendstate", "alphablend"))
|
||||
{
|
||||
case "alpha":
|
||||
case "alphablend":
|
||||
@@ -130,42 +130,41 @@ namespace Barotrauma.Particles
|
||||
break;
|
||||
}
|
||||
|
||||
GrowTime = ToolBox.GetAttributeFloat(element, "growtime", 0.0f);
|
||||
GrowTime = element.GetAttributeFloat("growtime", 0.0f);
|
||||
|
||||
if (element.Attribute("startrotation") == null)
|
||||
{
|
||||
StartRotationMin = ToolBox.GetAttributeFloat(element, "startrotationmin", 0.0f);
|
||||
StartRotationMax = ToolBox.GetAttributeFloat(element, "startrotationmax", 0.0f);
|
||||
StartRotationMin = element.GetAttributeFloat("startrotationmin", 0.0f);
|
||||
StartRotationMax = element.GetAttributeFloat("startrotationmax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartRotationMin = ToolBox.GetAttributeFloat(element, "startrotation", 0.0f);
|
||||
StartRotationMin = element.GetAttributeFloat("startrotation", 0.0f);
|
||||
StartRotationMax = StartRotationMin;
|
||||
}
|
||||
|
||||
StartRotationMin = MathHelper.ToRadians(StartRotationMin);
|
||||
StartRotationMax = MathHelper.ToRadians(StartRotationMax);
|
||||
|
||||
StartColor = new Color(ToolBox.GetAttributeVector4(element, "startcolor", Vector4.One));
|
||||
StartAlpha = ToolBox.GetAttributeFloat(element, "startalpha", 1.0f);
|
||||
StartColor = new Color(element.GetAttributeVector4("startcolor", Vector4.One));
|
||||
StartAlpha = element.GetAttributeFloat("startalpha", 1.0f);
|
||||
|
||||
DeleteOnCollision = ToolBox.GetAttributeBool(element, "deleteoncollision", false);
|
||||
CollidesWithWalls = ToolBox.GetAttributeBool(element, "collideswithwalls", false);
|
||||
DeleteOnCollision = element.GetAttributeBool("deleteoncollision", false);
|
||||
CollidesWithWalls = element.GetAttributeBool("collideswithwalls", false);
|
||||
|
||||
CollisionRadius = ToolBox.GetAttributeFloat(element,
|
||||
"collisionradius",
|
||||
CollisionRadius = element.GetAttributeFloat("collisionradius",
|
||||
Sprites.Count > 0 ? 1 : Sprites[0].SourceRect.Width / 2.0f);
|
||||
|
||||
ColorChange = ToolBox.GetAttributeVector4(element, "colorchange", Vector4.Zero);
|
||||
ColorChange = element.GetAttributeVector4("colorchange", Vector4.Zero);
|
||||
|
||||
LifeTime = ToolBox.GetAttributeFloat(element, "lifetime", 5.0f);
|
||||
LifeTime = element.GetAttributeFloat("lifetime", 5.0f);
|
||||
|
||||
VelocityChange = ToolBox.GetAttributeVector2(element, "velocitychange", Vector2.Zero);
|
||||
VelocityChange = element.GetAttributeVector2("velocitychange", Vector2.Zero);
|
||||
VelocityChange = ConvertUnits.ToDisplayUnits(VelocityChange);
|
||||
|
||||
RotateToDirection = ToolBox.GetAttributeBool(element, "rotatetodirection", false);
|
||||
RotateToDirection = element.GetAttributeBool("rotatetodirection", false);
|
||||
|
||||
switch (ToolBox.GetAttributeString(element, "drawtarget", "air").ToLowerInvariant())
|
||||
switch (element.GetAttributeString("drawtarget", "air").ToLowerInvariant())
|
||||
{
|
||||
case "air":
|
||||
default:
|
||||
|
||||
@@ -166,9 +166,9 @@ namespace Barotrauma
|
||||
|
||||
RemoveSaveFrame();
|
||||
|
||||
string subName = ToolBox.GetAttributeString(doc.Root, "submarine", "");
|
||||
string saveTime = ToolBox.GetAttributeString(doc.Root, "savetime", "unknown");
|
||||
string mapseed = ToolBox.GetAttributeString(doc.Root, "mapseed", "unknown");
|
||||
string subName = doc.Root.GetAttributeString("submarine", "");
|
||||
string saveTime = doc.Root.GetAttributeString("savetime", "unknown");
|
||||
string mapseed = doc.Root.GetAttributeString("mapseed", "unknown");
|
||||
|
||||
GUIFrame saveFileFrame = new GUIFrame(new Rectangle((int)(saveList.Rect.Width + 20), 0, 200, 230), Color.Black * 0.4f, "", loadGameContainer);
|
||||
saveFileFrame.UserData = "savefileframe";
|
||||
|
||||
@@ -93,13 +93,13 @@ namespace Barotrauma
|
||||
|
||||
public static Sound Load(XElement element, bool destroyOnGameEnd = true)
|
||||
{
|
||||
string filePath = ToolBox.GetAttributeString(element, "file", "");
|
||||
string filePath = element.GetAttributeString("file", "");
|
||||
|
||||
var newSound = new Sound(filePath, destroyOnGameEnd);
|
||||
if (newSound != null)
|
||||
{
|
||||
newSound.baseVolume = ToolBox.GetAttributeFloat(element, "volume", 1.0f);
|
||||
newSound.range = ToolBox.GetAttributeFloat(element, "range", 1000.0f);
|
||||
newSound.baseVolume = element.GetAttributeFloat("volume", 1.0f);
|
||||
newSound.range = element.GetAttributeFloat("range", 1000.0f);
|
||||
}
|
||||
|
||||
return newSound;
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Barotrauma
|
||||
{
|
||||
OverrideMusicType = null;
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml("Content/Sounds/sounds.xml");
|
||||
XDocument doc = XMLExtensions.TryLoadXml("Content/Sounds/sounds.xml");
|
||||
if (doc == null) yield return CoroutineStatus.Failure;
|
||||
|
||||
SoundCount = 16 + doc.Root.Elements().Count();
|
||||
@@ -134,9 +134,9 @@ namespace Barotrauma
|
||||
int i = 0;
|
||||
foreach (XElement element in xMusic)
|
||||
{
|
||||
string file = ToolBox.GetAttributeString(element, "file", "");
|
||||
string type = ToolBox.GetAttributeString(element, "type", "").ToLowerInvariant();
|
||||
Vector2 priority = ToolBox.GetAttributeVector2(element, "priorityrange", new Vector2(0.0f, 100.0f));
|
||||
string file = element.GetAttributeString("file", "");
|
||||
string type = element.GetAttributeString("type", "").ToLowerInvariant();
|
||||
Vector2 priority = element.GetAttributeVector2("priorityrange", new Vector2(0.0f, 100.0f));
|
||||
|
||||
musicClips[i] = new BackgroundMusic(file, type, priority);
|
||||
|
||||
@@ -158,21 +158,21 @@ namespace Barotrauma
|
||||
case "music":
|
||||
continue;
|
||||
case "damagesound":
|
||||
Sound damageSound = Sound.Load(ToolBox.GetAttributeString(subElement, "file", ""), false);
|
||||
Sound damageSound = Sound.Load(subElement.GetAttributeString("file", ""), false);
|
||||
if (damageSound == null) continue;
|
||||
|
||||
DamageSoundType damageSoundType = DamageSoundType.None;
|
||||
Enum.TryParse<DamageSoundType>(ToolBox.GetAttributeString(subElement, "damagesoundtype", "None"), false, out damageSoundType);
|
||||
Enum.TryParse<DamageSoundType>(subElement.GetAttributeString("damagesoundtype", "None"), false, out damageSoundType);
|
||||
|
||||
damageSounds.Add(new DamageSound(
|
||||
damageSound,
|
||||
ToolBox.GetAttributeVector2(subElement, "damagerange", new Vector2(0.0f, 100.0f)),
|
||||
subElement.GetAttributeVector2("damagerange", new Vector2(0.0f, 100.0f)),
|
||||
damageSoundType,
|
||||
ToolBox.GetAttributeString(subElement, "requiredtag", "")));
|
||||
subElement.GetAttributeString("requiredtag", "")));
|
||||
|
||||
break;
|
||||
default:
|
||||
Sound sound = Sound.Load(ToolBox.GetAttributeString(subElement, "file", ""), false);
|
||||
Sound sound = Sound.Load(subElement.GetAttributeString("file", ""), false);
|
||||
if (sound != null)
|
||||
{
|
||||
miscSoundList.Add(new KeyValuePair<string, Sound>(subElement.Name.ToString().ToLowerInvariant(), sound));
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Barotrauma
|
||||
|
||||
public void StartServer()
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(GameServer.SettingsFile);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(GameServer.SettingsFile);
|
||||
if (doc == null)
|
||||
{
|
||||
DebugConsole.ThrowError("File \"" + GameServer.SettingsFile + "\" not found. Starting the server with default settings.");
|
||||
@@ -108,12 +108,12 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Server = new GameServer(
|
||||
ToolBox.GetAttributeString(doc.Root, "name", "Server"),
|
||||
ToolBox.GetAttributeInt(doc.Root, "port", 14242),
|
||||
ToolBox.GetAttributeBool(doc.Root, "public", false),
|
||||
ToolBox.GetAttributeString(doc.Root, "password", ""),
|
||||
ToolBox.GetAttributeBool(doc.Root, "enableupnp", false),
|
||||
ToolBox.GetAttributeInt(doc.Root, "maxplayers", 10));
|
||||
doc.Root.GetAttributeString("name", "Server"),
|
||||
doc.Root.GetAttributeInt("port", 14242),
|
||||
doc.Root.GetAttributeBool("public", false),
|
||||
doc.Root.GetAttributeString("password", ""),
|
||||
doc.Root.GetAttributeBool("enableupnp", false),
|
||||
doc.Root.GetAttributeInt("maxplayers", 10));
|
||||
}
|
||||
|
||||
public void CloseServer()
|
||||
|
||||
@@ -1414,6 +1414,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Items\Components\Signal\MotionSensor.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Items\Components\Signal\NotComponent.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Items\Components\Signal\OrComponent.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Items\Components\Signal\OscillatorComponent.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Items\Components\Signal\OxygenDetector.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Items\Components\Signal\RegExFindComponent.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Items\Components\Signal\RelayComponent.cs" />
|
||||
@@ -1500,5 +1501,6 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Utils\SaveUtil.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Utils\ToolBox.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Utils\UpdaterUtil.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Utils\XMLExtensions.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Barotrauma
|
||||
public ContentPackage(string filePath)
|
||||
: this()
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(filePath);
|
||||
|
||||
Path = filePath;
|
||||
|
||||
@@ -74,12 +74,12 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
|
||||
name = ToolBox.GetAttributeString(doc.Root, "name", "");
|
||||
name = doc.Root.GetAttributeString("name", "");
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
ContentType type = (ContentType)Enum.Parse(typeof(ContentType), subElement.Name.ToString(), true);
|
||||
files.Add(new ContentFile(ToolBox.GetAttributeString(subElement, "file", ""), type));
|
||||
files.Add(new ContentFile(subElement.GetAttributeString("file", ""), type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Barotrauma
|
||||
public ArtifactEvent(XElement element)
|
||||
: base(element)
|
||||
{
|
||||
string itemName = ToolBox.GetAttributeString(element, "itemname", "");
|
||||
string itemName = element.GetAttributeString("itemname", "");
|
||||
|
||||
itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Barotrauma
|
||||
{
|
||||
itemConfig = element.Element("Items");
|
||||
|
||||
requiredDeliveryAmount = ToolBox.GetAttributeInt(element, "requireddeliveryamount", 0);
|
||||
requiredDeliveryAmount = element.GetAttributeInt("requireddeliveryamount", 0);
|
||||
}
|
||||
|
||||
private void InitItems()
|
||||
@@ -41,7 +41,7 @@ namespace Barotrauma
|
||||
|
||||
private void LoadItemAsChild(XElement element, Item parent)
|
||||
{
|
||||
string itemName = ToolBox.GetAttributeString(element, "name", "");
|
||||
string itemName = element.GetAttributeString("name", "");
|
||||
|
||||
ItemPrefab itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
|
||||
if (itemPrefab==null)
|
||||
@@ -79,7 +79,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
int amount = ToolBox.GetAttributeInt(subElement, "amount", 1);
|
||||
int amount = subElement.GetAttributeInt("amount", 1);
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
LoadItemAsChild(subElement, item);
|
||||
|
||||
@@ -58,9 +58,9 @@ namespace Barotrauma
|
||||
{
|
||||
descriptions = new string[]
|
||||
{
|
||||
ToolBox.GetAttributeString(element, "descriptionneutral", ""),
|
||||
ToolBox.GetAttributeString(element, "description1", ""),
|
||||
ToolBox.GetAttributeString(element, "description2", "")
|
||||
element.GetAttributeString("descriptionneutral", ""),
|
||||
element.GetAttributeString("description1", ""),
|
||||
element.GetAttributeString("description2", "")
|
||||
};
|
||||
|
||||
for (int i = 0; i < descriptions.Length; i++)
|
||||
@@ -73,8 +73,8 @@ namespace Barotrauma
|
||||
|
||||
teamNames = new string[]
|
||||
{
|
||||
ToolBox.GetAttributeString(element, "teamname1", "Team A"),
|
||||
ToolBox.GetAttributeString(element, "teamname2", "Team B")
|
||||
element.GetAttributeString("teamname1", "Team A"),
|
||||
element.GetAttributeString("teamname2", "Team B")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Barotrauma
|
||||
var files = GameMain.SelectedPackage.GetFilesOfType(ContentType.Missions);
|
||||
foreach (string file in files)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(file);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(file);
|
||||
if (doc == null || doc.Root == null) continue;
|
||||
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
@@ -94,26 +94,26 @@ namespace Barotrauma
|
||||
|
||||
public Mission(XElement element, Location[] locations)
|
||||
{
|
||||
name = ToolBox.GetAttributeString(element, "name", "");
|
||||
name = element.GetAttributeString("name", "");
|
||||
|
||||
description = ToolBox.GetAttributeString(element, "description", "");
|
||||
description = element.GetAttributeString("description", "");
|
||||
|
||||
reward = ToolBox.GetAttributeInt(element, "reward", 1);
|
||||
reward = element.GetAttributeInt("reward", 1);
|
||||
|
||||
successMessage = ToolBox.GetAttributeString(element, "successmessage",
|
||||
successMessage = element.GetAttributeString("successmessage",
|
||||
"Mission completed successfully");
|
||||
failureMessage = ToolBox.GetAttributeString(element, "failuremessage",
|
||||
failureMessage = element.GetAttributeString("failuremessage",
|
||||
"Mission failed");
|
||||
|
||||
radarLabel = ToolBox.GetAttributeString(element, "radarlabel", "");
|
||||
radarLabel = element.GetAttributeString("radarlabel", "");
|
||||
|
||||
messages = new List<string>();
|
||||
headers = new List<string>();
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().ToLowerInvariant() != "message") continue;
|
||||
headers.Add(ToolBox.GetAttributeString(subElement, "header", ""));
|
||||
messages.Add(ToolBox.GetAttributeString(subElement, "text", ""));
|
||||
headers.Add(subElement.GetAttributeString("header", ""));
|
||||
messages.Add(subElement.GetAttributeString("text", ""));
|
||||
}
|
||||
|
||||
for (int n = 0; n < 2; n++)
|
||||
@@ -137,7 +137,7 @@ namespace Barotrauma
|
||||
var files = GameMain.SelectedPackage.GetFilesOfType(ContentType.Missions);
|
||||
string configFile = files[rand.Next(files.Count)];
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml(configFile);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile);
|
||||
if (doc == null) return null;
|
||||
|
||||
int eventCount = doc.Root.Elements().Count();
|
||||
@@ -167,17 +167,17 @@ namespace Barotrauma
|
||||
|
||||
if (isSinglePlayer)
|
||||
{
|
||||
matchingElements.RemoveAll(m => ToolBox.GetAttributeBool(m, "multiplayeronly", false));
|
||||
matchingElements.RemoveAll(m => m.GetAttributeBool("multiplayeronly", false));
|
||||
}
|
||||
else
|
||||
{
|
||||
matchingElements.RemoveAll(m => ToolBox.GetAttributeBool(m, "singleplayeronly", false));
|
||||
matchingElements.RemoveAll(m => m.GetAttributeBool("singleplayeronly", false));
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
foreach (XElement element in matchingElements)
|
||||
{
|
||||
eventProbability[i] = ToolBox.GetAttributeInt(element, "commonness", 1);
|
||||
eventProbability[i] = element.GetAttributeInt("commonness", 1);
|
||||
|
||||
probabilitySum += eventProbability[i];
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Barotrauma
|
||||
public MonsterMission(XElement element, Location[] locations)
|
||||
: base(element, locations)
|
||||
{
|
||||
monsterFile = ToolBox.GetAttributeString(element, "monsterfile", "");
|
||||
monsterFile = element.GetAttributeString("monsterfile", "");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace Barotrauma
|
||||
public SalvageMission(XElement element, Location[] locations)
|
||||
: base(element, locations)
|
||||
{
|
||||
string itemName = ToolBox.GetAttributeString(element, "itemname", "");
|
||||
string itemName = element.GetAttributeString("itemname", "");
|
||||
|
||||
itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
|
||||
|
||||
string spawnPositionTypeStr = ToolBox.GetAttributeString(element, "spawntype", "");
|
||||
string spawnPositionTypeStr = element.GetAttributeString("spawntype", "");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(spawnPositionTypeStr) ||
|
||||
!Enum.TryParse<Level.PositionType>(spawnPositionTypeStr, true, out spawnPositionType))
|
||||
|
||||
@@ -39,14 +39,14 @@ namespace Barotrauma
|
||||
public MonsterEvent(XElement element)
|
||||
: base (element)
|
||||
{
|
||||
characterFile = ToolBox.GetAttributeString(element, "characterfile", "");
|
||||
characterFile = element.GetAttributeString("characterfile", "");
|
||||
|
||||
int defaultAmount = ToolBox.GetAttributeInt(element, "amount", 1);
|
||||
int defaultAmount = element.GetAttributeInt("amount", 1);
|
||||
|
||||
minAmount = ToolBox.GetAttributeInt(element, "minamount", defaultAmount);
|
||||
maxAmount = Math.Max(ToolBox.GetAttributeInt(element, "maxamount", 1), minAmount);
|
||||
minAmount = element.GetAttributeInt("minamount", defaultAmount);
|
||||
maxAmount = Math.Max(element.GetAttributeInt("maxamount", 1), minAmount);
|
||||
|
||||
var spawnPosTypeStr = ToolBox.GetAttributeString(element, "spawntype", "");
|
||||
var spawnPosTypeStr = element.GetAttributeString("spawntype", "");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(spawnPosTypeStr) ||
|
||||
!Enum.TryParse<Level.PositionType>(spawnPosTypeStr, true, out spawnPosType))
|
||||
@@ -54,9 +54,9 @@ namespace Barotrauma
|
||||
spawnPosType = Level.PositionType.MainPath;
|
||||
}
|
||||
|
||||
spawnDeep = ToolBox.GetAttributeBool(element, "spawndeep", false);
|
||||
spawnDeep = element.GetAttributeBool("spawndeep", false);
|
||||
|
||||
repeat = ToolBox.GetAttributeBool(element, "repeat", repeat);
|
||||
repeat = element.GetAttributeBool("repeat", repeat);
|
||||
|
||||
if (GameMain.NetworkMember != null)
|
||||
{
|
||||
|
||||
@@ -56,13 +56,13 @@ namespace Barotrauma
|
||||
{
|
||||
configElement = element;
|
||||
|
||||
name = ToolBox.GetAttributeString(element, "name", "");
|
||||
description = ToolBox.GetAttributeString(element, "description", "");
|
||||
name = element.GetAttributeString("name", "");
|
||||
description = element.GetAttributeString("description", "");
|
||||
|
||||
minEventCount = ToolBox.GetAttributeInt(element, "mineventcount", 0);
|
||||
maxEventCount = ToolBox.GetAttributeInt(element, "maxeventcount", 0);
|
||||
minEventCount = element.GetAttributeInt("mineventcount", 0);
|
||||
maxEventCount = element.GetAttributeInt("maxeventcount", 0);
|
||||
|
||||
MusicType = ToolBox.GetAttributeString(element, "musictype", "default");
|
||||
MusicType = element.GetAttributeString("musictype", "default");
|
||||
|
||||
overrideMinEventCount = new Dictionary<string, int>();
|
||||
overrideMaxEventCount = new Dictionary<string, int>();
|
||||
@@ -72,11 +72,11 @@ namespace Barotrauma
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "overrideeventcount":
|
||||
string levelType = ToolBox.GetAttributeString(subElement, "leveltype", "");
|
||||
string levelType = subElement.GetAttributeString("leveltype", "");
|
||||
if (!overrideMinEventCount.ContainsKey(levelType))
|
||||
{
|
||||
overrideMinEventCount.Add(levelType, ToolBox.GetAttributeInt(subElement, "min", 0));
|
||||
overrideMaxEventCount.Add(levelType, ToolBox.GetAttributeInt(subElement, "max", 0));
|
||||
overrideMinEventCount.Add(levelType, subElement.GetAttributeInt("min", 0));
|
||||
overrideMaxEventCount.Add(levelType, subElement.GetAttributeInt("max", 0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (string configFile in configFiles)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(configFile);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile);
|
||||
if (doc == null) continue;
|
||||
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace Barotrauma
|
||||
|
||||
public void Load(XElement element)
|
||||
{
|
||||
Money = ToolBox.GetAttributeInt(element, "money", 0);
|
||||
Money = element.GetAttributeInt("money", 0);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Barotrauma
|
||||
Submarine.MainSub = submarine;
|
||||
|
||||
GameMain.GameSession = this;
|
||||
selectedSub.Name = ToolBox.GetAttributeString(doc.Root, "submarine", selectedSub.Name);
|
||||
selectedSub.Name = doc.Root.GetAttributeString("submarine", selectedSub.Name);
|
||||
#if CLIENT
|
||||
CrewManager = new CrewManager();
|
||||
#endif
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Barotrauma
|
||||
{
|
||||
infoTexts = new Dictionary<string, List<string>>();
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml(file);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(file);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Barotrauma
|
||||
|
||||
public void Load(string filePath)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(filePath);
|
||||
|
||||
if (doc == null)
|
||||
{
|
||||
@@ -37,12 +37,12 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
MasterServerUrl = ToolBox.GetAttributeString(doc.Root, "masterserverurl", "");
|
||||
MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", "");
|
||||
|
||||
AutoCheckUpdates = ToolBox.GetAttributeBool(doc.Root, "autocheckupdates", true);
|
||||
WasGameUpdated = ToolBox.GetAttributeBool(doc.Root, "wasgameupdated", false);
|
||||
AutoCheckUpdates = doc.Root.GetAttributeBool("autocheckupdates", true);
|
||||
WasGameUpdated = doc.Root.GetAttributeBool("wasgameupdated", false);
|
||||
|
||||
VerboseLogging = ToolBox.GetAttributeBool(doc.Root, "verboselogging", false);
|
||||
VerboseLogging = doc.Root.GetAttributeBool("verboselogging", false);
|
||||
|
||||
InitProjSpecific(doc);
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Barotrauma
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "contentpackage":
|
||||
string path = ToolBox.GetAttributeString(subElement, "path", "");
|
||||
string path = subElement.GetAttributeString("path", "");
|
||||
|
||||
|
||||
SelectedContentPackage = ContentPackage.list.Find(cp => cp.Path == path);
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace Barotrauma.Networking
|
||||
XDocument doc = null;
|
||||
if (File.Exists(SettingsFile))
|
||||
{
|
||||
doc = ToolBox.TryLoadXml(SettingsFile);
|
||||
doc = XMLExtensions.TryLoadXml(SettingsFile);
|
||||
}
|
||||
|
||||
if (doc == null || doc.Root == null)
|
||||
@@ -281,7 +281,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
ObjectProperties = ObjectProperty.InitProperties(this, doc.Root);
|
||||
|
||||
AutoRestart = ToolBox.GetAttributeBool(doc.Root, "autorestart", false);
|
||||
AutoRestart = doc.Root.GetAttributeBool("autorestart", false);
|
||||
#if CLIENT
|
||||
if (autoRestart)
|
||||
{
|
||||
@@ -290,15 +290,15 @@ namespace Barotrauma.Networking
|
||||
#endif
|
||||
|
||||
subSelectionMode = SelectionMode.Manual;
|
||||
Enum.TryParse<SelectionMode>(ToolBox.GetAttributeString(doc.Root, "SubSelection", "Manual"), out subSelectionMode);
|
||||
Enum.TryParse<SelectionMode>(doc.Root.GetAttributeString("SubSelection", "Manual"), out subSelectionMode);
|
||||
Voting.AllowSubVoting = subSelectionMode == SelectionMode.Vote;
|
||||
|
||||
modeSelectionMode = SelectionMode.Manual;
|
||||
Enum.TryParse<SelectionMode>(ToolBox.GetAttributeString(doc.Root, "ModeSelection", "Manual"), out modeSelectionMode);
|
||||
Enum.TryParse<SelectionMode>(doc.Root.GetAttributeString("ModeSelection", "Manual"), out modeSelectionMode);
|
||||
Voting.AllowModeVoting = modeSelectionMode == SelectionMode.Vote;
|
||||
|
||||
var traitorsEnabled = TraitorsEnabled;
|
||||
Enum.TryParse<YesNoMaybe>(ToolBox.GetAttributeString(doc.Root, "TraitorsEnabled", "No"), out traitorsEnabled);
|
||||
Enum.TryParse<YesNoMaybe>(doc.Root.GetAttributeString("TraitorsEnabled", "No"), out traitorsEnabled);
|
||||
TraitorsEnabled = traitorsEnabled;
|
||||
GameMain.NetLobbyScreen.SetTraitorsEnabled(traitorsEnabled);
|
||||
|
||||
@@ -308,7 +308,7 @@ namespace Barotrauma.Networking
|
||||
#endif
|
||||
)
|
||||
{
|
||||
GameMain.NetLobbyScreen.ServerMessageText = ToolBox.GetAttributeString(doc.Root, "ServerMessage", "");
|
||||
GameMain.NetLobbyScreen.ServerMessageText = doc.Root.GetAttributeString("ServerMessage", "");
|
||||
}
|
||||
|
||||
#if CLIENT
|
||||
|
||||
@@ -279,11 +279,11 @@ namespace Barotrauma
|
||||
|
||||
public PhysicsBody(XElement element, Vector2 position, float scale=1.0f)
|
||||
{
|
||||
float radius = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "radius", 0.0f)) * scale;
|
||||
float height = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "height", 0.0f)) * scale;
|
||||
float width = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "width", 0.0f)) * scale;
|
||||
float radius = ConvertUnits.ToSimUnits(element.GetAttributeFloat("radius", 0.0f)) * scale;
|
||||
float height = ConvertUnits.ToSimUnits(element.GetAttributeFloat("height", 0.0f)) * scale;
|
||||
float width = ConvertUnits.ToSimUnits(element.GetAttributeFloat("width", 0.0f)) * scale;
|
||||
|
||||
density = ToolBox.GetAttributeFloat(element, "density", 10.0f);
|
||||
density = element.GetAttributeFloat("density", 10.0f);
|
||||
|
||||
CreateBody(width, height, radius, density);
|
||||
|
||||
@@ -292,8 +292,8 @@ namespace Barotrauma
|
||||
body.CollisionCategories = Physics.CollisionItem;
|
||||
body.CollidesWith = Physics.CollisionWall | Physics.CollisionLevel;
|
||||
|
||||
body.Friction = ToolBox.GetAttributeFloat(element, "friction", 0.3f);
|
||||
body.Restitution = ToolBox.GetAttributeFloat(element, "restitution", 0.05f);
|
||||
body.Friction = element.GetAttributeFloat("friction", 0.3f);
|
||||
body.Restitution = element.GetAttributeFloat("restitution", 0.05f);
|
||||
|
||||
body.BodyType = BodyType.Dynamic;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (file == "")
|
||||
{
|
||||
file = ToolBox.GetAttributeString(element, "texture", "");
|
||||
file = element.GetAttributeString("texture", "");
|
||||
}
|
||||
|
||||
if (file == "")
|
||||
@@ -81,7 +81,7 @@ namespace Barotrauma
|
||||
|
||||
this.file = path + file;
|
||||
|
||||
Vector4 sourceVector = ToolBox.GetAttributeVector4(element, "sourcerect", Vector4.Zero);
|
||||
Vector4 sourceVector = element.GetAttributeVector4("sourcerect", Vector4.Zero);
|
||||
|
||||
bool shouldReturn = false;
|
||||
LoadTexture(ref sourceVector, ref shouldReturn);
|
||||
@@ -91,15 +91,15 @@ namespace Barotrauma
|
||||
(int)sourceVector.X, (int)sourceVector.Y,
|
||||
(int)sourceVector.Z, (int)sourceVector.W);
|
||||
|
||||
origin = ToolBox.GetAttributeVector2(element, "origin", new Vector2(0.5f, 0.5f));
|
||||
origin = element.GetAttributeVector2("origin", new Vector2(0.5f, 0.5f));
|
||||
origin.X = origin.X * sourceRect.Width;
|
||||
origin.Y = origin.Y * sourceRect.Height;
|
||||
|
||||
size = ToolBox.GetAttributeVector2(element, "size", Vector2.One);
|
||||
size = element.GetAttributeVector2("size", Vector2.One);
|
||||
size.X *= sourceRect.Width;
|
||||
size.Y *= sourceRect.Height;
|
||||
|
||||
Depth = ToolBox.GetAttributeFloat(element, "depth", 0.0f);
|
||||
Depth = element.GetAttributeFloat("depth", 0.0f);
|
||||
|
||||
list.Add(this);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace Barotrauma
|
||||
public SpriteSheet(XElement element, string path = "", string file = "")
|
||||
: base(element, path, file)
|
||||
{
|
||||
int columnCount = Math.Max(ToolBox.GetAttributeInt(element, "columns", 1), 1);
|
||||
int rowCount = Math.Max(ToolBox.GetAttributeInt(element, "rows", 1), 1);
|
||||
int columnCount = Math.Max(element.GetAttributeInt("columns", 1), 1);
|
||||
int rowCount = Math.Max(element.GetAttributeInt("rows", 1), 1);
|
||||
|
||||
sourceRects = new Rectangle[rowCount * columnCount];
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
origin = ToolBox.GetAttributeVector2(element, "origin", new Vector2(0.5f, 0.5f));
|
||||
origin = element.GetAttributeVector2("origin", new Vector2(0.5f, 0.5f));
|
||||
origin.X = origin.X * cellWidth;
|
||||
origin.Y = origin.Y * cellHeight;
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ namespace Barotrauma
|
||||
{
|
||||
DecompressToDirectory(filePath, TempPath, null);
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml(Path.Combine(TempPath, "gamesession.xml"));
|
||||
XDocument doc = XMLExtensions.TryLoadXml(Path.Combine(TempPath, "gamesession.xml"));
|
||||
|
||||
string subPath = Path.Combine(TempPath, ToolBox.GetAttributeString(doc.Root, "submarine", "")) + ".sub";
|
||||
string subPath = Path.Combine(TempPath, doc.Root.GetAttributeString("submarine", "")) + ".sub";
|
||||
Submarine selectedSub = new Submarine(subPath, "");
|
||||
GameMain.GameSession = new GameSession(selectedSub, filePath, doc);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace Barotrauma
|
||||
public static void LoadGame(string filePath, GameSession gameSession)
|
||||
{
|
||||
DecompressToDirectory(filePath, TempPath, null);
|
||||
XDocument doc = ToolBox.TryLoadXml(Path.Combine(TempPath, "gamesession.xml"));
|
||||
XDocument doc = XMLExtensions.TryLoadXml(Path.Combine(TempPath, "gamesession.xml"));
|
||||
gameSession.Load(doc.Root);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Barotrauma
|
||||
return null;
|
||||
}
|
||||
|
||||
return ToolBox.TryLoadXml(Path.Combine(tempPath, "gamesession.xml"));
|
||||
return XMLExtensions.TryLoadXml(Path.Combine(tempPath, "gamesession.xml"));
|
||||
}
|
||||
|
||||
public static void DeleteSave(string filePath)
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
using Lidgren.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -27,6 +23,7 @@ namespace Barotrauma
|
||||
|
||||
public static partial class ToolBox
|
||||
{
|
||||
|
||||
public static bool IsProperFilenameCase(string filename)
|
||||
{
|
||||
char[] delimiters = { '/','\\' };
|
||||
@@ -70,339 +67,6 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
public static XDocument TryLoadXml(string filePath)
|
||||
{
|
||||
XDocument doc;
|
||||
try
|
||||
{
|
||||
IsProperFilenameCase(filePath);
|
||||
doc = XDocument.Load(filePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Couldn't load xml document \""+filePath+"\"!", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (doc.Root == null) return null;
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
/*public static SpriteFont TryLoadFont(string file, Microsoft.Xna.Framework.Content.ContentManager contentManager)
|
||||
{
|
||||
SpriteFont font = null;
|
||||
try
|
||||
{
|
||||
font = contentManager.Load<SpriteFont>(file);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Loading font \""+file+"\" failed", e);
|
||||
}
|
||||
|
||||
return font;
|
||||
}*/
|
||||
|
||||
public static object GetAttributeObject(XElement element, string name)
|
||||
{
|
||||
if (element == null || element.Attribute(name) == null) return null;
|
||||
return GetAttributeObject(element.Attribute(name));
|
||||
}
|
||||
|
||||
public static object GetAttributeObject(XAttribute attribute)
|
||||
{
|
||||
if (attribute == null) return null;
|
||||
|
||||
return ParseToObject(attribute.Value.ToString());
|
||||
}
|
||||
|
||||
public static object ParseToObject(string value)
|
||||
{
|
||||
float floatVal;
|
||||
int intVal;
|
||||
if (value.ToString().Contains(".") && float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out floatVal))
|
||||
{
|
||||
return floatVal;
|
||||
}
|
||||
else if (int.TryParse(value, out intVal))
|
||||
{
|
||||
return intVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
string lowerTrimmedVal = value.ToLowerInvariant().Trim();
|
||||
if (lowerTrimmedVal == "true")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (lowerTrimmedVal == "false")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static string GetAttributeString(XElement element, string name, string defaultValue)
|
||||
{
|
||||
if (element == null || element.Attribute(name) == null) return defaultValue;
|
||||
return GetAttributeString(element.Attribute(name), defaultValue);
|
||||
}
|
||||
|
||||
public static string GetAttributeString(XAttribute attribute, string defaultValue)
|
||||
{
|
||||
string value = attribute.Value;
|
||||
if (String.IsNullOrEmpty(value)) return defaultValue;
|
||||
return value;
|
||||
}
|
||||
|
||||
public static float GetAttributeFloat(XElement element, float defaultValue, params string[] matchingAttributeName)
|
||||
{
|
||||
if (element == null) return defaultValue;
|
||||
|
||||
foreach (string name in matchingAttributeName)
|
||||
{
|
||||
if (element.Attribute(name) == null) continue;
|
||||
|
||||
float val = defaultValue;
|
||||
|
||||
try
|
||||
{
|
||||
if (!float.TryParse(element.Attribute(name).Value, NumberStyles.Float, CultureInfo.InvariantCulture, out val))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in "+element+"!", e);
|
||||
continue;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static float GetAttributeFloat(XElement element, string name, float defaultValue)
|
||||
{
|
||||
if (element == null || element.Attribute(name) == null) return defaultValue;
|
||||
|
||||
float val = defaultValue;
|
||||
|
||||
try
|
||||
{
|
||||
if (!float.TryParse(element.Attribute(name).Value, NumberStyles.Float, CultureInfo.InvariantCulture, out val))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in "+element+"!", e);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
public static float GetAttributeFloat(XAttribute attribute, float defaultValue)
|
||||
{
|
||||
if (attribute == null) return defaultValue;
|
||||
|
||||
float val = defaultValue;
|
||||
|
||||
try
|
||||
{
|
||||
val = float.Parse(attribute.Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in " + attribute + "! ", e);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
public static int GetAttributeInt(XElement element, string name, int defaultValue)
|
||||
{
|
||||
if (element == null || element.Attribute(name) == null) return defaultValue;
|
||||
|
||||
int val = defaultValue;
|
||||
|
||||
try
|
||||
{
|
||||
val = int.Parse(element.Attribute(name).Value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in " + element + "! ", e);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
public static bool GetAttributeBool(XElement element, string name, bool defaultValue)
|
||||
{
|
||||
if (element == null || element.Attribute(name) == null) return defaultValue;
|
||||
|
||||
return GetAttributeBool(element.Attribute(name), defaultValue);
|
||||
}
|
||||
|
||||
public static bool GetAttributeBool(XAttribute attribute, bool defaultValue)
|
||||
{
|
||||
if (attribute == null) return defaultValue;
|
||||
|
||||
string val = attribute.Value.ToLowerInvariant().Trim();
|
||||
if (val == "true")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (val == "false")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ThrowError("Error in " + attribute.Value.ToString() + "! \"" + val + "\" is not a valid boolean value");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Vector2 GetAttributeVector2(XElement element, string name, Vector2 defaultValue)
|
||||
{
|
||||
if (element == null || element.Attribute(name) == null) return defaultValue;
|
||||
|
||||
string val = element.Attribute(name).Value;
|
||||
|
||||
return ParseToVector2(val);
|
||||
}
|
||||
|
||||
public static Vector3 GetAttributeVector3(XElement element, string name, Vector3 defaultValue)
|
||||
{
|
||||
if (element == null || element.Attribute(name) == null) return defaultValue;
|
||||
|
||||
string val = element.Attribute(name).Value;
|
||||
|
||||
return ParseToVector3(val);
|
||||
}
|
||||
|
||||
public static Vector4 GetAttributeVector4(XElement element, string name, Vector4 defaultValue)
|
||||
{
|
||||
if (element == null || element.Attribute(name) == null) return defaultValue;
|
||||
|
||||
string val = element.Attribute(name).Value;
|
||||
|
||||
return ParseToVector4(val);
|
||||
}
|
||||
|
||||
public static string ElementInnerText(this XElement el)
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
foreach (XNode element in el.DescendantNodes().Where(x => x.NodeType == XmlNodeType.Text))
|
||||
{
|
||||
str.Append(element.ToString());
|
||||
}
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static Vector2 ParseToVector2(string stringVector2, bool errorMessages = true)
|
||||
{
|
||||
string[] components = stringVector2.Split(',');
|
||||
|
||||
Vector2 vector = Vector2.Zero;
|
||||
|
||||
if (components.Length!=2)
|
||||
{
|
||||
if (!errorMessages) return vector;
|
||||
DebugConsole.ThrowError("Failed to parse the string \""+stringVector2+"\" to Vector2");
|
||||
return vector;
|
||||
}
|
||||
|
||||
float.TryParse(components[0], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.X);
|
||||
float.TryParse(components[1], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.Y);
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
public static string Vector2ToString(Vector2 vector)
|
||||
{
|
||||
return vector.X.ToString("G", CultureInfo.InvariantCulture) + "," + vector.Y.ToString("G", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static Vector3 ParseToVector3(string stringVector3, bool errorMessages = true)
|
||||
{
|
||||
string[] components = stringVector3.Split(',');
|
||||
|
||||
Vector3 vector = Vector3.Zero;
|
||||
|
||||
if (components.Length!=3)
|
||||
{
|
||||
if (!errorMessages) return vector;
|
||||
DebugConsole.ThrowError("Failed to parse the string \""+stringVector3+"\" to Vector3");
|
||||
return vector;
|
||||
}
|
||||
|
||||
float.TryParse(components[0], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.X);
|
||||
float.TryParse(components[1], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.Y);
|
||||
float.TryParse(components[2], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.Z);
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
public static Vector4 ParseToVector4(string stringVector4, bool errorMessages = true)
|
||||
{
|
||||
string[] components = stringVector4.Split(',');
|
||||
|
||||
Vector4 vector = Vector4.Zero;
|
||||
|
||||
if (components.Length < 3)
|
||||
{
|
||||
if (errorMessages) DebugConsole.ThrowError("Failed to parse the string \"" + stringVector4 + "\" to Vector4");
|
||||
return vector;
|
||||
}
|
||||
|
||||
float.TryParse(components[0], NumberStyles.Float, CultureInfo.InvariantCulture, out vector.X);
|
||||
float.TryParse(components[1], NumberStyles.Float, CultureInfo.InvariantCulture, out vector.Y);
|
||||
float.TryParse(components[2], NumberStyles.Float, CultureInfo.InvariantCulture, out vector.Z);
|
||||
if (components.Length>3)
|
||||
float.TryParse(components[3], NumberStyles.Float, CultureInfo.InvariantCulture, out vector.W);
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
public static string Vector4ToString(Vector4 vector, string format = "G")
|
||||
{
|
||||
return vector.X.ToString(format, CultureInfo.InvariantCulture) + "," +
|
||||
vector.Y.ToString(format, CultureInfo.InvariantCulture) + "," +
|
||||
vector.Z.ToString(format, CultureInfo.InvariantCulture) + "," +
|
||||
vector.W.ToString(format, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static float[] ParseArrayToFloat(string[] stringArray)
|
||||
{
|
||||
if (stringArray == null || stringArray.Length == 0) return null;
|
||||
|
||||
float[] floatArray = new float[stringArray.Length];
|
||||
for (int i = 0; i<floatArray.Length; i++)
|
||||
{
|
||||
floatArray[i]=0.0f;
|
||||
float.TryParse(stringArray[i], NumberStyles.Float, CultureInfo.InvariantCulture, out floatArray[i]);
|
||||
}
|
||||
|
||||
return floatArray;
|
||||
}
|
||||
|
||||
public static string LimitString(string str, int maxCharacters)
|
||||
{
|
||||
if (str == null || maxCharacters < 0) return null;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (XElement file in fileListElement.Elements())
|
||||
{
|
||||
string filePath = ToolBox.GetAttributeString(file, "path", "");
|
||||
string filePath = file.GetAttributeString("path", "");
|
||||
|
||||
fileList.Add(filePath);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (XElement file in fileList.Elements())
|
||||
{
|
||||
string filePath = ToolBox.GetAttributeString(file, "path", "");
|
||||
string filePath = file.GetAttributeString("path", "");
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
@@ -79,7 +79,7 @@ namespace Barotrauma
|
||||
continue;
|
||||
}
|
||||
|
||||
string md5 = ToolBox.GetAttributeString(file, "md5", "");
|
||||
string md5 = file.GetAttributeString("md5", "");
|
||||
|
||||
if (GetFileMd5Hash(filePath) != md5)
|
||||
{
|
||||
|
||||
314
Barotrauma/BarotraumaShared/Source/Utils/XMLExtensions.cs
Normal file
314
Barotrauma/BarotraumaShared/Source/Utils/XMLExtensions.cs
Normal file
@@ -0,0 +1,314 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public static class XMLExtensions
|
||||
{
|
||||
public static XDocument TryLoadXml(string filePath)
|
||||
{
|
||||
XDocument doc;
|
||||
try
|
||||
{
|
||||
ToolBox.IsProperFilenameCase(filePath);
|
||||
doc = XDocument.Load(filePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Couldn't load xml document \"" + filePath + "\"!", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (doc.Root == null) return null;
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
public static object GetAttributeObject(XAttribute attribute)
|
||||
{
|
||||
if (attribute == null) return null;
|
||||
|
||||
return ParseToObject(attribute.Value.ToString());
|
||||
}
|
||||
|
||||
public static object ParseToObject(string value)
|
||||
{
|
||||
float floatVal;
|
||||
int intVal;
|
||||
if (value.Contains(".") && Single.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out floatVal))
|
||||
{
|
||||
return floatVal;
|
||||
}
|
||||
if (Int32.TryParse(value, out intVal))
|
||||
{
|
||||
return intVal;
|
||||
}
|
||||
|
||||
string lowerTrimmedVal = value.ToLowerInvariant().Trim();
|
||||
if (lowerTrimmedVal == "true")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (lowerTrimmedVal == "false")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public static string GetAttributeString(this XElement element, string name, string defaultValue)
|
||||
{
|
||||
if (element?.Attribute(name) == null) return defaultValue;
|
||||
return GetAttributeString(element.Attribute(name), defaultValue);
|
||||
}
|
||||
|
||||
private static string GetAttributeString(XAttribute attribute, string defaultValue)
|
||||
{
|
||||
string value = attribute.Value;
|
||||
return String.IsNullOrEmpty(value) ? defaultValue : value;
|
||||
}
|
||||
|
||||
public static float GetAttributeFloat(this XElement element, float defaultValue, params string[] matchingAttributeName)
|
||||
{
|
||||
if (element == null) return defaultValue;
|
||||
|
||||
foreach (string name in matchingAttributeName)
|
||||
{
|
||||
if (element.Attribute(name) == null) continue;
|
||||
|
||||
float val;
|
||||
|
||||
try
|
||||
{
|
||||
if (!Single.TryParse(element.Attribute(name).Value, NumberStyles.Float, CultureInfo.InvariantCulture, out val))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in " + element + "!", e);
|
||||
continue;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static float GetAttributeFloat(this XElement element, string name, float defaultValue)
|
||||
{
|
||||
if (element?.Attribute(name) == null) return defaultValue;
|
||||
|
||||
float val = defaultValue;
|
||||
|
||||
try
|
||||
{
|
||||
if (!Single.TryParse(element.Attribute(name).Value, NumberStyles.Float, CultureInfo.InvariantCulture, out val))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in " + element + "!", e);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
public static float GetAttributeFloat(this XAttribute attribute, float defaultValue)
|
||||
{
|
||||
if (attribute == null) return defaultValue;
|
||||
|
||||
float val = defaultValue;
|
||||
|
||||
try
|
||||
{
|
||||
val = Single.Parse(attribute.Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in " + attribute + "! ", e);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
public static int GetAttributeInt(this XElement element, string name, int defaultValue)
|
||||
{
|
||||
if (element?.Attribute(name) == null) return defaultValue;
|
||||
|
||||
int val = defaultValue;
|
||||
|
||||
try
|
||||
{
|
||||
val = Int32.Parse(element.Attribute(name).Value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in " + element + "! ", e);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
public static bool GetAttributeBool(this XElement element, string name, bool defaultValue)
|
||||
{
|
||||
if (element?.Attribute(name) == null) return defaultValue;
|
||||
|
||||
return element.Attribute(name).GetAttributeBool(defaultValue);
|
||||
}
|
||||
|
||||
public static bool GetAttributeBool(this XAttribute attribute, bool defaultValue)
|
||||
{
|
||||
if (attribute == null) return defaultValue;
|
||||
|
||||
string val = attribute.Value.ToLowerInvariant().Trim();
|
||||
if (val == "true")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (val == "false")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DebugConsole.ThrowError("Error in " + attribute.Value.ToString() + "! \"" + val + "\" is not a valid boolean value");
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Vector2 GetAttributeVector2(this XElement element, string name, Vector2 defaultValue)
|
||||
{
|
||||
if (element?.Attribute(name) == null) return defaultValue;
|
||||
|
||||
string val = element.Attribute(name).Value;
|
||||
|
||||
return ParseToVector2(val);
|
||||
}
|
||||
|
||||
public static Vector3 GetAttributeVector3(this XElement element, string name, Vector3 defaultValue)
|
||||
{
|
||||
if (element == null || element.Attribute(name) == null) return defaultValue;
|
||||
|
||||
string val = element.Attribute(name).Value;
|
||||
|
||||
return ParseToVector3(val);
|
||||
}
|
||||
|
||||
public static Vector4 GetAttributeVector4(this XElement element, string name, Vector4 defaultValue)
|
||||
{
|
||||
if (element == null || element.Attribute(name) == null) return defaultValue;
|
||||
|
||||
string val = element.Attribute(name).Value;
|
||||
|
||||
return ParseToVector4(val);
|
||||
}
|
||||
|
||||
public static string ElementInnerText(this XElement el)
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
foreach (XNode element in el.DescendantNodes().Where(x => x.NodeType == XmlNodeType.Text))
|
||||
{
|
||||
str.Append(element.ToString());
|
||||
}
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
|
||||
public static Vector2 ParseToVector2(string stringVector2, bool errorMessages = true)
|
||||
{
|
||||
string[] components = stringVector2.Split(',');
|
||||
|
||||
Vector2 vector = Vector2.Zero;
|
||||
|
||||
if (components.Length != 2)
|
||||
{
|
||||
if (!errorMessages) return vector;
|
||||
DebugConsole.ThrowError("Failed to parse the string \"" + stringVector2 + "\" to Vector2");
|
||||
return vector;
|
||||
}
|
||||
|
||||
Single.TryParse(components[0], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.X);
|
||||
Single.TryParse(components[1], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.Y);
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
public static string Vector2ToString(Vector2 vector)
|
||||
{
|
||||
return vector.X.ToString("G", CultureInfo.InvariantCulture) + "," + vector.Y.ToString("G", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static Vector3 ParseToVector3(string stringVector3, bool errorMessages = true)
|
||||
{
|
||||
string[] components = stringVector3.Split(',');
|
||||
|
||||
Vector3 vector = Vector3.Zero;
|
||||
|
||||
if (components.Length != 3)
|
||||
{
|
||||
if (!errorMessages) return vector;
|
||||
DebugConsole.ThrowError("Failed to parse the string \"" + stringVector3 + "\" to Vector3");
|
||||
return vector;
|
||||
}
|
||||
|
||||
Single.TryParse(components[0], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.X);
|
||||
Single.TryParse(components[1], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.Y);
|
||||
Single.TryParse(components[2], NumberStyles.Any, CultureInfo.InvariantCulture, out vector.Z);
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
public static Vector4 ParseToVector4(string stringVector4, bool errorMessages = true)
|
||||
{
|
||||
string[] components = stringVector4.Split(',');
|
||||
|
||||
Vector4 vector = Vector4.Zero;
|
||||
|
||||
if (components.Length < 3)
|
||||
{
|
||||
if (errorMessages) DebugConsole.ThrowError("Failed to parse the string \"" + stringVector4 + "\" to Vector4");
|
||||
return vector;
|
||||
}
|
||||
|
||||
Single.TryParse(components[0], NumberStyles.Float, CultureInfo.InvariantCulture, out vector.X);
|
||||
Single.TryParse(components[1], NumberStyles.Float, CultureInfo.InvariantCulture, out vector.Y);
|
||||
Single.TryParse(components[2], NumberStyles.Float, CultureInfo.InvariantCulture, out vector.Z);
|
||||
if (components.Length > 3)
|
||||
Single.TryParse(components[3], NumberStyles.Float, CultureInfo.InvariantCulture, out vector.W);
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
public static string Vector4ToString(Vector4 vector, string format = "G")
|
||||
{
|
||||
return vector.X.ToString(format, CultureInfo.InvariantCulture) + "," +
|
||||
vector.Y.ToString(format, CultureInfo.InvariantCulture) + "," +
|
||||
vector.Z.ToString(format, CultureInfo.InvariantCulture) + "," +
|
||||
vector.W.ToString(format, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static float[] ParseArrayToFloat(string[] stringArray)
|
||||
{
|
||||
if (stringArray == null || stringArray.Length == 0) return null;
|
||||
|
||||
float[] floatArray = new float[stringArray.Length];
|
||||
for (int i = 0; i < floatArray.Length; i++)
|
||||
{
|
||||
floatArray[i] = 0.0f;
|
||||
Single.TryParse(stringArray[i], NumberStyles.Float, CultureInfo.InvariantCulture, out floatArray[i]);
|
||||
}
|
||||
|
||||
return floatArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -408,9 +408,9 @@ namespace Launcher
|
||||
Version currentVersion = new Version(version);
|
||||
|
||||
|
||||
string latestVersionStr = ToolBox.GetAttributeString(doc.Root, "latestversion", "");
|
||||
latestVersionFolder = ToolBox.GetAttributeString(doc.Root, "latestversionfolder", "");
|
||||
latestVersionFileList = ToolBox.GetAttributeString(doc.Root, "latestversionfilelist", "");
|
||||
string latestVersionStr = doc.Root.GetAttributeString("latestversion", "");
|
||||
latestVersionFolder = doc.Root.GetAttributeString("latestversionfolder", "");
|
||||
latestVersionFileList = doc.Root.GetAttributeString("latestversionfilelist", "");
|
||||
|
||||
|
||||
Version latestVersion = new Version(latestVersionStr);
|
||||
@@ -435,7 +435,7 @@ namespace Launcher
|
||||
|
||||
foreach (XElement patchNote in patchNotes.Elements())
|
||||
{
|
||||
string patchNumber = ToolBox.GetAttributeString(patchNote, "version", "");
|
||||
string patchNumber = patchNote.GetAttributeString("version", "");
|
||||
|
||||
//read the patch notes until we reach the user's version
|
||||
if (patchNumber == version) break;
|
||||
@@ -443,7 +443,7 @@ namespace Launcher
|
||||
Version patchVersion = new Version(patchNumber);
|
||||
if (currentVersion.CompareTo(patchVersion) >= 0) break;
|
||||
|
||||
string innerText = ToolBox.ElementInnerText(patchNote);
|
||||
string innerText = patchNote.ElementInnerText();
|
||||
|
||||
innerText = innerText.Replace("\r\n", "\n");
|
||||
innerText = innerText.Replace("\t", "");
|
||||
@@ -488,7 +488,7 @@ namespace Launcher
|
||||
latestVersionFiles = UpdaterUtil.GetFileList(doc);
|
||||
filesToDownload = UpdaterUtil.GetRequiredFiles(doc);
|
||||
|
||||
string updaterVersion = ToolBox.GetAttributeString(doc.Root, "updaterversion", "1.1");
|
||||
string updaterVersion = doc.Root.GetAttributeString("updaterversion", "1.1");
|
||||
if (updaterVersion!=UpdaterUtil.Version)
|
||||
{
|
||||
ShowError("Warning", "The update may contain changes which can't be installed by the autoupdater. If you receive any error messages during the install, please download and install the update manually.");
|
||||
|
||||
Reference in New Issue
Block a user