Build 0.18.1.0

This commit is contained in:
Markus Isberg
2022-05-13 22:55:07 +09:00
parent 7547a9b78a
commit d4f6f4cf88
32 changed files with 1263 additions and 25 deletions
@@ -301,8 +301,12 @@ namespace Barotrauma
/// </summary>
public enum LevelGenStage
{
LevelGenParams,
Size,
GenStart,
TunnelGen,
AbyssGen,
CaveGen,
VoronoiGen,
VoronoiGen2,
VoronoiGen3,
@@ -327,6 +331,11 @@ namespace Barotrauma
equalityCheckValues[stage] = Rand.Int(int.MaxValue, Rand.RandSync.ServerAndClient);
}
private void SetEqualityCheckValue(LevelGenStage stage, int value)
{
equalityCheckValues[stage] = value;
}
private void ClearEqualityCheckValues()
{
foreach (LevelGenStage stage in Enum.GetValues(typeof(LevelGenStage)))
@@ -445,6 +454,9 @@ namespace Barotrauma
}
GenerateEqualityCheckValue(LevelGenStage.GenStart);
SetEqualityCheckValue(LevelGenStage.LevelGenParams, unchecked((int)GenerationParams.UintIdentifier));
SetEqualityCheckValue(LevelGenStage.Size, borders.Width ^ borders.Height << 16);
GenerateEqualityCheckValue(LevelGenStage.TunnelGen);
LevelObjectManager = new LevelObjectManager();
@@ -582,10 +594,12 @@ namespace Barotrauma
}
int sideTunnelCount = Rand.Range(GenerationParams.SideTunnelCount.X, GenerationParams.SideTunnelCount.Y + 1, Rand.RandSync.ServerAndClient);
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 && t != endHole && t != abyssTunnel);
Tunnel tunnelToBranchOff = validTunnels[Rand.Int(validTunnels.Count, Rand.RandSync.ServerAndClient)];
if (tunnelToBranchOff == null) { tunnelToBranchOff = mainPath; }
@@ -600,7 +614,13 @@ namespace Barotrauma
CalculateTunnelDistanceField(null);
GenerateSeaFloorPositions();
GenerateEqualityCheckValue(LevelGenStage.AbyssGen);
GenerateAbyssArea();
GenerateEqualityCheckValue(LevelGenStage.CaveGen);
GenerateCaves(mainPath);
GenerateEqualityCheckValue(LevelGenStage.VoronoiGen);
@@ -584,7 +584,9 @@ namespace Barotrauma
throw new InvalidOperationException("Level generation presets not found - using default presets");
}
var matchingLevelParams = LevelParams.Where(lp =>
var levelParamsOrdered = LevelParams.OrderBy(l => l.UintIdentifier);
var matchingLevelParams = levelParamsOrdered.Where(lp =>
lp.Type == type &&
(lp.AnyBiomeAllowed || lp.AllowedBiomeIdentifiers.Any()) &&
!lp.AllowedBiomeIdentifiers.Contains("None".ToIdentifier()));
@@ -598,11 +600,11 @@ namespace Barotrauma
if (!biome.IsEmpty)
{
//try to find params that at least have a suitable type
matchingLevelParams = LevelParams.Where(lp => lp.Type == type);
matchingLevelParams = levelParamsOrdered.Where(lp => lp.Type == type);
if (!matchingLevelParams.Any())
{
//still not found, give up and choose some params randomly
matchingLevelParams = LevelParams;
matchingLevelParams = levelParamsOrdered;
}
}
}