Release 1.9.7.0 - Summer Update 2025

This commit is contained in:
Regalis11
2025-06-17 16:38:11 +03:00
parent 22227f13e5
commit ea5a2bc693
297 changed files with 7344 additions and 2421 deletions
@@ -1,6 +1,7 @@
using Barotrauma.Extensions;
using Barotrauma.Items.Components;
using Microsoft.Xna.Framework;
using RestSharp.Extensions;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
@@ -12,6 +13,10 @@ using System.Xml.Linq;
namespace Barotrauma
{
/// <summary>
/// Is the value of the property saved when saving (serializing) the entity?
/// Can be set to false if e.g. the value doesn't ever change from the prefab value, or if changes to it shouldn't persist between rounds.
/// </summary>
public enum IsPropertySaveable
{
Yes,
@@ -883,7 +888,16 @@ namespace Barotrauma
public static Dictionary<Identifier, SerializableProperty> DeserializeProperties(object obj, XElement element = null)
{
Dictionary<Identifier, SerializableProperty> dictionary = GetProperties(obj);
#if DEBUG
var nonPublicProperties = obj.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Instance);
foreach (var property in nonPublicProperties)
{
if (property.GetAttribute<Serialize>() != null)
{
DebugConsole.ThrowError($"The property {property.Name} in class {obj.GetType()} is set as serializable, but isn't public. Serializable properties must have at least a public getter.");
}
}
#endif
foreach (var property in dictionary.Values)
{
//set the value of the property to the default value if there is one
@@ -239,6 +239,16 @@ namespace Barotrauma
return element.GetAttributeIdentifierArray(key, null, trim)?.ToImmutableHashSet()
?? defaultValue;
}
public static float? GetAttributeNullableFloat(this XElement element, string attributeName)
{
if (element.GetAttribute(attributeName) is XAttribute attribute)
{
// if there is an error in parsing, we will return the default value, which may cause edge case errors down the line
return GetAttributeFloat(attribute, 0.0f);
}
return null;
}
public static float GetAttributeFloat(this XElement element, float defaultValue, params string[] matchingAttributeName)
{
@@ -253,7 +263,7 @@ namespace Barotrauma
return defaultValue;
}
public static float GetAttributeFloat(this XElement element, string name, float defaultValue) => GetAttributeFloat(element?.GetAttribute(name), defaultValue);
public static float GetAttributeFloat(this XAttribute attribute, float defaultValue)
@@ -352,6 +362,16 @@ namespace Barotrauma
}
return false;
}
public static int? GetAttributeNullableInt(this XElement element, string attributeName)
{
if (element.GetAttribute(attributeName) is XAttribute attribute)
{
// if there is an error in parsing, we will return the default value, which may cause edge case errors down the line
return GetAttributeInt(attribute, 0);
}
return null;
}
public static int GetAttributeInt(this XElement element, string name, int defaultValue) => GetAttributeInt(element?.GetAttribute(name), defaultValue);