Merge branch 'dev' of https://github.com/Regalis11/Barotrauma.git into unstable-tests

This commit is contained in:
Evil Factory
2022-04-08 12:52:28 -03:00
990 changed files with 44338 additions and 38589 deletions
@@ -14,7 +14,7 @@ namespace Barotrauma
{
public static List<MapEntity> mapEntityList = new List<MapEntity>();
public readonly MapEntityPrefab prefab;
public readonly MapEntityPrefab Prefab;
protected List<ushort> linkedToID;
public List<ushort> unresolvedLinkedToID;
@@ -28,23 +28,22 @@ namespace Barotrauma
/// </summary>
protected readonly List<Upgrade> Upgrades = new List<Upgrade>();
public HashSet<string> disallowedUpgrades = new HashSet<string>();
[Editable, Serialize("", true)]
public readonly HashSet<Identifier> DisallowedUpgradeSet = new HashSet<Identifier>();
[Editable, Serialize("", IsPropertySaveable.Yes)]
public string DisallowedUpgrades
{
get { return string.Join(",", disallowedUpgrades); }
get { return string.Join(",", DisallowedUpgradeSet); }
set
{
disallowedUpgrades.Clear();
DisallowedUpgradeSet.Clear();
if (!string.IsNullOrWhiteSpace(value))
{
string[] splitTags = value.Split(',');
foreach (string tag in splitTags)
{
string[] splitTag = tag.Trim().Split(':');
splitTag[0] = splitTag[0].ToLowerInvariant();
disallowedUpgrades.Add(string.Join(":", splitTag));
DisallowedUpgradeSet.Add(string.Join(":", splitTag).ToIdentifier());
}
}
}
@@ -109,19 +108,19 @@ namespace Barotrauma
get { return false; }
}
public List<string> AllowedLinks => prefab == null ? new List<string>() : prefab.AllowedLinks;
public IEnumerable<Identifier> AllowedLinks => Prefab == null ? Enumerable.Empty<Identifier>() : Prefab.AllowedLinks;
public bool ResizeHorizontal
{
get { return prefab != null && prefab.ResizeHorizontal; }
get { return Prefab != null && Prefab.ResizeHorizontal; }
}
public bool ResizeVertical
{
get { return prefab != null && prefab.ResizeVertical; }
get { return Prefab != null && Prefab.ResizeVertical; }
}
//for upgrading the dimensions of the entity from xml
[Serialize(0, false)]
[Serialize(0, IsPropertySaveable.No)]
public int RectWidth
{
get { return rect.Width; }
@@ -132,7 +131,7 @@ namespace Barotrauma
}
}
//for upgrading the dimensions of the entity from xml
[Serialize(0, false)]
[Serialize(0, IsPropertySaveable.No)]
public int RectHeight
{
get { return rect.Height; }
@@ -148,7 +147,7 @@ namespace Barotrauma
public bool SpriteDepthOverrideIsSet { get; private set; }
public float SpriteOverrideDepth => SpriteDepth;
private float _spriteOverrideDepth = float.NaN;
[Editable(0.001f, 0.999f, decimals: 3), Serialize(float.NaN, true)]
[Editable(0.001f, 0.999f, decimals: 3), Serialize(float.NaN, IsPropertySaveable.Yes)]
public float SpriteDepth
{
get
@@ -167,10 +166,10 @@ namespace Barotrauma
}
}
[Serialize(1f, true), Editable(0.01f, 10f, DecimalCount = 3, ValueStep = 0.1f)]
[Serialize(1f, IsPropertySaveable.Yes), Editable(0.01f, 10f, DecimalCount = 3, ValueStep = 0.1f)]
public virtual float Scale { get; set; } = 1;
[Editable, Serialize(false, true)]
[Editable, Serialize(false, IsPropertySaveable.Yes)]
public bool HiddenInGame
{
get;
@@ -226,14 +225,14 @@ namespace Barotrauma
}
}
[Serialize(true, true)]
[Serialize(true, IsPropertySaveable.Yes)]
public bool RemoveIfLinkedOutpostDoorInUse
{
get;
protected set;
} = true;
[Serialize("", true, "Submarine editor layer")]
[Serialize("", IsPropertySaveable.Yes, "Submarine editor layer")]
public string Layer { get; set; }
/// <summary>
@@ -250,7 +249,7 @@ namespace Barotrauma
public MapEntity(MapEntityPrefab prefab, Submarine submarine, ushort id) : base(submarine, id)
{
this.prefab = prefab;
this.Prefab = prefab;
Scale = prefab != null ? prefab.Scale : 1;
}
@@ -304,12 +303,12 @@ namespace Barotrauma
return (Submarine.RectContains(WorldRect, position));
}
public bool HasUpgrade(string identifier)
public bool HasUpgrade(Identifier identifier)
{
return GetUpgrade(identifier) != null;
}
public Upgrade GetUpgrade(string identifier)
public Upgrade GetUpgrade(Identifier identifier)
{
return Upgrades.Find(upgrade => upgrade.Identifier == identifier);
}
@@ -332,7 +331,7 @@ namespace Barotrauma
{
AddUpgrade(upgrade, createNetworkEvent);
}
DebugConsole.Log($"Set (ID: {ID} {prefab.Name})'s \"{upgrade.Prefab.Name}\" upgrade to level {upgrade.Level}");
DebugConsole.Log($"Set (ID: {ID} {Prefab.Name})'s \"{upgrade.Prefab.Name}\" upgrade to level {upgrade.Level}");
}
/// <summary>
@@ -345,7 +344,7 @@ namespace Barotrauma
return false;
}
if (disallowedUpgrades.Contains(upgrade.Identifier)) { return false; }
if (DisallowedUpgradeSet.Contains(upgrade.Identifier)) { return false; }
Upgrade existingUpgrade = GetUpgrade(upgrade.Identifier);
@@ -655,7 +654,7 @@ namespace Barotrauma
IdRemap idRemap = new IdRemap(parentElement, idOffset);
List<MapEntity> entities = new List<MapEntity>();
foreach (XElement element in parentElement.Elements())
foreach (var element in parentElement.Elements())
{
string typeName = element.Name.ToString();
@@ -678,7 +677,7 @@ namespace Barotrauma
if (t == typeof(Structure))
{
string name = element.Attribute("name").Value;
string identifier = element.GetAttributeString("identifier", "");
Identifier identifier = element.GetAttributeIdentifier("identifier", "");
StructurePrefab structurePrefab = Structure.FindPrefab(name, identifier);
if (structurePrefab == null)
{
@@ -692,7 +691,7 @@ namespace Barotrauma
try
{
MethodInfo loadMethod = t.GetMethod("Load", new[] { typeof(XElement), typeof(Submarine), typeof(IdRemap) });
MethodInfo loadMethod = t.GetMethod("Load", new[] { typeof(ContentXElement), typeof(Submarine), typeof(IdRemap) });
if (loadMethod == null)
{
DebugConsole.ThrowError("Could not find the method \"Load\" in " + t + ".");
@@ -703,7 +702,7 @@ namespace Barotrauma
}
else
{
object newEntity = loadMethod.Invoke(t, new object[] { element, submarine, idRemap });
object newEntity = loadMethod.Invoke(t, new object[] { element.FromPackage(null), submarine, idRemap });
if (newEntity != null)
{
entities.Add((MapEntity)newEntity);