v1.4.4.1 (Blood in the Water Update)

This commit is contained in:
Regalis11
2024-04-24 18:09:05 +03:00
parent 89b91d1c3e
commit ff1b8951a7
397 changed files with 15250 additions and 6479 deletions
@@ -188,7 +188,6 @@ namespace Barotrauma
}
return realWorldCrushDepth.Value;
}
set { realWorldCrushDepth = value; }
}
/// <summary>
@@ -976,7 +975,7 @@ namespace Barotrauma
if (ignoreLevel && fixture.CollisionCategories.HasFlag(Physics.CollisionLevel)) { return -1; }
if (!fixture.CollisionCategories.HasFlag(Physics.CollisionLevel)
&& !fixture.CollisionCategories.HasFlag(Physics.CollisionWall)
&& !fixture.CollisionCategories.HasFlag(Physics.CollisionRepair)) { return -1; }
&& !fixture.CollisionCategories.HasFlag(Physics.CollisionRepairableWall)) { return -1; }
if (ignoreSubs && fixture.Body.UserData is Submarine) { return -1; }
if (ignoreBranches && fixture.Body.UserData is VineTile) { return -1; }
if (fixture.Body.UserData as string == "ruinroom") { return -1; }
@@ -1113,27 +1112,45 @@ namespace Barotrauma
}
public void EnableFactionSpecificEntities(Identifier factionIdentifier)
{
foreach (var faction in FactionPrefab.Prefabs)
{
SetLayerEnabled(faction.Identifier, faction.Identifier == factionIdentifier);
}
}
public bool LayerExists(Identifier layer)
{
foreach (MapEntity me in MapEntity.MapEntityList)
{
if (string.IsNullOrEmpty(me.Layer) || me.Submarine != this) { continue; }
var layerAsIdentifier = me.Layer.ToIdentifier();
if (FactionPrefab.Prefabs.ContainsKey(layerAsIdentifier))
{
me.HiddenInGame = factionIdentifier != layerAsIdentifier;
#if CLIENT
//normally this is handled in LightComponent.OnMapLoaded, but this method is called after that
if (me.HiddenInGame && me is Item item)
{
foreach (var lightComponent in item.GetComponents<LightComponent>())
{
lightComponent.Light.Enabled = false;
}
}
#endif
}
if (me.Submarine == this || me.Layer == layer) { return true; }
}
return false;
}
public void SetLayerEnabled(Identifier layer, bool enabled, bool sendNetworkEvent = false)
{
foreach (MapEntity me in MapEntity.MapEntityList)
{
if (string.IsNullOrEmpty(me.Layer) || me.Submarine != this || me.Layer != layer) { continue; }
me.HiddenInGame = !enabled;
#if CLIENT
//normally this is handled in LightComponent.OnMapLoaded, but this method is called after that
if (me.HiddenInGame && me is Item item)
{
foreach (var lightComponent in item.GetComponents<LightComponent>())
{
lightComponent.Light.Enabled = false;
}
}
#endif
}
#if SERVER
if (sendNetworkEvent)
{
GameMain.Server.CreateEntityEvent(this, new SetLayerEnabledEventData(layer, enabled));
}
#endif
}
public void Update(float deltaTime)
@@ -1230,6 +1247,8 @@ namespace Barotrauma
public void NeutralizeBallast()
{
if (PhysicsBody.BodyType != BodyType.Dynamic) { return; }
float neutralBallastLevel = 0.5f;
int selectedSteeringValue = 0;
foreach (Item item in Item.ItemList)
@@ -1240,8 +1259,8 @@ namespace Barotrauma
//find how many pumps/engines in this sub the steering item is connected to
int steeringValue = 1;
Connection connectionX = item.GetComponent<ConnectionPanel>()?.Connections.Find(c => c.Name == "velocity_x_out");
Connection connectionY = item.GetComponent<ConnectionPanel>()?.Connections.Find(c => c.Name == "velocity_y_out");
Connection connectionX = item.GetComponent<ConnectionPanel>()?.Connections.Find(static c => c.Name == "velocity_x_out");
Connection connectionY = item.GetComponent<ConnectionPanel>()?.Connections.Find(static c => c.Name == "velocity_y_out");
if (connectionX != null)
{
foreach (Engine engine in steering.Item.GetConnectedComponentsRecursive<Engine>(connectionX))
@@ -1371,7 +1390,7 @@ namespace Barotrauma
}
/// <summary>
/// Returns true if the sub is same as the other.
/// Returns true if the sub is same as the other, or connected to it via docking ports.
/// </summary>
public bool IsConnectedTo(Submarine otherSub) => this == otherSub || GetConnectedSubs().Contains(otherSub);
@@ -1459,22 +1478,39 @@ namespace Barotrauma
public static Rectangle GetBorders(XElement submarineElement)
{
Vector4 bounds = Vector4.Zero;
Vector4 bounds = new Vector4(float.MaxValue, float.MinValue, float.MinValue, float.MaxValue);
foreach (XElement element in submarineElement.Elements())
{
if (element.Name != "Structure") { continue; }
if (element.Name == "Structure")
{
string name = element.GetAttributeString("name", "");
Identifier identifier = element.GetAttributeIdentifier("identifier", "");
StructurePrefab prefab = Structure.FindPrefab(name, identifier);
if (prefab == null || !prefab.Body) { continue; }
string name = element.GetAttributeString("name", "");
Identifier identifier = element.GetAttributeIdentifier("identifier", "");
StructurePrefab prefab = Structure.FindPrefab(name, identifier);
if (prefab == null || !prefab.Body) { continue; }
var rect = element.GetAttributeRect("rect", Rectangle.Empty);
bounds = new Vector4(
Math.Min(rect.X, bounds.X),
Math.Max(rect.Y, bounds.Y),
Math.Max(rect.Right, bounds.Z),
Math.Min(rect.Y - rect.Height, bounds.W));
}
else if (element.Name == "LinkedSubmarine")
{
Point dimensions = element.GetAttributePoint("dimensions", Point.Zero);
Point pos = element.GetAttributeVector2("pos", Vector2.Zero).ToPoint();
bounds = new Vector4(
Math.Min(pos.X - dimensions.X / 2, bounds.X),
Math.Max(pos.Y + dimensions.Y / 2, bounds.Y),
Math.Max(pos.X + dimensions.X / 2, bounds.Z),
Math.Min(pos.Y - dimensions.Y / 2, bounds.W));
}
}
var rect = element.GetAttributeRect("rect", Rectangle.Empty);
bounds = new Vector4(
Math.Min(rect.X, bounds.X),
Math.Max(rect.Y, bounds.Y),
Math.Max(rect.Right, bounds.Z),
Math.Min(rect.Y - rect.Height, bounds.W));
if (bounds.X == float.MaxValue || bounds.Y == float.MinValue || bounds.Z == float.MinValue || bounds.W == float.MaxValue)
{
//no bounds found
return Rectangle.Empty;
}
return new Rectangle((int)bounds.X, (int)bounds.Y, (int)(bounds.Z - bounds.X), (int)(bounds.Y - bounds.W));
@@ -1667,6 +1703,11 @@ namespace Barotrauma
}
}
foreach (Identifier layer in Info.LayersHiddenByDefault)
{
SetLayerEnabled(layer, enabled: false);
}
GameMain.GameSession?.Campaign?.UpgradeManager?.OnUpgradesChanged.Register(upgradeEventIdentifier, _ => ResetCrushDepth());
#if CLIENT
@@ -1721,6 +1762,22 @@ namespace Barotrauma
realWorldCrushDepth = null;
}
/// <summary>
/// Normally crush depth is determined by the crush depths of the walls and upgrades applied on them.
/// This method forces the crush depths of all the walls to the specified value.
/// </summary>
/// </summary>
/// <param name="realWorldCrushDepth">Depth in "real world" units (meters from the surface of Europa, the value you see on the nav terminal).</param>
public void SetCrushDepth(float realWorldCrushDepth)
{
foreach (Structure structure in Structure.WallList)
{
if (structure.Submarine != this || !structure.HasBody || structure.Indestructible) { continue; }
structure.CrushDepth = realWorldCrushDepth;
}
this.realWorldCrushDepth = realWorldCrushDepth;
}
public static void RepositionEntities(Vector2 moveAmount, IEnumerable<MapEntity> entities)
{
if (moveAmount.LengthSquared() < 0.00001f) { return; }
@@ -1777,6 +1834,10 @@ namespace Barotrauma
element.Add(new XAttribute("recommendedcrewsizemax", Info.RecommendedCrewSizeMax));
element.Add(new XAttribute("recommendedcrewexperience", Info.RecommendedCrewExperience.ToString()));
element.Add(new XAttribute("requiredcontentpackages", string.Join(", ", Info.RequiredContentPackages)));
if (Info.LayersHiddenByDefault.Any())
{
element.Add(new XAttribute("layerhiddenbydefault", string.Join(", ", Info.LayersHiddenByDefault)));
}
if (Info.Type == SubmarineType.OutpostModule)
{