Unstable 1.1.14.0

This commit is contained in:
Markus Isberg
2023-10-02 16:43:54 +03:00
parent 94f5a93a0c
commit cf8f0de659
606 changed files with 21906 additions and 11456 deletions
@@ -8,6 +8,8 @@ using System.Globalization;
using System.Linq;
using System.Xml.Linq;
using Barotrauma.MapCreatures.Behavior;
using Barotrauma.Items.Components;
using Barotrauma.Extensions;
namespace Barotrauma
{
@@ -140,6 +142,16 @@ namespace Barotrauma
get { return properties; }
}
/// <summary>
/// How fast the pressure in the hull builds up when there's a gap leading outside
/// </summary>
public const float PressureBuildUpSpeed = 15.0f;
/// <summary>
/// How fast the pressure in the hull goes back to normal when it's no longer full of water
/// </summary>
public const float PressureDropSpeed = 10.0f;
private float lethalPressure;
private float surface;
@@ -310,6 +322,8 @@ namespace Barotrauma
}
}
public bool IsAirlock { get; private set; }
private bool ForceAsWetRoom =>
roomName != null && (
roomName.Contains("ballast", StringComparison.OrdinalIgnoreCase) ||
@@ -404,6 +418,26 @@ namespace Barotrauma
private bool networkUpdatePending;
private float networkUpdateTimer;
/// <summary>
/// Average color of the background sections
/// </summary>
public Color AveragePaintedColor { get; private set; }
/// <summary>
/// Returns true if the red component of the background color is twice as bright as the blue and green. Can be used by StatusEffects.
/// </summary>
public bool IsRed => ColorExtensions.IsRedDominant(AveragePaintedColor, minimumAlpha: 100);
/// <summary>
/// Returns true if the green component of the background color is twice as bright as the red and blue. Can be used by StatusEffects.
/// </summary>
public bool IsGreen => ColorExtensions.IsGreenDominant(AveragePaintedColor, minimumAlpha: 100);
/// <summary>
/// Returns true if the blue component of the background color is twice as bright as the red and green. Can be used by StatusEffects.
/// </summary>
public bool IsBlue => ColorExtensions.IsBlueDominant(AveragePaintedColor, minimumAlpha: 100);
public List<FireSource> FireSources { get; private set; }
public List<DummyFireSource> FakeFireSources { get; private set; }
@@ -556,7 +590,9 @@ namespace Barotrauma
}
}
Pressure = rect.Y - rect.Height + waterVolume / rect.Width;
DetermineIsAirlock();
BallastFlora?.OnMapLoaded();
#if CLIENT
lastAmbientLightEditTime = 0.0;
@@ -980,7 +1016,7 @@ namespace Barotrauma
if (waterVolume < Volume)
{
LethalPressure -= 10.0f * deltaTime;
LethalPressure -= PressureDropSpeed * deltaTime;
if (WaterVolume <= 0.0f)
{
#if CLIENT
@@ -1264,7 +1300,7 @@ namespace Barotrauma
{
if (g.ConnectedDoor != null && !HullList.Any(h => h.ConnectedGaps.Contains(g) && h != this)) return true;
}
List<MapEntity> structures = mapEntityList.FindAll(me => me is Structure && me.Rect.Intersects(Rect));
List<MapEntity> structures = MapEntityList.FindAll(me => me is Structure && me.Rect.Intersects(Rect));
return structures.Any(st => !(st as Structure).CastShadow);
}
return false;
@@ -1280,7 +1316,7 @@ namespace Barotrauma
if (item.GetComponent<Items.Components.Engine>() != null) roomItems.Add("engine");
if (item.GetComponent<Items.Components.Steering>() != null) roomItems.Add("steering");
if (item.GetComponent<Items.Components.Sonar>() != null) roomItems.Add("sonar");
if (item.HasTag("ballast")) roomItems.Add("ballast");
if (item.HasTag(Tags.Ballast)) roomItems.Add("ballast");
}
if (roomItems.Contains("reactor"))
@@ -1297,7 +1333,7 @@ namespace Barotrauma
if (moduleFlags != null && moduleFlags.Any() &&
(Submarine.Info.Type == SubmarineType.OutpostModule || Submarine.Info.Type == SubmarineType.Outpost))
{
if (moduleFlags.Contains("airlock".ToIdentifier()) &&
if (moduleFlags.Contains(Tags.Airlock) &&
ConnectedGaps.Any(g => !g.IsRoomToRoom && g.ConnectedDoor != null))
{
return "RoomName.Airlock";
@@ -1334,23 +1370,26 @@ namespace Barotrauma
/// <summary>
/// Is this hull or any of the items inside it tagged as "airlock"?
/// </summary>
public bool IsTaggedAirlock()
private void DetermineIsAirlock()
{
if (RoomName != null && RoomName.Contains("airlock", StringComparison.OrdinalIgnoreCase))
{
return true;
IsAirlock = true;
return;
}
else
{
var airlockTag = "airlock".ToIdentifier();
foreach (Item item in Item.ItemList)
{
if (item.CurrentHull != this && item.HasTag("airlock"))
if (item.CurrentHull != this && item.HasTag(airlockTag))
{
return true;
IsAirlock = true;
return;
}
}
}
return false;
IsAirlock = false;
}
/// <summary>
@@ -1489,6 +1528,7 @@ namespace Barotrauma
#endif
sectionUpdated = true;
}
RefreshAveragePaintedColor();
}
if (sectionUpdated && GameMain.NetworkMember != null && requiresUpdate)
@@ -1501,6 +1541,17 @@ namespace Barotrauma
}
}
private void RefreshAveragePaintedColor()
{
Vector4 avgColor = Vector4.Zero;
foreach (var anySection in BackgroundSections)
{
avgColor += anySection.Color.ToVector4();
}
avgColor /= BackgroundSections.Count;
AveragePaintedColor = new Color(avgColor);
}
public void SetSectionColorOrStrength(BackgroundSection section, Color? color, float? strength)
{
if (color != null)
@@ -1619,6 +1670,7 @@ namespace Barotrauma
}
}
}
hull.RefreshAveragePaintedColor();
SerializableProperty.DeserializeProperties(hull, element);
if (element.GetAttribute("oxygen") == null) { hull.Oxygen = hull.Volume; }
@@ -1687,7 +1739,7 @@ namespace Barotrauma
public override string ToString()
{
return $"{base.ToString()} ({Name ?? "unnamed"})";
return $"{base.ToString()} ({DisplayName ?? "unnamed"}, {(Submarine?.Info?.Name ?? "no sub")})";
}
}
}