PropertyConditional fixes:

- Fixed Equals/NotEquals not working at all because they checked for float values when the property is not a float and vice versa.
- Bool comparisons work now.
- Removed unnecessary property.GetValue calls, no need to get the value twice in the same method.
This commit is contained in:
Joonas Rikkonen
2018-04-23 15:19:40 +03:00
parent 6e666939a0
commit eff5976461

View File

@@ -206,22 +206,30 @@ namespace Barotrauma
switch (Operator)
{
case OperatorType.Equals:
if (floatValue == null)
if (type == typeof(bool))
{
return property.GetValue().Equals(floatValue);
return ((bool)propertyValue) == (Value.ToLowerInvariant() == "true");
}
else if (floatValue == null)
{
return propertyValue.ToString().Equals(Value);
}
else
{
return property.GetValue().Equals(Value);
return propertyValue.Equals(floatValue);
}
case OperatorType.NotEquals:
if (floatValue == null)
if (type == typeof(bool))
{
return !property.GetValue().Equals(floatValue);
return ((bool)propertyValue) != (Value.ToLowerInvariant() == "true");
}
else if (floatValue == null)
{
return !propertyValue.ToString().Equals(Value);
}
else
{
return !property.GetValue().Equals(Value);
return !propertyValue.Equals(floatValue);
}
case OperatorType.GreaterThan:
if (floatValue == null)