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
@@ -18,11 +18,14 @@ namespace Barotrauma
bool skipMainSubs = GameMain.GameSession.GameMode is CampaignMode { IsFirstRound: false };
if (!skipMainSubs)
{
if (Submarine.MainSub is Submarine mainSub && mainSub.Info.IsPlayer)
{
SpawnStartItems(mainSub);
}
for (int i = 0; i < Submarine.MainSubs.Length; i++)
{
var sub = Submarine.MainSubs[i];
if (sub == null || sub.Info.InitialSuppliesSpawned) { continue; }
SpawnStartItems(sub);
var subs = sub.GetConnectedSubs().Where(s => s.TeamID == sub.TeamID);
CreateAndPlace(subs);
subs.ForEach(s => s.Info.InitialSuppliesSpawned = true);
@@ -79,7 +82,6 @@ namespace Barotrauma
return;
}
initialSpawnPos = spawnHull;
}
else
{
@@ -388,7 +388,7 @@ namespace Barotrauma.Items.Components
IsActive = isActive;
}
public void SetRequiredItems(ContentXElement element)
public void SetRequiredItems(ContentXElement element, bool allowEmpty = false)
{
bool returnEmpty = false;
#if CLIENT
@@ -410,7 +410,7 @@ namespace Barotrauma.Items.Components
requiredItems[ri.Type].Add(ri);
}
}
else
else if (!allowEmpty)
{
DebugConsole.ThrowError("Error in item config \"" + item.ConfigFilePath + "\" - component " + GetType().ToString() + " requires an item with no identifiers.");
}
@@ -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;
}
}
}
@@ -911,7 +911,7 @@ namespace Barotrauma.Networking
public LootedMoneyDestination LootedMoneyDestination { get; set; }
[Serialize(999999, IsPropertySaveable.Yes)]
public int MaximumTransferRequest { get; set; }
public int MaximumMoneyTransferRequest { get; set; }
private int maxMissionCount = CampaignSettings.DefaultMaxMissionCount;
@@ -1107,7 +1107,7 @@ namespace Barotrauma
itemComponent.requiredItems.Clear();
itemComponent.DisabledRequiredItems.Clear();
itemComponent.SetRequiredItems(element);
itemComponent.SetRequiredItems(element, allowEmpty: true);
break;
}
}