Unstable 1.2.1.0

This commit is contained in:
Markus Isberg
2023-11-10 17:45:19 +02:00
parent 2ea58c58a7
commit 8a2e2ea0ae
268 changed files with 4076 additions and 1843 deletions
@@ -109,6 +109,8 @@ namespace Barotrauma
public float Size => IsHorizontal ? Rect.Height : Rect.Width;
public float PressureDistributionSpeed => Size / 100.0f * open;
private Door connectedDoor;
public Door ConnectedDoor
{
@@ -427,11 +429,9 @@ namespace Barotrauma
if (hull1.WaterVolume <= 0.0 && hull2.WaterVolume <= 0.0) { return; }
float size = IsHorizontal ? rect.Height : rect.Width;
//a variable affecting the water flow through the gap
//the larger the gap is, the faster the water flows
float sizeModifier = size / 100.0f * open;
float sizeModifier = Size / 100.0f * open;
//horizontal gap (such as a regular door)
if (IsHorizontal)
@@ -440,7 +440,7 @@ namespace Barotrauma
float delta = 0.0f;
//water level is above the lower boundary of the gap
if (Math.Max(hull1.Surface + hull1.WaveY[hull1.WaveY.Length - 1], hull2.Surface + subOffset.Y + hull2.WaveY[0]) > rect.Y - size)
if (Math.Max(hull1.Surface + hull1.WaveY[hull1.WaveY.Length - 1], hull2.Surface + subOffset.Y + hull2.WaveY[0]) > rect.Y - Size)
{
int dir = (hull1.Pressure > hull2.Pressure + subOffset.Y) ? 1 : -1;
@@ -569,27 +569,35 @@ namespace Barotrauma
if (open > 0.0f)
{
if (hull1.WaterVolume > hull1.Volume / Hull.MaxCompress && hull2.WaterVolume > hull2.Volume / Hull.MaxCompress)
if (hull1.WaterVolume > hull1.Volume / Hull.MaxCompress &&
hull2.WaterVolume > hull2.Volume / Hull.MaxCompress)
{
//both hulls full -> distribute pressure
float avgLethality = (hull1.LethalPressure + hull2.LethalPressure) / 2.0f;
hull1.LethalPressure = avgLethality;
hull2.LethalPressure = avgLethality;
changePressure(hull1, avgLethality, PressureDistributionSpeed, deltaTime);
changePressure(hull2, avgLethality, PressureDistributionSpeed, deltaTime);
static void changePressure(Hull hull, float target, float speed, float deltaTime)
{
float diff = target - hull.LethalPressure;
float maxChange = Hull.PressureBuildUpSpeed * speed * deltaTime;
hull.LethalPressure += MathHelper.Clamp(diff, -maxChange, maxChange);
}
}
else
{
hull1.LethalPressure -= Hull.PressureDropSpeed * deltaTime;
hull2.LethalPressure -= Hull.PressureDropSpeed * deltaTime;
//either hull not full -> pressure drops
hull1.LethalPressure -= Hull.PressureDropSpeed * PressureDistributionSpeed * deltaTime;
hull2.LethalPressure -= Hull.PressureDropSpeed * PressureDistributionSpeed * deltaTime;
}
}
}
void UpdateRoomToOut(float deltaTime, Hull hull1)
{
float size = IsHorizontal ? rect.Height : rect.Width;
//a variable affecting the water flow through the gap
//the larger the gap is, the faster the water flows
float sizeModifier = size * open * open;
float sizeModifier = Size * open * open;
float delta = 500.0f * sizeModifier * deltaTime;
@@ -642,7 +650,7 @@ namespace Barotrauma
}
else
{
hull1.LethalPressure += ((Submarine != null && Submarine.AtDamageDepth) ? 100.0f : Hull.PressureBuildUpSpeed) * deltaTime;
hull1.LethalPressure += ((Submarine != null && Submarine.AtDamageDepth) ? 100.0f : Hull.PressureBuildUpSpeed) * PressureDistributionSpeed * deltaTime;
}
}
else
@@ -657,7 +665,7 @@ namespace Barotrauma
}
if (hull1.WaterVolume >= hull1.Volume / Hull.MaxCompress)
{
hull1.LethalPressure += ((Submarine != null && Submarine.AtDamageDepth) ? 100.0f : Hull.PressureBuildUpSpeed) * deltaTime;
hull1.LethalPressure += ((Submarine != null && Submarine.AtDamageDepth) ? 100.0f : Hull.PressureBuildUpSpeed) * PressureDistributionSpeed * deltaTime;
}
}
}