Unstable 0.1300.0.9

This commit is contained in:
Markus Isberg
2021-04-13 16:58:13 +03:00
parent 86597456ca
commit f48dfb5862
30 changed files with 245 additions and 57 deletions
@@ -464,6 +464,49 @@ namespace Barotrauma
}
}
/// <summary>
/// Calculated from <see cref="SubmarineElement"/>. Can be used when the sub hasn't been loaded and we can't access <see cref="Submarine.RealWorldCrushDepth"/>.
/// </summary>
public float GetRealWorldCrushDepth()
{
if (SubmarineElement == null) { return Level.DefaultRealWorldCrushDepth; }
bool structureCrushDepthsDefined = false;
float realWorldCrushDepth = float.PositiveInfinity;
foreach (var structureElement in SubmarineElement.GetChildElements("structure"))
{
string name = structureElement.Attribute("name")?.Value ?? "";
string identifier = structureElement.GetAttributeString("identifier", "");
var structurePrefab = Structure.FindPrefab(name, identifier);
if (structurePrefab == null || !structurePrefab.Body) { continue; }
if (!structureCrushDepthsDefined && structureElement.Attribute("crushdepth") != null)
{
structureCrushDepthsDefined = true;
}
float structureCrushDepth = structureElement.GetAttributeFloat("crushdepth", float.PositiveInfinity);
realWorldCrushDepth = Math.Min(structureCrushDepth, realWorldCrushDepth);
}
if (!structureCrushDepthsDefined)
{
realWorldCrushDepth = Level.DefaultRealWorldCrushDepth;
}
realWorldCrushDepth *= GetRealWorldCrushDepthMultiplier();
return realWorldCrushDepth;
}
/// <summary>
/// Based on <see cref="SubmarineClass"/>
/// </summary>
public float GetRealWorldCrushDepthMultiplier()
{
if (SubmarineClass == SubmarineClass.DeepDiver)
{
return 1.2f;
}
else
{
return 1.0f;
}
}
//saving/loading ----------------------------------------------------
public bool SaveAs(string filePath, System.IO.MemoryStream previewImage = null)