Vertical docking port, docking sounds, water flows properly between horizontally docked hulls, falseoutput of signal check components can be changed, lighting and FOW works between hulls (todo: some logic for determining when to update light.HullsInRange when two subs are moving relative to each other)

This commit is contained in:
Regalis
2016-06-27 17:48:20 +03:00
parent b04e204dc3
commit 38c5251005
19 changed files with 291 additions and 116 deletions
+29 -15
View File
@@ -173,8 +173,6 @@ namespace Barotrauma
{
Vector2 center = new Vector2(WorldRect.X + rect.Width / 2.0f, -(WorldRect.Y - rect.Height/ 2.0f));
GUI.DrawLine(sb, center, center + new Vector2(flowForce.X, -flowForce.Y)/10.0f, Color.Red);
GUI.DrawLine(sb, center + Vector2.One * 5.0f, center + new Vector2(lerpedFlowForce.X, -lerpedFlowForce.Y) / 10.0f + Vector2.One * 5.0f, Color.Orange);
@@ -329,6 +327,18 @@ namespace Barotrauma
if (linkedTo.Count < 2) return;
Hull hull1 = (Hull)linkedTo[0];
Hull hull2 = (Hull)linkedTo[1];
Vector2 subOffset = Vector2.Zero;
if (hull1.Submarine != Submarine)
{
subOffset =Submarine.Position - hull1.Submarine.Position;
}
else if (hull2.Submarine != Submarine)
{
subOffset = hull2.Submarine.Position - Submarine.Position;
}
if (hull1.Volume == 0.0 && hull2.Volume == 0.0) return;
@@ -341,13 +351,14 @@ namespace Barotrauma
//horizontal gap (such as a regular door)
if (isHorizontal)
{
higherSurface = Math.Max(hull1.Surface,hull2.Surface);
float delta=0.0f;
higherSurface = Math.Max(hull1.Surface, hull2.Surface + subOffset.Y);
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+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) ? 1 : -1;
int dir = (hull1.Pressure > hull2.Pressure+subOffset.Y) ? 1 : -1;
//water flowing from the righthand room to the lefthand room
if (dir == -1)
@@ -360,38 +371,42 @@ namespace Barotrauma
flowTargetHull = hull1;
//make sure not to move more than what the room contains
delta = Math.Min((hull2.Pressure - hull1.Pressure) * 5.0f * sizeModifier, Math.Min(hull2.Volume, hull2.FullVolume));
delta = Math.Min(((hull2.Pressure + subOffset.Y) - hull1.Pressure) * 5.0f * sizeModifier, Math.Min(hull2.Volume, hull2.FullVolume));
//make sure not to place more water to the target room than it can hold
delta = Math.Min(delta, hull1.FullVolume + Hull.MaxCompress - (hull1.Volume));
hull1.Volume += delta;
hull2.Volume -= delta;
if (hull1.Volume > hull1.FullVolume)
hull1.Pressure = Math.Max(hull1.Pressure, (hull1.Pressure + hull2.Pressure) / 2);
{
hull1.Pressure = Math.Max(hull1.Pressure, (hull1.Pressure + hull2.Pressure+subOffset.Y) / 2);
}
flowForce = new Vector2(-delta, 0.0f);
}
else if (dir == 1)
{
if (!(hull1.Volume > 0.0f)) return;
lowerSurface = hull2.Surface - hull2.WaveY[1];
//lowerSurface = hull2.Surface - hull2.WaveY[1];
flowTargetHull = hull2;
//make sure not to move more than what the room contains
delta = Math.Min((hull1.Pressure - hull2.Pressure) * 5.0f * sizeModifier, Math.Min(hull1.Volume, hull1.FullVolume));
delta = Math.Min((hull1.Pressure - (hull2.Pressure + subOffset.Y)) * 5.0f * sizeModifier, Math.Min(hull1.Volume, hull1.FullVolume));
//make sure not to place more water to the target room than it can hold
delta = Math.Min(delta, hull2.FullVolume + Hull.MaxCompress - (hull2.Volume));
hull1.Volume -= delta;
hull2.Volume += delta;
if (hull2.Volume > hull2.FullVolume)
hull2.Pressure = Math.Max(hull2.Pressure, (hull1.Pressure + hull2.Pressure) / 2);
{
hull2.Pressure = Math.Max(hull2.Pressure, ((hull1.Pressure-subOffset.Y) + hull2.Pressure) / 2);
}
flowForce = new Vector2(delta, 0.0f);
}
if (delta>100.0f)
if (delta>100.0f && subOffset == Vector2.Zero)
{
float avg = (hull1.Surface + hull2.Surface) / 2.0f;
//float avgVel = (hull2.WaveVel[1] + hull1.WaveVel[hull1.WaveY.Length - 2]) / 2.0f;
@@ -625,10 +640,9 @@ namespace Barotrauma
GapList.Remove(this);
foreach (MapEntity entity in linkedTo)
foreach (Hull hull in Hull.hullList)
{
var hull = entity as Hull;
if (hull.ConnectedGaps.Contains(this)) hull.ConnectedGaps.Remove(this);
hull.ConnectedGaps.Remove(this);
}
}