Unstable 1.1.14.0
This commit is contained in:
@@ -85,7 +85,11 @@ namespace Barotrauma
|
||||
AllowRotating,
|
||||
Attachable,
|
||||
HasBody,
|
||||
Pickable
|
||||
Pickable,
|
||||
OnlyByStatusEffectsAndNetwork,
|
||||
HasIntegratedButtons,
|
||||
IsToggleableController,
|
||||
HasConnectionPanel
|
||||
}
|
||||
|
||||
public bool IsEditable(ISerializableEntity entity)
|
||||
@@ -115,6 +119,26 @@ namespace Barotrauma
|
||||
{
|
||||
return entity is Item item && item.GetComponent<Pickable>() != null;
|
||||
}
|
||||
case ConditionType.HasIntegratedButtons:
|
||||
{
|
||||
return entity is Door door && door.HasIntegratedButtons;
|
||||
}
|
||||
case ConditionType.OnlyByStatusEffectsAndNetwork:
|
||||
#if SERVER
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
case ConditionType.IsToggleableController:
|
||||
{
|
||||
return entity is Controller controller && controller.IsToggle && controller.Item.GetComponent<ConnectionPanel>() != null;
|
||||
}
|
||||
case ConditionType.HasConnectionPanel:
|
||||
{
|
||||
return
|
||||
(entity is Item item && item.GetComponent<ConnectionPanel>() != null) ||
|
||||
(entity is ItemComponent ic && ic.Item.GetComponent<ConnectionPanel>() != null);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -228,7 +252,7 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + parentObject + "\" to " + value + " (not a valid " + PropertyInfo.PropertyType + ")", e);
|
||||
DebugConsole.ThrowError($"Failed to set the value of the property \"{Name}\" of \"{parentObject}\" to {value} (not a valid {PropertyInfo.PropertyType})", e);
|
||||
return false;
|
||||
}
|
||||
try
|
||||
@@ -237,7 +261,7 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + parentObject.ToString() + "\" to " + value.ToString(), e);
|
||||
DebugConsole.ThrowError($"Failed to set the value of the property \"{Name}\" of \"{parentObject}\" to {value}", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -320,7 +344,7 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + parentObject.ToString() + "\" to " + value.ToString(), e);
|
||||
DebugConsole.ThrowError($"Failed to set the value of the property \"{Name}\" of \"{parentObject}\" to {value}", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -403,14 +427,14 @@ namespace Barotrauma
|
||||
PropertyInfo.SetValue(parentObject, XMLExtensions.ParseStringArray((string)value).ToIdentifiers().ToArray());
|
||||
return true;
|
||||
default:
|
||||
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + parentObject.ToString() + "\" to " + value.ToString());
|
||||
DebugConsole.ThrowError("(Cannot convert a string to a " + PropertyType.ToString() + ")");
|
||||
DebugConsole.ThrowError($"Failed to set the value of the property \"{Name}\" of \"{parentObject}\" to {value}");
|
||||
DebugConsole.ThrowError($"(Cannot convert a string to a {PropertyType})");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (PropertyType != value.GetType())
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + parentObject.ToString() + "\" to " + value.ToString());
|
||||
DebugConsole.ThrowError($"Failed to set the value of the property \"{Name}\" of \"{parentObject}\" to {value}");
|
||||
DebugConsole.ThrowError("(Non-matching type, should be " + PropertyType + " instead of " + value.GetType() + ")");
|
||||
return false;
|
||||
}
|
||||
@@ -420,7 +444,7 @@ namespace Barotrauma
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + parentObject.ToString() + "\" to " + value.ToString(), e);
|
||||
DebugConsole.ThrowError($"Failed to set the value of the property \"{Name}\" of \"{parentObject}\" to {value}", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -428,7 +452,7 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in SerializableProperty.TrySetValue", e);
|
||||
DebugConsole.ThrowError($"Error in SerializableProperty.TrySetValue (Property: {PropertyInfo.Name})", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -447,7 +471,7 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in SerializableProperty.TrySetValue", e);
|
||||
DebugConsole.ThrowError($"Error in SerializableProperty.TrySetValue (Property: {PropertyInfo.Name})", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -468,7 +492,7 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in SerializableProperty.TrySetValue", e);
|
||||
DebugConsole.ThrowError($"Error in SerializableProperty.TrySetValue (Property: {PropertyInfo.Name})", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -488,7 +512,7 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in SerializableProperty.TrySetValue", e);
|
||||
DebugConsole.ThrowError($"Error in SerializableProperty.TrySetValue (Property: {PropertyInfo.Name})", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1051,12 +1075,18 @@ namespace Barotrauma
|
||||
{
|
||||
if (!subElement.Name.ToString().Equals("upgrade", StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
var upgradeVersion = new Version(subElement.GetAttributeString("gameversion", "0.0.0.0"));
|
||||
if (savedVersion >= upgradeVersion) { continue; }
|
||||
|
||||
if (subElement.GetAttributeBool("campaignsaveonly", false))
|
||||
{
|
||||
if ((GameMain.GameSession?.LastSaveVersion ?? GameMain.Version) >= upgradeVersion) { continue; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (savedVersion >= upgradeVersion) { continue; }
|
||||
}
|
||||
foreach (XAttribute attribute in subElement.Attributes())
|
||||
{
|
||||
var attributeName = attribute.NameAsIdentifier();
|
||||
if (attributeName == "gameversion") { continue; }
|
||||
if (attributeName == "gameversion" || attributeName == "campaignsaveonly") { continue; }
|
||||
|
||||
if (attributeName == "refreshrect")
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Barotrauma
|
||||
{
|
||||
public static class XMLExtensions
|
||||
{
|
||||
private static ImmutableDictionary<Type, Func<string, object, object>> converters
|
||||
private readonly static ImmutableDictionary<Type, Func<string, object, object>> Converters
|
||||
= new Dictionary<Type, Func<string, object, object>>()
|
||||
{
|
||||
{ typeof(string), (str, defVal) => str },
|
||||
@@ -349,10 +349,11 @@ namespace Barotrauma
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int GetAttributeInt(this XElement element, string name, int defaultValue)
|
||||
|
||||
public static int GetAttributeInt(this XElement element, string name, int defaultValue) => GetAttributeInt(element?.GetAttribute(name), defaultValue);
|
||||
|
||||
public static int GetAttributeInt(this XAttribute attribute, int defaultValue)
|
||||
{
|
||||
var attribute = element?.GetAttribute(name);
|
||||
if (attribute == null) { return defaultValue; }
|
||||
|
||||
int val = defaultValue;
|
||||
@@ -361,12 +362,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (!Int32.TryParse(attribute.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out val))
|
||||
{
|
||||
val = (int)float.Parse(element.GetAttribute(name).Value, CultureInfo.InvariantCulture);
|
||||
val = (int)float.Parse(attribute.Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogAttributeError(attribute, element, e);
|
||||
LogAttributeError(attribute, attribute.Parent, e);
|
||||
}
|
||||
|
||||
return val;
|
||||
@@ -391,6 +392,25 @@ namespace Barotrauma
|
||||
return val;
|
||||
}
|
||||
|
||||
public static ushort GetAttributeUInt16(this XElement element, string name, ushort defaultValue)
|
||||
{
|
||||
var attribute = element?.GetAttribute(name);
|
||||
if (attribute == null) { return defaultValue; }
|
||||
|
||||
ushort val = defaultValue;
|
||||
|
||||
try
|
||||
{
|
||||
val = ushort.Parse(attribute.Value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogAttributeError(attribute, element, e);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
public static UInt64 GetAttributeUInt64(this XElement element, string name, UInt64 defaultValue)
|
||||
{
|
||||
var attribute = element?.GetAttribute(name);
|
||||
@@ -738,8 +758,8 @@ namespace Barotrauma
|
||||
string[] elems = strValue.Split(',');
|
||||
if (elems.Length != 2) { return defaultValue; }
|
||||
|
||||
return ((T1)converters[typeof(T1)].Invoke(elems[0], defaultValue.Item1),
|
||||
(T2)converters[typeof(T2)].Invoke(elems[1], defaultValue.Item2));
|
||||
return ((T1)Converters[typeof(T1)].Invoke(elems[0], defaultValue.Item1),
|
||||
(T2)Converters[typeof(T2)].Invoke(elems[1], defaultValue.Item2));
|
||||
}
|
||||
|
||||
public static Point ParsePoint(string stringPoint, bool errorMessages = true)
|
||||
|
||||
Reference in New Issue
Block a user