Build 1.1.4.0
This commit is contained in:
@@ -154,6 +154,7 @@ namespace Barotrauma
|
||||
{ typeof(float), "float" },
|
||||
{ typeof(string), "string" },
|
||||
{ typeof(Identifier), "identifier" },
|
||||
{ typeof(LanguageIdentifier), "languageidentifier" },
|
||||
{ typeof(LocalizedString), "localizedstring" },
|
||||
{ typeof(Point), "point" },
|
||||
{ typeof(Vector2), "vector2" },
|
||||
@@ -240,7 +241,7 @@ namespace Barotrauma
|
||||
switch (typeName)
|
||||
{
|
||||
case "bool":
|
||||
bool boolValue = value == "true" || value == "True";
|
||||
bool boolValue = value.ToIdentifier() == "true";
|
||||
if (TrySetBoolValueWithoutReflection(parentObject, boolValue)) { return true; }
|
||||
PropertyInfo.SetValue(parentObject, boolValue, null);
|
||||
break;
|
||||
@@ -290,6 +291,9 @@ namespace Barotrauma
|
||||
case "identifier":
|
||||
PropertyInfo.SetValue(parentObject, value.ToIdentifier());
|
||||
break;
|
||||
case "languageidentifier":
|
||||
PropertyInfo.SetValue(parentObject, value.ToLanguageIdentifier());
|
||||
break;
|
||||
case "localizedstring":
|
||||
PropertyInfo.SetValue(parentObject, new RawLString(value));
|
||||
break;
|
||||
@@ -373,6 +377,9 @@ namespace Barotrauma
|
||||
case "identifier":
|
||||
PropertyInfo.SetValue(parentObject, new Identifier((string)value));
|
||||
return true;
|
||||
case "languageidentifier":
|
||||
PropertyInfo.SetValue(parentObject, ((string)value).ToLanguageIdentifier());
|
||||
return true;
|
||||
case "localizedstring":
|
||||
PropertyInfo.SetValue(parentObject, new RawLString((string)value));
|
||||
return true;
|
||||
@@ -556,7 +563,7 @@ namespace Barotrauma
|
||||
|
||||
public static string GetSupportedTypeName(Type type)
|
||||
{
|
||||
if (type.IsEnum) return "Enum";
|
||||
if (type.IsEnum) { return "Enum"; }
|
||||
if (!supportedTypes.TryGetValue(type, out string typeName))
|
||||
{
|
||||
return null;
|
||||
@@ -693,6 +700,29 @@ namespace Barotrauma
|
||||
case nameof(Character.SpeedMultiplier):
|
||||
{ if (parentObject is Character character) { value = character.SpeedMultiplier; return true; } }
|
||||
break;
|
||||
case nameof(Character.PropulsionSpeedMultiplier):
|
||||
{ if (parentObject is Character character) { value = character.PropulsionSpeedMultiplier; return true; } }
|
||||
break;
|
||||
case nameof(Character.LowPassMultiplier):
|
||||
{ if (parentObject is Character character) { value = character.LowPassMultiplier; return true; } }
|
||||
break;
|
||||
case nameof(Character.HullOxygenPercentage):
|
||||
{
|
||||
if (parentObject is Character character)
|
||||
{
|
||||
value = character.HullOxygenPercentage;
|
||||
return true;
|
||||
}
|
||||
else if (parentObject is Item item)
|
||||
{
|
||||
value = item.HullOxygenPercentage;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case nameof(Door.Stuck):
|
||||
{ if (parentObject is Door door) { value = door.Stuck; return true; } }
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -740,6 +770,23 @@ namespace Barotrauma
|
||||
case nameof(Controller.State):
|
||||
if (parentObject is Controller controller) { value = controller.State; return true; }
|
||||
break;
|
||||
case nameof(Character.InWater):
|
||||
{
|
||||
if (parentObject is Character character)
|
||||
{
|
||||
value = character.InWater;
|
||||
return true;
|
||||
}
|
||||
else if (parentObject is Item item)
|
||||
{
|
||||
value = item.InWater;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case nameof(Rope.Snapped):
|
||||
if (parentObject is Rope rope) { value = rope.Snapped; return true; }
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -769,7 +816,7 @@ namespace Barotrauma
|
||||
switch (Name)
|
||||
{
|
||||
case nameof(Item.Condition):
|
||||
if (parentObject is Item item) { item.Condition = value; return true; }
|
||||
{ if (parentObject is Item item) { item.Condition = value; return true; } }
|
||||
break;
|
||||
case nameof(Powered.Voltage):
|
||||
if (parentObject is Powered powered) { powered.Voltage = value; return true; }
|
||||
@@ -801,6 +848,9 @@ namespace Barotrauma
|
||||
case nameof(Character.PropulsionSpeedMultiplier):
|
||||
{ if (parentObject is Character character) { character.PropulsionSpeedMultiplier = value; return true; } }
|
||||
break;
|
||||
case nameof(Item.Scale):
|
||||
{ if (parentObject is Item item) { item.Scale = value; return true; } }
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -213,6 +213,16 @@ namespace Barotrauma
|
||||
return splitValue;
|
||||
}
|
||||
|
||||
public static Identifier[] GetAttributeIdentifierArray(this XElement element, Identifier[] defaultValue, params string[] matchingAttributeName)
|
||||
{
|
||||
if (element == null) { return defaultValue; }
|
||||
foreach (string name in matchingAttributeName)
|
||||
{
|
||||
var value = element.GetAttributeIdentifierArray(name, defaultValue);
|
||||
if (value != defaultValue) { return value; }
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static Identifier[] GetAttributeIdentifierArray(this XElement element, string name, Identifier[] defaultValue, bool trim = true)
|
||||
{
|
||||
@@ -484,9 +494,18 @@ namespace Barotrauma
|
||||
{
|
||||
var attr = element?.GetAttribute(name);
|
||||
if (attr == null) { return defaultValue; }
|
||||
return Enum.TryParse(attr.Value, true, out T result) ? result :
|
||||
int.TryParse(attr.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out int resultInt) ? Unsafe.As<int, T>(ref resultInt) :
|
||||
defaultValue;
|
||||
|
||||
if (Enum.TryParse(attr.Value, true, out T result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else if (int.TryParse(attr.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out int resultInt))
|
||||
{
|
||||
return Unsafe.As<int, T>(ref resultInt);
|
||||
}
|
||||
DebugConsole.ThrowError($"Error in {attr}! \"{attr}\" is not a valid {typeof(T).Name} value");
|
||||
return default;
|
||||
|
||||
}
|
||||
|
||||
public static bool GetAttributeBool(this XElement element, string name, bool defaultValue)
|
||||
@@ -608,10 +627,18 @@ namespace Barotrauma
|
||||
return mouseButton;
|
||||
}
|
||||
else if (int.TryParse(strValue, NumberStyles.Any, CultureInfo.InvariantCulture, out int mouseButtonInt) &&
|
||||
(Enum.GetValues(typeof(MouseButton)) as MouseButton[]).Contains((MouseButton)mouseButtonInt))
|
||||
Enum.GetValues<MouseButton>().Contains((MouseButton)mouseButtonInt))
|
||||
{
|
||||
return (MouseButton)mouseButtonInt;
|
||||
}
|
||||
else if (string.Equals(strValue, "LeftMouse", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return !PlayerInput.MouseButtonsSwapped() ? MouseButton.PrimaryMouse : MouseButton.SecondaryMouse;
|
||||
}
|
||||
else if (string.Equals(strValue, "RightMouse", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return !PlayerInput.MouseButtonsSwapped() ? MouseButton.SecondaryMouse : MouseButton.PrimaryMouse;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
#endif
|
||||
@@ -807,7 +834,15 @@ namespace Barotrauma
|
||||
#endif
|
||||
return Color.White;
|
||||
}
|
||||
|
||||
if (stringColor.StartsWith("faction.", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Identifier factionId = stringColor.Substring(8).ToIdentifier();
|
||||
if (FactionPrefab.Prefabs.TryGet(factionId, out var faction))
|
||||
{
|
||||
return faction.IconColor;
|
||||
}
|
||||
return Color.White;
|
||||
}
|
||||
|
||||
string[] strComponents = stringColor.Split(',');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user