v1.6.17.0 (Unto the Breach update)

This commit is contained in:
Regalis11
2024-10-22 17:29:04 +03:00
parent e74b3cdb17
commit 6e6c17e100
417 changed files with 17166 additions and 5870 deletions
@@ -11,6 +11,9 @@ namespace Barotrauma
{
public readonly static PrefabCollection<LevelGenerationParams> LevelParams = new PrefabCollection<LevelGenerationParams>();
public LocalizedString DisplayName { get; private set; }
public LocalizedString Description { get; private set; }
public string Name => Identifier.Value;
public Identifier OldIdentifier { get; }
@@ -68,12 +71,18 @@ namespace Barotrauma
set;
}
[Serialize(false, IsPropertySaveable.Yes, "If the given level is only used in PvP modes"), Editable]
public bool IsPvPLevel { get; set; }
[Serialize(100.0f, IsPropertySaveable.Yes, "If there are multiple level generation parameters available for a level in a given biome, their commonness determines how likely it is for one to get selected."), Editable(MinValueFloat = 0, MaxValueFloat = 100)]
public float Commonness
{
get;
set;
}
[Serialize(false, IsPropertySaveable.Yes, "If the level is a transition from the previous biome to this one."), Editable]
public bool TransitionFromPreviousBiome { get; set; }
[Serialize(0.0f, IsPropertySaveable.Yes, "The difficulty of the level has to be above or equal to this for these parameters to get chosen for the level."), Editable(MinValueFloat = 0, MaxValueFloat = 100)]
public float MinLevelDifficulty
@@ -497,6 +506,9 @@ namespace Barotrauma
[Serialize(0, IsPropertySaveable.Yes, description: "The maximum number of alien ruins in the level."), Editable(MinValueInt = 0, MaxValueInt = 10)]
public int MaxRuinCount { get; set; }
[Serialize(1.0f, IsPropertySaveable.Yes, description: "The probability of spawning a ruin in the level. If the level can have multiple ruins, the probability is evaluated separately for each."), Editable(MinValueFloat = 0.0f, MaxValueFloat = 1.0f, DecimalCount = 2)]
public float RuinSpawnProbability { get; set; }
// TODO: Move the wreck parameters under a separate class?
#region Wreck parameters
@@ -512,6 +524,9 @@ namespace Barotrauma
[Serialize(5, IsPropertySaveable.Yes, description: "The maximum number of corpses per wreck."), Editable(MinValueInt = 0, MaxValueInt = 20)]
public int MaxCorpseCount { get; set; }
[Serialize(0.0f, IsPropertySaveable.Yes, description: "How likely is it that a character set to be spawned as a corpse spawns as a human husk instead? Percentage from 0 to 1 per character."), Editable(MinValueFloat = 0, MaxValueFloat = 1)]
public float HuskProbability { get; set; }
[Serialize(0.0f, IsPropertySaveable.Yes, description: "How likely is it that a Thalamus inhabits a wreck. Percentage from 0 to 1 per wreck."), Editable(MinValueFloat = 0, MaxValueFloat = 1)]
public float ThalamusProbability { get; set; }
@@ -673,7 +688,7 @@ namespace Barotrauma
}
}
public static LevelGenerationParams GetRandom(string seed, LevelData.LevelType type, float difficulty, Identifier biomeId = default)
public static LevelGenerationParams GetRandom(string seed, LevelData.LevelType type, float difficulty, Identifier biomeId = default, bool pvpOnly = false, bool biomeTransition = false)
{
Rand.SetSyncedSeed(ToolBox.StringToInt(seed));
@@ -688,7 +703,41 @@ namespace Barotrauma
lp.Type == type &&
(lp.AnyBiomeAllowed || lp.AllowedBiomeIdentifiers.Any()) &&
!lp.AllowedBiomeIdentifiers.Contains("None".ToIdentifier()));
if (biomeId.IsEmpty)
if (biomeTransition)
{
var biomeTransitionParams = matchingLevelParams.Where(lp =>
lp.TransitionFromPreviousBiome && lp.AllowedBiomeIdentifiers.Contains(biomeId));
if (biomeTransitionParams.Any())
{
return ToolBox.SelectWeightedRandom(biomeTransitionParams, p => p.Commonness, Rand.RandSync.ServerAndClient);
}
}
else
{
matchingLevelParams = matchingLevelParams.Where(lp => !lp.TransitionFromPreviousBiome);
}
if (pvpOnly)
{
var pvpOnlyLevels = matchingLevelParams.Where(static lp => lp.IsPvPLevel);
if (pvpOnlyLevels.Any())
{
matchingLevelParams = pvpOnlyLevels;
}
else
{
DebugConsole.AddWarning("No PvP specific level generation presets found - using all level generation presets instead.");
}
}
else
{
matchingLevelParams = matchingLevelParams.Where(static lp => !lp.IsPvPLevel);
}
if (biomeId.IsEmpty || biomeId == "Random")
{
//we don't want end levels when generating a completely random level (e.g. in mission mode)
matchingLevelParams = matchingLevelParams.Where(lp => lp.AnyBiomeAllowed || !lp.AllowedBiomeIdentifiers.All(b => Biome.Prefabs[b].IsEndBiome));
@@ -746,6 +795,20 @@ namespace Barotrauma
allowedBiomeIdentifiers.Remove("any".ToIdentifier());
AllowedBiomeIdentifiers = allowedBiomeIdentifiers.ToImmutableHashSet();
DisplayName = TextManager.Get($"levelname.{Identifier}");
Description = TextManager.Get($"leveldescription.{Identifier}");
var nameIdentifier = element.GetAttributeIdentifier("nameidentifier", Identifier.Empty);
var descriptionIdentifier = element.GetAttributeIdentifier("descriptionidentifier", Identifier.Empty);
if (!nameIdentifier.IsEmpty)
{
DisplayName = TextManager.Get(nameIdentifier);
}
if (!descriptionIdentifier.IsEmpty)
{
Description = TextManager.Get(descriptionIdentifier);
}
foreach (var subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())