Unstable 0.1300.0.3
This commit is contained in:
@@ -87,7 +87,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
|
||||
internal partial class BallastFloraBehavior : ISerializableEntity
|
||||
{
|
||||
#if DEBUG || UNSTABLE
|
||||
#if DEBUG
|
||||
public List<Tuple<Vector2, Vector2>> debugSearchLines = new List<Tuple<Vector2, Vector2>>();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
protected virtual void Grow()
|
||||
{
|
||||
List<BallastFloraBranch> newTiles = GrowRandomly();
|
||||
#if DEBUG || UNSTABLE
|
||||
#if DEBUG
|
||||
Behavior.debugSearchLines.Clear();
|
||||
#endif
|
||||
if (newTiles.Any(TryScanTargets)) { return; }
|
||||
@@ -135,7 +135,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
|
||||
Vector2 itemSimPos = ConvertUnits.ToSimUnits(item.Position);
|
||||
|
||||
#if DEBUG || UNSTABLE
|
||||
#if DEBUG
|
||||
Tuple<Vector2, Vector2> debugLine1 = Tuple.Create(parent.Position - ConvertUnits.ToDisplayUnits(topLeft), parent.Position - ConvertUnits.ToDisplayUnits(itemSimPos - diameter));
|
||||
Tuple<Vector2, Vector2> debugLine2 = Tuple.Create(parent.Position - ConvertUnits.ToDisplayUnits(bottomRight), parent.Position - ConvertUnits.ToDisplayUnits(itemSimPos + diameter));
|
||||
Behavior.debugSearchLines.Add(debugLine2);
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Barotrauma
|
||||
private bool sparks, shockwave, flames, smoke, flash, underwaterBubble;
|
||||
private bool playTinnitus;
|
||||
private bool applyFireEffects;
|
||||
private string[] ignoreFireEffectsForTags;
|
||||
private bool ignoreCover;
|
||||
private bool onlyInside;
|
||||
private bool onlyOutside;
|
||||
@@ -53,6 +54,7 @@ namespace Barotrauma
|
||||
smoke = true;
|
||||
flames = true;
|
||||
underwaterBubble = true;
|
||||
ignoreFireEffectsForTags = new string[0];
|
||||
}
|
||||
|
||||
public Explosion(XElement element, string parentDebugName)
|
||||
@@ -70,6 +72,8 @@ namespace Barotrauma
|
||||
playTinnitus = element.GetAttributeBool("playtinnitus", true);
|
||||
|
||||
applyFireEffects = element.GetAttributeBool("applyfireeffects", flames);
|
||||
ignoreFireEffectsForTags = element.GetAttributeStringArray("ignorefireeffectsfortags", new string[0], convertToLowerInvariant: true);
|
||||
|
||||
ignoreCover = element.GetAttributeBool("ignorecover", false);
|
||||
onlyInside = element.GetAttributeBool("onlyinside", false);
|
||||
onlyOutside = element.GetAttributeBool("onlyoutside", false);
|
||||
@@ -192,7 +196,7 @@ namespace Barotrauma
|
||||
dist = Math.Max(0.0f, dist - ConvertUnits.ToDisplayUnits(itemRadius));
|
||||
if (dist > Attack.Range) { continue; }
|
||||
|
||||
if (dist < Attack.Range * 0.5f && applyFireEffects && !item.FireProof)
|
||||
if (dist < Attack.Range * 0.5f && applyFireEffects && !item.FireProof && ignoreFireEffectsForTags.None(t => item.HasTag(t)))
|
||||
{
|
||||
//don't apply OnFire effects if the item is inside a fireproof container
|
||||
//(or if it's inside a container that's inside a fireproof container, etc)
|
||||
|
||||
@@ -479,8 +479,8 @@ namespace Barotrauma
|
||||
minMainPathWidth, parentTunnel: null);
|
||||
Tunnels.Add(mainPath);
|
||||
|
||||
Tunnel startPath = null, endPath = null;
|
||||
if (Mirrored ? !HasEndOutpost() : !HasStartOutpost())
|
||||
Tunnel startPath = null, endPath = null, endHole = null;
|
||||
if (GenerationParams.StartPosition.Y < 0.5f && (Mirrored ? !HasEndOutpost() : !HasStartOutpost()))
|
||||
{
|
||||
startPath = new Tunnel(
|
||||
TunnelType.SidePath,
|
||||
@@ -488,7 +488,11 @@ namespace Barotrauma
|
||||
minWidth / 2, parentTunnel: mainPath);
|
||||
Tunnels.Add(startPath);
|
||||
}
|
||||
if (Mirrored ? !HasStartOutpost() : !HasEndOutpost())
|
||||
else
|
||||
{
|
||||
startExitPosition = StartPosition;
|
||||
}
|
||||
if (GenerationParams.EndPosition.Y < 0.5f && (Mirrored ? !HasStartOutpost() : !HasEndOutpost()))
|
||||
{
|
||||
endPath = new Tunnel(
|
||||
TunnelType.SidePath,
|
||||
@@ -496,12 +500,51 @@ namespace Barotrauma
|
||||
minWidth / 2, parentTunnel: mainPath);
|
||||
Tunnels.Add(endPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
endExitPosition = EndPosition;
|
||||
}
|
||||
|
||||
if (GenerationParams.CreateHoleNextToEnd)
|
||||
{
|
||||
if (Mirrored)
|
||||
{
|
||||
endHole = new Tunnel(
|
||||
TunnelType.SidePath,
|
||||
new List<Point>() { startPosition, startExitPosition.ToPoint(), new Point(0, Size.Y) },
|
||||
minWidth / 2, parentTunnel: mainPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
endHole = new Tunnel(
|
||||
TunnelType.SidePath,
|
||||
new List<Point>() { endPosition, endExitPosition.ToPoint(), Size },
|
||||
minWidth / 2, parentTunnel: mainPath);
|
||||
}
|
||||
Tunnels.Add(endHole);
|
||||
}
|
||||
|
||||
//create a tunnel from the lowest point in the main path to the abyss
|
||||
//to ensure there's a way to the abyss in all levels
|
||||
if (GenerationParams.CreateHoleToAbyss)
|
||||
{
|
||||
Point lowestPoint = mainPath.Nodes.First();
|
||||
foreach (var pathNode in mainPath.Nodes)
|
||||
{
|
||||
if (pathNode.Y < lowestPoint.Y) { lowestPoint = pathNode; }
|
||||
}
|
||||
var abyssTunnel = new Tunnel(
|
||||
TunnelType.SidePath,
|
||||
new List<Point>() { lowestPoint, new Point(lowestPoint.X, 0) },
|
||||
minWidth / 2, parentTunnel: mainPath);
|
||||
Tunnels.Add(abyssTunnel);
|
||||
}
|
||||
|
||||
int sideTunnelCount = Rand.Range(GenerationParams.SideTunnelCount.X, GenerationParams.SideTunnelCount.Y + 1, Rand.RandSync.Server);
|
||||
for (int j = 0; j < sideTunnelCount; j++)
|
||||
{
|
||||
if (mainPath.Nodes.Count < 4) { break; }
|
||||
var validTunnels = Tunnels.FindAll(t => t.Type != TunnelType.Cave && t != startPath && t != endPath);
|
||||
var validTunnels = Tunnels.FindAll(t => t.Type != TunnelType.Cave && t != startPath && t != endPath && t != endHole);
|
||||
Tunnel tunnelToBranchOff = validTunnels[Rand.Int(validTunnels.Count, Rand.RandSync.Server)];
|
||||
if (tunnelToBranchOff == null) { tunnelToBranchOff = mainPath; }
|
||||
|
||||
@@ -634,13 +677,16 @@ namespace Barotrauma
|
||||
CaveGenerator.GeneratePath(tunnel, this);
|
||||
if (tunnel.Type == TunnelType.MainPath || tunnel.Type == TunnelType.SidePath)
|
||||
{
|
||||
var distinctCells = tunnel.Cells.Distinct().ToList();
|
||||
for (int i = 2; i < distinctCells.Count; i += 3)
|
||||
if (tunnel != startPath && tunnel != endPath && tunnel != endHole)
|
||||
{
|
||||
PositionsOfInterest.Add(new InterestingPosition(
|
||||
new Point((int)distinctCells[i].Site.Coord.X, (int)distinctCells[i].Site.Coord.Y),
|
||||
tunnel.Type == TunnelType.MainPath ? PositionType.MainPath : PositionType.SidePath,
|
||||
Caves.Find(cave => cave.Tunnels.Contains(tunnel))));
|
||||
var distinctCells = tunnel.Cells.Distinct().ToList();
|
||||
for (int i = 2; i < distinctCells.Count; i += 3)
|
||||
{
|
||||
PositionsOfInterest.Add(new InterestingPosition(
|
||||
new Point((int)distinctCells[i].Site.Coord.X, (int)distinctCells[i].Site.Coord.Y),
|
||||
tunnel.Type == TunnelType.MainPath ? PositionType.MainPath : PositionType.SidePath,
|
||||
Caves.Find(cave => cave.Tunnels.Contains(tunnel))));
|
||||
}
|
||||
}
|
||||
}
|
||||
GenerateWaypoints(tunnel, parentTunnel: tunnel.ParentTunnel);
|
||||
@@ -685,7 +731,10 @@ namespace Barotrauma
|
||||
var potentialIslands = new List<VoronoiCell>();
|
||||
foreach (var cell in pathCells)
|
||||
{
|
||||
if (GetDistToTunnel(cell.Center, mainPath) < minMainPathWidth) { continue; }
|
||||
if (GetDistToTunnel(cell.Center, mainPath) < minMainPathWidth ||
|
||||
(startPath != null && GetDistToTunnel(cell.Center, startPath) < minMainPathWidth) ||
|
||||
(endPath != null && GetDistToTunnel(cell.Center, endPath) < minMainPathWidth) ||
|
||||
(endHole != null && GetDistToTunnel(cell.Center, endHole) < minMainPathWidth)) { continue; }
|
||||
if (cell.Edges.Any(e => e.AdjacentCell(cell)?.CellType != CellType.Path || e.NextToCave)) { continue; }
|
||||
potentialIslands.Add(cell);
|
||||
}
|
||||
@@ -1230,18 +1279,6 @@ namespace Barotrauma
|
||||
List<VoronoiCell> toBeRemoved = new List<VoronoiCell>();
|
||||
foreach (VoronoiCell cell in cells)
|
||||
{
|
||||
if (GenerationParams.CreateHoleNextToEnd)
|
||||
{
|
||||
if ((!Mirrored && cell.Center.X > endPosition.X) || (Mirrored && cell.Center.X < StartPosition.X))
|
||||
{
|
||||
if (cell.Edges.Any(e => e.Point1.Y > Size.Y - submarineSize || e.Point2.Y > Size.Y - submarineSize))
|
||||
{
|
||||
toBeRemoved.Add(cell);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cell.Edges.Any(e => e.NextToCave)) { continue; }
|
||||
if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) > holeProbability) { continue; }
|
||||
if (!limits.Contains(cell.Site.Coord.X, cell.Site.Coord.Y)) { continue; }
|
||||
@@ -1644,7 +1681,7 @@ namespace Barotrauma
|
||||
Rectangle allowedArea = new Rectangle(padding, padding, Size.X - padding * 2, Size.Y - padding * 2);
|
||||
|
||||
int radius = Math.Max(caveSize.X, caveSize.Y) / 2;
|
||||
var cavePos = FindPosAwayFromMainPath((parentTunnel.MinWidth + radius) * 1.2f, asCloseAsPossible: true, allowedArea);
|
||||
var cavePos = FindPosAwayFromMainPath((parentTunnel.MinWidth + radius) * 1.5f, asCloseAsPossible: true, allowedArea);
|
||||
|
||||
GenerateCave(caveParams, parentTunnel, cavePos, caveSize);
|
||||
|
||||
@@ -2633,7 +2670,7 @@ namespace Barotrauma
|
||||
if (Submarine.PickBody(
|
||||
ConvertUnits.ToSimUnits(startPos),
|
||||
ConvertUnits.ToSimUnits(endPos),
|
||||
ExtraWalls.Where(w => w.Body?.BodyType == BodyType.Dynamic || w is DestructibleLevelWall).Select(w => w.Body),
|
||||
ExtraWalls.Where(w => w.Body?.BodyType == BodyType.Dynamic || w is DestructibleLevelWall).Select(w => w.Body).Union(Submarine.Loaded.Where(s => s.Info.Type == SubmarineType.Player).Select(s => s.PhysicsBody.FarseerBody)),
|
||||
Physics.CollisionLevel | Physics.CollisionWall) != null)
|
||||
{
|
||||
position = ConvertUnits.ToDisplayUnits(Submarine.LastPickedPosition) + Vector2.Normalize(startPos - endPos) * offsetFromWall;
|
||||
@@ -3027,6 +3064,7 @@ namespace Barotrauma
|
||||
else if (type == SubmarineType.BeaconStation)
|
||||
{
|
||||
sub.ShowSonarMarker = false;
|
||||
sub.DockedTo.ForEach(s => s.ShowSonarMarker = false);
|
||||
sub.PhysicsBody.FarseerBody.BodyType = BodyType.Static;
|
||||
sub.TeamID = CharacterTeamType.None;
|
||||
}
|
||||
@@ -3472,13 +3510,22 @@ namespace Barotrauma
|
||||
if ((i == 0) == !Mirrored)
|
||||
{
|
||||
StartOutpost = outpost;
|
||||
if (StartLocation != null) { outpost.Info.Name = StartLocation.Name; }
|
||||
if (StartLocation != null)
|
||||
{
|
||||
outpost.TeamID = StartLocation.Type.OutpostTeam;
|
||||
outpost.Info.Name = StartLocation.Name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EndOutpost = outpost;
|
||||
if (EndLocation != null) { outpost.Info.Name = EndLocation.Name; }
|
||||
if (EndLocation != null)
|
||||
{
|
||||
outpost.TeamID = EndLocation.Type.OutpostTeam;
|
||||
outpost.Info.Name = EndLocation.Name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3514,20 +3561,28 @@ namespace Barotrauma
|
||||
List<Item> beaconItems = Item.ItemList.FindAll(it => it.Submarine == BeaconStation);
|
||||
|
||||
Item reactorItem = beaconItems.Find(it => it.GetComponent<Reactor>() != null);
|
||||
Reactor reactorComponent = reactorItem.GetComponent<Reactor>();
|
||||
ItemContainer reactorContainer = reactorItem.GetComponent<ItemContainer>();
|
||||
Repairable repairable = reactorItem.GetComponent<Repairable>();
|
||||
reactorComponent.FuelConsumptionRate = 0.0f;
|
||||
if (repairable != null)
|
||||
Reactor reactorComponent = null;
|
||||
ItemContainer reactorContainer = null;
|
||||
if (reactorItem != null)
|
||||
{
|
||||
repairable.DeteriorationSpeed = 0.0f;
|
||||
reactorComponent = reactorItem.GetComponent<Reactor>();
|
||||
reactorComponent.FuelConsumptionRate = 0.0f;
|
||||
reactorContainer = reactorItem.GetComponent<ItemContainer>();
|
||||
Repairable repairable = reactorItem.GetComponent<Repairable>();
|
||||
if (repairable != null)
|
||||
{
|
||||
if (repairable != null)
|
||||
{
|
||||
repairable.DeteriorationSpeed = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (LevelData.IsBeaconActive)
|
||||
{
|
||||
if (reactorContainer.Inventory.IsEmpty())
|
||||
if (reactorContainer != null && reactorContainer.Inventory.IsEmpty())
|
||||
{
|
||||
ItemPrefab fuelPrefab = ItemPrefab.Prefabs[reactorContainer.ContainableItems[0].Identifiers[0]];
|
||||
Entity.Spawner.AddToSpawnQueue(
|
||||
Spawner.AddToSpawnQueue(
|
||||
fuelPrefab, reactorContainer.Inventory,
|
||||
onSpawned: (it) => reactorComponent.PowerUpImmediately());
|
||||
}
|
||||
@@ -3544,7 +3599,7 @@ namespace Barotrauma
|
||||
foreach (Item item in reactorContainer.Inventory.AllItems)
|
||||
{
|
||||
if (item.NonInteractable) { continue; }
|
||||
Entity.Spawner.AddToRemoveQueue(item);
|
||||
Spawner.AddToRemoveQueue(item);
|
||||
}
|
||||
|
||||
//remove wires
|
||||
@@ -3563,7 +3618,18 @@ namespace Barotrauma
|
||||
}
|
||||
if (Rand.Range(0f, 1f, Rand.RandSync.Unsynced) < 0.25f)
|
||||
{
|
||||
Entity.Spawner.AddToRemoveQueue(item);
|
||||
foreach (Connection connection in wire.Connections)
|
||||
{
|
||||
if (connection != null)
|
||||
{
|
||||
connection.ConnectionPanel.DisconnectedWires.Add(wire);
|
||||
wire.RemoveConnection(connection.Item);
|
||||
#if SERVER
|
||||
connection.ConnectionPanel.Item.CreateServerEvent(connection.ConnectionPanel);
|
||||
wire.CreateNetworkEvent();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3573,7 +3639,7 @@ namespace Barotrauma
|
||||
if (item.NonInteractable) { continue; }
|
||||
if (Rand.Range(0f, 1f, Rand.RandSync.Unsynced) < 0.5f)
|
||||
{
|
||||
item.Condition *= Rand.Range(0.2f, 0.6f, Rand.RandSync.Unsynced);
|
||||
item.Condition *= Rand.Range(0.6f, 0.8f, Rand.RandSync.Unsynced);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3617,6 +3683,9 @@ namespace Barotrauma
|
||||
pathPoints.Shuffle(Rand.RandSync.Unsynced);
|
||||
var corpsePoints = allSpawnPoints.FindAll(wp => wp.SpawnType == SpawnType.Corpse);
|
||||
corpsePoints.Shuffle(Rand.RandSync.Unsynced);
|
||||
|
||||
if (!corpsePoints.Any() && !pathPoints.Any()) { continue; }
|
||||
|
||||
int spawnCounter = 0;
|
||||
for (int j = 0; j < corpseCount; j++)
|
||||
{
|
||||
@@ -3706,7 +3775,15 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public float GetRealWorldDepth(float worldPositionY)
|
||||
{
|
||||
return (-(worldPositionY - GenerationParams.Height) + LevelData.InitialDepth) * Physics.DisplayToRealWorldRatio;
|
||||
if (GameMain.GameSession?.Campaign == null)
|
||||
{
|
||||
//ensure the levels aren't too deep to traverse in non-campaign modes where you don't have the option to upgrade/switch the sub
|
||||
return (-(worldPositionY - GenerationParams.Height) + 80000.0f) * Physics.DisplayToRealWorldRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (-(worldPositionY - GenerationParams.Height) + LevelData.InitialDepth) * Physics.DisplayToRealWorldRatio;
|
||||
}
|
||||
}
|
||||
|
||||
public void DebugSetStartLocation(Location newStartLocation)
|
||||
|
||||
@@ -145,8 +145,11 @@ namespace Barotrauma
|
||||
var rand = new MTRandom(ToolBox.StringToInt(Seed));
|
||||
InitialDepth = (int)MathHelper.Lerp(GenerationParams.InitialDepthMin, GenerationParams.InitialDepthMax, (float)rand.NextDouble());
|
||||
|
||||
//minimum difficulty of the level before hunting grounds can appear
|
||||
float huntingGroundsDifficultyThreshold = 25;
|
||||
//probability of hunting grounds appearing in 100% difficulty levels
|
||||
float maxHuntingGroundsProbability = 0.3f;
|
||||
HasHuntingGrounds = rand.NextDouble() < Difficulty / 100.0f * maxHuntingGroundsProbability;
|
||||
HasHuntingGrounds = OriginallyHadHuntingGrounds = rand.NextDouble() < MathUtils.InverseLerp(huntingGroundsDifficultyThreshold, 100.0f, Difficulty) * maxHuntingGroundsProbability;
|
||||
|
||||
HasBeaconStation = !HasHuntingGrounds && rand.NextDouble() < locationConnection.Locations.Select(l => l.Type.BeaconStationChance).Max();
|
||||
IsBeaconActive = false;
|
||||
|
||||
@@ -181,6 +181,13 @@ namespace Barotrauma
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(true, true, "Should the generator force a hole to the bottom of the level to ensure there's a way to the abyss."), Editable]
|
||||
public bool CreateHoleToAbyss
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(1000, true, description: "The total number of level objects (vegetation, vents, etc) in the level."), Editable(MinValueInt = 0, MaxValueInt = 100000)]
|
||||
public int LevelObjectAmount
|
||||
{
|
||||
|
||||
@@ -361,6 +361,11 @@ namespace Barotrauma
|
||||
if (subElement.Attribute("index") != null)
|
||||
{
|
||||
int locationTypeChangeIndex = subElement.GetAttributeInt("index", 0);
|
||||
if (locationTypeChangeIndex < 0 || locationTypeChangeIndex >= Type.CanChangeTo.Count)
|
||||
{
|
||||
DebugConsole.AddWarning($"Failed to activate a location type change in the location \"{Name}\". Location index out of bounds ({locationTypeChangeIndex}).");
|
||||
continue;
|
||||
}
|
||||
PendingLocationTypeChange = (Type.CanChangeTo[locationTypeChangeIndex], timer, null);
|
||||
}
|
||||
else
|
||||
@@ -1059,12 +1064,21 @@ namespace Barotrauma
|
||||
if (PendingLocationTypeChange.Value.parentMission != null)
|
||||
{
|
||||
changeElement.Add(new XAttribute("missionidentifier", PendingLocationTypeChange.Value.parentMission.Identifier));
|
||||
locationElement.Add(changeElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
changeElement.Add(new XAttribute("index", Type.CanChangeTo.IndexOf(PendingLocationTypeChange.Value.typeChange)));
|
||||
int index = Type.CanChangeTo.IndexOf(PendingLocationTypeChange.Value.typeChange);
|
||||
changeElement.Add(new XAttribute("index", index));
|
||||
if (index == -1)
|
||||
{
|
||||
DebugConsole.AddWarning($"Invalid location type change in the location \"{Name}\". Unknown type change ({PendingLocationTypeChange.Value.typeChange.ChangeToType}).");
|
||||
}
|
||||
else
|
||||
{
|
||||
locationElement.Add(changeElement);
|
||||
}
|
||||
}
|
||||
locationElement.Add(changeElement);
|
||||
}
|
||||
|
||||
if (LocationTypeChangeCooldown > 0)
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace Barotrauma
|
||||
|
||||
public readonly float BeaconStationChance;
|
||||
|
||||
public readonly CharacterTeamType OutpostTeam;
|
||||
|
||||
public readonly List<LocationTypeChange> CanChangeTo = new List<LocationTypeChange>();
|
||||
|
||||
public readonly List<string> MissionIdentifiers = new List<string>();
|
||||
@@ -90,6 +92,9 @@ namespace Barotrauma
|
||||
|
||||
ReplaceInRadiation = element.GetAttributeString(nameof(ReplaceInRadiation).ToLower(), "");
|
||||
|
||||
string teamStr = element.GetAttributeString("outpostteam", "FriendlyNPC");
|
||||
Enum.TryParse(teamStr, out OutpostTeam);
|
||||
|
||||
string nameFile = element.GetAttributeString("namefile", "Content/Map/locationNames.txt");
|
||||
try
|
||||
{
|
||||
|
||||
@@ -316,20 +316,13 @@ namespace Barotrauma
|
||||
if (connection2.Locations[1] == connection.Locations[0]) { connection2.Locations[1] = connection.Locations[1]; }
|
||||
}
|
||||
}
|
||||
|
||||
HashSet<Location> connectedLocations = new HashSet<Location>();
|
||||
|
||||
foreach (LocationConnection connection in Connections)
|
||||
{
|
||||
connection.Locations[0].Connections.Add(connection);
|
||||
connection.Locations[1].Connections.Add(connection);
|
||||
|
||||
connectedLocations.Add(connection.Locations[0]);
|
||||
connectedLocations.Add(connection.Locations[1]);
|
||||
}
|
||||
|
||||
//remove orphans
|
||||
Locations.RemoveAll(c => !connectedLocations.Contains(c));
|
||||
|
||||
//remove locations that are too close to each other
|
||||
float minLocationDistanceSqr = generationParams.MinLocationDistance * generationParams.MinLocationDistance;
|
||||
for (int i = Locations.Count - 1; i >= 0; i--)
|
||||
@@ -443,6 +436,9 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
//remove orphans
|
||||
Locations.RemoveAll(l => !Connections.Any(c => c.Locations.Contains(l)));
|
||||
|
||||
foreach (LocationConnection connection in Connections)
|
||||
{
|
||||
connection.Difficulty = MathHelper.Clamp((connection.CenterPos.X / Width * 100) + Rand.Range(-10.0f, 0.0f, Rand.RandSync.Server), 1.2f, 100.0f);
|
||||
@@ -654,10 +650,12 @@ namespace Barotrauma
|
||||
CurrentLocation.CreateStore();
|
||||
OnLocationChanged?.Invoke(prevLocation, CurrentLocation);
|
||||
|
||||
if (GameMain.GameSession?.GameMode is CampaignMode campaign && campaign.CampaignMetadata is { } metadata)
|
||||
if (GameMain.GameSession is { Campaign: { CampaignMetadata: { } metadata } })
|
||||
{
|
||||
metadata.SetValue("campaign.location.id", CurrentLocationIndex);
|
||||
metadata.SetValue("campaign.location.name", CurrentLocation.Name);
|
||||
metadata.SetValue("campaign.location.biome", CurrentLocation.Biome?.Identifier ?? "null");
|
||||
metadata.SetValue("campaign.location.type", CurrentLocation.Type?.Identifier ?? "null");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -185,10 +185,6 @@ namespace Barotrauma
|
||||
{
|
||||
return -WorldPosition.Y * Physics.DisplayToRealWorldRatio;
|
||||
}
|
||||
else if (GameMain.GameSession?.Campaign == null)
|
||||
{
|
||||
return (-(WorldPosition.Y - Level.Loaded.GenerationParams.Height) + 80000.0f) * Physics.DisplayToRealWorldRatio;
|
||||
}
|
||||
return Level.Loaded.GetRealWorldDepth(WorldPosition.Y);
|
||||
}
|
||||
}
|
||||
@@ -254,7 +250,7 @@ namespace Barotrauma
|
||||
get
|
||||
{
|
||||
if (Level.Loaded == null || subBody == null) { return false; }
|
||||
return RealWorldDepth > Level.Loaded.RealWorldCrushDepth & RealWorldDepth > RealWorldCrushDepth;
|
||||
return RealWorldDepth > Level.Loaded.RealWorldCrushDepth && RealWorldDepth > RealWorldCrushDepth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,6 +320,7 @@ namespace Barotrauma
|
||||
{
|
||||
Info.Type = SubmarineType.Wreck;
|
||||
ShowSonarMarker = false;
|
||||
DockedTo.ForEach(s => s.ShowSonarMarker = false);
|
||||
PhysicsBody.FarseerBody.BodyType = BodyType.Static;
|
||||
TeamID = CharacterTeamType.None;
|
||||
|
||||
|
||||
@@ -450,12 +450,21 @@ namespace Barotrauma
|
||||
if (GameMain.GameSession?.GameMode is TestGameMode) { return; }
|
||||
#endif
|
||||
if (Level.Loaded == null) { return; }
|
||||
float submarineDepth = submarine.RealWorldDepth;
|
||||
if (!Submarine.AtDamageDepth) { return; }
|
||||
|
||||
//camera shake and sounds start playing 500 meters before crush depth
|
||||
float depthEffectThreshold = 500.0f;
|
||||
if (Submarine.RealWorldDepth < Level.Loaded.RealWorldCrushDepth - depthEffectThreshold && Submarine.RealWorldDepth < Submarine.RealWorldCrushDepth - depthEffectThreshold)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
depthDamageTimer -= deltaTime;
|
||||
if (depthDamageTimer > 0.0f) { return; }
|
||||
|
||||
#if CLIENT
|
||||
SoundPlayer.PlayDamageSound("pressure", Rand.Range(0.0f, 100.0f), submarine.WorldPosition + Rand.Vector(Rand.Range(0.0f, Math.Min(submarine.Borders.Width, submarine.Borders.Height))), 20000.0f);
|
||||
#endif
|
||||
|
||||
foreach (Structure wall in Structure.WallList)
|
||||
{
|
||||
if (wall.Submarine != submarine) { continue; }
|
||||
@@ -463,12 +472,14 @@ namespace Barotrauma
|
||||
float wallCrushDepth = wall.CrushDepth;
|
||||
if (submarine.Info.SubmarineClass == SubmarineClass.DeepDiver) { wallCrushDepth *= 1.2f; }
|
||||
float pastCrushDepth = submarine.RealWorldDepth - wallCrushDepth;
|
||||
if (pastCrushDepth < 0) { return; }
|
||||
Explosion.RangedStructureDamage(wall.WorldPosition, 100.0f, pastCrushDepth * 0.1f, levelWallDamage: 0.0f);
|
||||
if (pastCrushDepth > 0)
|
||||
{
|
||||
Explosion.RangedStructureDamage(wall.WorldPosition, 100.0f, pastCrushDepth * 0.1f, levelWallDamage: 0.0f);
|
||||
}
|
||||
if (Character.Controlled != null && Character.Controlled.Submarine == submarine)
|
||||
{
|
||||
GameMain.GameScreen.Cam.Shake = Math.Max(GameMain.GameScreen.Cam.Shake, Math.Min(pastCrushDepth * 0.001f, 50.0f));
|
||||
}
|
||||
GameMain.GameScreen.Cam.Shake = Math.Max(GameMain.GameScreen.Cam.Shake, MathHelper.Clamp(pastCrushDepth * 0.001f, 1.0f, 50.0f));
|
||||
}
|
||||
}
|
||||
|
||||
depthDamageTimer = 10.0f;
|
||||
|
||||
Reference in New Issue
Block a user