From eff5976461c8463e9b98e91f7c173896555fc685 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 23 Apr 2018 15:19:40 +0300 Subject: [PATCH] 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. --- .../StatusEffects/PropertyConditional.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/StatusEffects/PropertyConditional.cs b/Barotrauma/BarotraumaShared/Source/StatusEffects/PropertyConditional.cs index 04f7da66d..9942bcccd 100644 --- a/Barotrauma/BarotraumaShared/Source/StatusEffects/PropertyConditional.cs +++ b/Barotrauma/BarotraumaShared/Source/StatusEffects/PropertyConditional.cs @@ -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)