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:
@@ -250,7 +250,7 @@ namespace Barotrauma.Items.Components
|
||||
//steer closer if almost in range
|
||||
if (dist > range)
|
||||
{
|
||||
Vector2 standPos = leak.isHorizontal ?
|
||||
Vector2 standPos = leak.IsHorizontal ?
|
||||
new Vector2(Math.Sign(item.WorldPosition.X - leak.WorldPosition.X), 0.0f)
|
||||
: new Vector2(0.0f, Math.Sign(item.WorldPosition.Y - leak.WorldPosition.Y));
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
hullData.Water = Math.Min(senderHull.Volume / senderHull.FullVolume, 1.0f);
|
||||
hullData.Water = Math.Min(senderHull.WaterVolume / senderHull.Volume, 1.0f);
|
||||
}
|
||||
break;
|
||||
case "oxygen_data_in":
|
||||
|
||||
@@ -90,17 +90,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
Vent vent = linkedItem.GetComponent<Vent>();
|
||||
if (vent == null) continue;
|
||||
|
||||
|
||||
ventList.Add(vent);
|
||||
if (linkedItem.CurrentHull!=null) totalHullVolume += linkedItem.CurrentHull.FullVolume;
|
||||
if (linkedItem.CurrentHull != null) totalHullVolume += linkedItem.CurrentHull.Volume;
|
||||
}
|
||||
}
|
||||
|
||||
//public override void OnMapLoaded()
|
||||
//{
|
||||
// GetVents();
|
||||
//}
|
||||
|
||||
|
||||
private void UpdateVents(float deltaOxygen)
|
||||
{
|
||||
if (ventList == null)
|
||||
@@ -109,13 +104,13 @@ namespace Barotrauma.Items.Components
|
||||
GetVents();
|
||||
}
|
||||
|
||||
if (!ventList.Any() || totalHullVolume == 0.0f) return;
|
||||
if (!ventList.Any() || totalHullVolume <= 0.0f) return;
|
||||
|
||||
foreach (Vent v in ventList)
|
||||
{
|
||||
if (v.Item.CurrentHull == null) continue;
|
||||
|
||||
v.OxygenFlow = deltaOxygen * (v.Item.CurrentHull.FullVolume / totalHullVolume);
|
||||
v.OxygenFlow = deltaOxygen * (v.Item.CurrentHull.Volume / totalHullVolume);
|
||||
v.IsActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Barotrauma.Items.Components
|
||||
if (targetLevel != null)
|
||||
{
|
||||
float hullPercentage = 0.0f;
|
||||
if (hull1 != null) hullPercentage = (hull1.Volume / hull1.FullVolume) * 100.0f;
|
||||
if (hull1 != null) hullPercentage = (hull1.WaterVolume / hull1.Volume) * 100.0f;
|
||||
FlowPercentage = ((float)targetLevel - hullPercentage) * 10.0f;
|
||||
}
|
||||
|
||||
@@ -100,21 +100,14 @@ namespace Barotrauma.Items.Components
|
||||
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
|
||||
|
||||
if (hull1 == null) return;
|
||||
|
||||
float powerFactor = currPowerConsumption <= 0.0f ? 1.0f : voltage;
|
||||
|
||||
currFlow = flowPercentage / 100.0f * maxFlow * powerFactor;
|
||||
|
||||
hull1.WaterVolume += currFlow;
|
||||
if (hull1.WaterVolume > hull1.Volume) hull1.Pressure += 0.5f;
|
||||
|
||||
float powerFactor = (currPowerConsumption==0.0f) ? 1.0f : voltage;
|
||||
//flowPercentage = maxFlow * powerFactor;
|
||||
|
||||
currFlow = (flowPercentage / 100.0f) * maxFlow * powerFactor;
|
||||
|
||||
hull1.Volume += currFlow;
|
||||
if (hull1.Volume > hull1.FullVolume) hull1.Pressure += 0.5f;
|
||||
|
||||
//if (hull2 != null)
|
||||
//{
|
||||
// hull2.Volume -= currFlow;
|
||||
// if (hull2.Volume > hull1.FullVolume) hull2.Pressure += 0.5f;
|
||||
//}
|
||||
|
||||
voltage = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user