Build 0.20.4.0

This commit is contained in:
Markus Isberg
2022-11-11 17:57:23 +02:00
parent edaf4b09fe
commit 54712b5dc9
201 changed files with 7618 additions and 2020 deletions
@@ -1,3 +1,5 @@
using Barotrauma.Extensions;
using System.Collections.Generic;
using System.Collections.Immutable;
namespace Barotrauma
@@ -18,6 +20,14 @@ namespace Barotrauma
public readonly ImmutableHashSet<int> AllowedZones;
private readonly SubmarineAvailability? submarineAvailability;
private readonly ImmutableHashSet<SubmarineAvailability> submarineAvailabilityOverrides;
public readonly record struct SubmarineAvailability(
Identifier LocationType,
SubmarineClass Class = SubmarineClass.Undefined,
int MaxTier = 0);
public Biome(ContentXElement element, LevelGenerationParametersFile file) : base(file, ParseIdentifier(element))
{
OldIdentifier = element.GetAttributeIdentifier("oldidentifier", Identifier.Empty);
@@ -34,6 +44,26 @@ namespace Barotrauma
AllowedZones = element.GetAttributeIntArray("AllowedZones", new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }).ToImmutableHashSet();
MinDifficulty = element.GetAttributeFloat("MinDifficulty", 0);
maxDifficulty = element.GetAttributeFloat("MaxDifficulty", 100);
var submarineAvailabilityOverrides = new HashSet<SubmarineAvailability>();
if (element.GetChildElement("submarines") is ContentXElement availabilityElement)
{
submarineAvailability = GetAvailability(availabilityElement);
foreach (var overrideElement in availabilityElement.GetChildElements("override"))
{
var availabilityOverride = GetAvailability(overrideElement);
submarineAvailabilityOverrides.Add(availabilityOverride);
}
}
this.submarineAvailabilityOverrides = submarineAvailabilityOverrides.ToImmutableHashSet();
static SubmarineAvailability GetAvailability(ContentXElement element)
{
return new SubmarineAvailability(
LocationType: element.GetAttributeIdentifier("locationtype", Identifier.Empty),
Class: element.GetAttributeEnum("class", SubmarineClass.Undefined),
MaxTier: element.GetAttributeInt("maxtier", 0));
}
}
public static Identifier ParseIdentifier(ContentXElement element)
@@ -47,6 +77,31 @@ namespace Barotrauma
return identifier;
}
public int HighestSubmarineTierAvailable(SubmarineClass subClass, Identifier locationType)
{
if (!submarineAvailability.HasValue)
{
// If the availability is not explicitly defined, make all subs available
return SubmarineInfo.HighestTier;
}
int maxTier = submarineAvailability.Value.MaxTier;
if (submarineAvailabilityOverrides.FirstOrNull(a => a.LocationType == locationType && a.Class == subClass) is SubmarineAvailability locationAndClassOverride)
{
maxTier = locationAndClassOverride.MaxTier;
}
else if (submarineAvailabilityOverrides.FirstOrNull(a => a.LocationType == locationType && a.Class == SubmarineClass.Undefined) is SubmarineAvailability locationOverride)
{
maxTier = locationOverride.MaxTier;
}
else if (submarineAvailabilityOverrides.FirstOrNull(a => a.LocationType == Identifier.Empty && a.Class == subClass) is SubmarineAvailability classOverride)
{
maxTier = classOverride.MaxTier;
}
return maxTier;
}
public bool IsSubmarineAvailable(SubmarineInfo info, Identifier locationType) => info.Tier <= HighestSubmarineTierAvailable(info.SubmarineClass, locationType);
public override void Dispose() { }
}
}
@@ -447,7 +447,7 @@ namespace Barotrauma
private Level(LevelData levelData) : base(null, 0)
{
this.LevelData = levelData;
LevelData = levelData;
borders = new Rectangle(Point.Zero, levelData.Size);
}
@@ -3939,7 +3939,7 @@ namespace Barotrauma
}
SubmarineInfo outpostInfo;
Submarine outpost;
Submarine outpost = null;
if (i == 0 && preSelectedStartOutpost == null || i == 1 && preSelectedEndOutpost == null)
{
if (OutpostGenerationParams.OutpostParams.Any() || LevelData.ForceOutpostGenerationParams != null)
@@ -59,6 +59,7 @@ namespace Barotrauma
public readonly List<EventPrefab> EventHistory = new List<EventPrefab>();
public readonly List<EventPrefab> NonRepeatableEvents = new List<EventPrefab>();
public readonly HashSet<Identifier> UsedUniqueSets = new HashSet<Identifier>();
public bool EventsExhausted { get; set; }
@@ -143,10 +144,11 @@ namespace Barotrauma
string[] nonRepeatablePrefabNames = element.GetAttributeStringArray("nonrepeatableevents", new string[] { });
NonRepeatableEvents.AddRange(EventPrefab.Prefabs.Where(p => nonRepeatablePrefabNames.Any(n => p.Identifier == n)));
UsedUniqueSets = element.GetAttributeIdentifierArray(nameof(UsedUniqueSets), Array.Empty<Identifier>()).ToHashSet();
EventsExhausted = element.GetAttributeBool(nameof(EventsExhausted).ToLower(), false);
}
/// <summary>
/// Instantiates level data using the properties of the connection (seed, size, difficulty)
/// </summary>
@@ -284,6 +286,12 @@ namespace Barotrauma
newElement.Add(new XAttribute("nonrepeatableevents", string.Join(',', NonRepeatableEvents.Select(p => p.Identifier))));
}
}
if (UsedUniqueSets.Any())
{
newElement.Add(new XAttribute(nameof(UsedUniqueSets), string.Join(',', UsedUniqueSets)));
}
parentElement.Add(newElement);
}
}
@@ -287,6 +287,13 @@ namespace Barotrauma
private set;
}
[Serialize("1.0,1.0,1.0,1.0", IsPropertySaveable.Yes), Editable]
public Color SpriteColor
{
get;
private set;
}
public string Name => Identifier.Value;
public List<ChildObject> ChildObjects
@@ -661,7 +661,7 @@ namespace Barotrauma
if (effect.HasTargetType(StatusEffect.TargetType.NearbyItems) || effect.HasTargetType(StatusEffect.TargetType.NearbyCharacters))
{
targets.Clear();
targets.AddRange(effect.GetNearbyTargets(worldPosition, targets));
effect.AddNearbyTargets(worldPosition, targets);
effect.Apply(effect.type, deltaTime, triggerer, targets);
}
}