Water flow logic tweaking:

- Less fluctuation, water doesn't constantly flow back and forth through gaps.
- Flowing water pushes characters around much more heavily, and the force is applied to the collider in addition to the limbs.
- Vertical gaps don't push characters up/down unless the character is roughly above/below the gap.

+ Renamed some fields in the hull and gap classes (Volume -> WaterVolume, FullVolume -> Volume, public fields start with a capital letter)
This commit is contained in:
Joonas Rikkonen
2017-10-10 00:34:54 +03:00
parent c444186426
commit f46dc5da28
26 changed files with 190 additions and 203 deletions
@@ -106,7 +106,7 @@ namespace Barotrauma
//suit can be taken off if there character is inside a hull and there's air in the room
bool canTakeOffSuit = Character.AnimController.CurrentHull != null &&
Character.AnimController.CurrentHull.OxygenPercentage > 30.0f &&
Character.AnimController.CurrentHull.Volume < Character.AnimController.CurrentHull.FullVolume * 0.3f;
Character.AnimController.CurrentHull.WaterVolume < Character.AnimController.CurrentHull.Volume * 0.3f;
//the suit can be taken off and the character is running out of oxygen (couldn't find a tank for the suit?) or idling
//-> take the suit off
@@ -215,7 +215,7 @@ namespace Barotrauma
bool shouldBeOpen = false;
if (door.LinkedGap.isHorizontal)
if (door.LinkedGap.IsHorizontal)
{
int currentDir = Math.Sign(nextNode.WorldPosition.X - door.Item.WorldPosition.X);
@@ -291,7 +291,7 @@ namespace Barotrauma
}
}
if (node.Waypoint!=null && node.Waypoint.CurrentHull!=null)
if (node.Waypoint != null && node.Waypoint.CurrentHull != null)
{
var hull = node.Waypoint.CurrentHull;
@@ -303,8 +303,8 @@ namespace Barotrauma
}
}
if (character.NeedsAir && hull.Volume / hull.Rect.Width > 100.0f) penalty += 500.0f;
if (character.PressureProtection < 10.0f && hull.Volume > hull.FullVolume) penalty += 1000.0f;
if (character.NeedsAir && hull.WaterVolume / hull.Rect.Width > 100.0f) penalty += 500.0f;
if (character.PressureProtection < 10.0f && hull.WaterVolume > hull.Volume) penalty += 1000.0f;
}
return penalty;
@@ -137,7 +137,7 @@ namespace Barotrauma
if (currentHull == null) return true;
//there's lots of water in the room -> get a suit
if (currentHull.Volume / currentHull.FullVolume > 0.5f) return true;
if (currentHull.WaterVolume / currentHull.Volume > 0.5f) return true;
if (currentHull.OxygenPercentage < 30.0f) return true;
@@ -185,7 +185,7 @@ namespace Barotrauma
{
if (hull == null) return 0.0f;
float waterPercentage = (hull.Volume / hull.FullVolume) * 100.0f;
float waterPercentage = (hull.WaterVolume / hull.Volume) * 100.0f;
float fireAmount = 0.0f;
var nearbyHulls = hull.GetConnectedHulls(3);
@@ -24,7 +24,7 @@ namespace Barotrauma
{
if (leak.Open == 0.0f) return 0.0f;
float leakSize = (leak.isHorizontal ? leak.Rect.Height : leak.Rect.Width) * Math.Max(leak.Open, 0.1f);
float leakSize = (leak.IsHorizontal ? leak.Rect.Height : leak.Rect.Width) * Math.Max(leak.Open, 0.1f);
float dist = Vector2.DistanceSquared(character.SimPosition, leak.SimPosition);
dist = Math.Max(dist/100.0f, 1.0f);
@@ -80,7 +80,7 @@ namespace Barotrauma
if (hull == null) return standPos;
if (leak.isHorizontal)
if (leak.IsHorizontal)
{
standPos += Vector2.UnitX * Math.Sign(hull.Position.X - leak.Position.X) * leak.Rect.Width;
}
@@ -81,7 +81,7 @@ namespace Barotrauma
if (gap == null) return 0.0f;
//larger gap -> higher priority
float gapPriority = (gap.isHorizontal ? gap.Rect.Width : gap.Rect.Height) * gap.Open;
float gapPriority = (gap.IsHorizontal ? gap.Rect.Width : gap.Rect.Height) * gap.Open;
//prioritize gaps that are close
gapPriority /= Math.Max(Vector2.Distance(character.WorldPosition, gap.WorldPosition), 1.0f);
@@ -132,7 +132,7 @@ namespace Barotrauma
{
List<Hull> targetHulls = new List<Hull>(Hull.hullList);
//ignore all hulls with fires or water in them
targetHulls.RemoveAll(h => h.FireSources.Any() || (h.Volume/h.FullVolume)>0.1f);
targetHulls.RemoveAll(h => h.FireSources.Any() || h.WaterVolume / h.Volume > 0.1f);
if (!targetHulls.Any()) return null;
return targetHulls[Rand.Range(0, targetHulls.Count)].AiTarget;
@@ -816,7 +816,7 @@ namespace Barotrauma
headInWater = false;
inWater = false;
if (currentHull.Volume > currentHull.FullVolume * 0.95f)
if (currentHull.WaterVolume > currentHull.Volume * 0.95f)
{
inWater = true;
}
@@ -836,7 +836,7 @@ namespace Barotrauma
}
if (currentHull == null ||
currentHull.Volume > currentHull.FullVolume * 0.95f ||
currentHull.WaterVolume > currentHull.Volume * 0.95f ||
ConvertUnits.ToSimUnits(currentHull.Surface) > Collider.SimPosition.Y)
{
Collider.ApplyWaterForces();
@@ -858,7 +858,7 @@ namespace Barotrauma
limb.inWater = true;
if (limb.type == LimbType.Head) headInWater = true;
}
else if (limbHull.Volume > 0.0f && Submarine.RectContains(limbHull.Rect, limb.Position))
else if (limbHull.WaterVolume > 0.0f && Submarine.RectContains(limbHull.Rect, limb.Position))
{
if (limb.Position.Y < limbHull.Surface)
{