|
|
@ -27,6 +27,7 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// anyone with a better name for this can update it |
|
|
|
// anyone with a better name for this can update it |
|
|
|
public enum AnyOrAllConditions |
|
|
|
public enum AnyOrAllConditions |
|
|
|
{ |
|
|
|
{ |
|
|
@ -43,6 +44,26 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] protected List<conditionExpression> conditions = new List<conditionExpression>(); |
|
|
|
[SerializeField] protected List<conditionExpression> conditions = new List<conditionExpression>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Called when the script is loaded or a value is changed in the |
|
|
|
|
|
|
|
/// inspector (Called in the editor only). |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
public override void OnValidate() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
base.OnValidate(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (conditions == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
conditions = new List<conditionExpression>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (conditions.Count == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
conditions.Add(new conditionExpression()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override bool EvaluateCondition() |
|
|
|
protected override bool EvaluateCondition() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (conditions == null || conditions.Count == 0) |
|
|
|
if (conditions == null || conditions.Count == 0) |
|
|
@ -61,7 +82,6 @@ namespace Fungus |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
condition.AnyVar.Compare(condition.CompareOperator, ref curResult); |
|
|
|
condition.AnyVar.Compare(condition.CompareOperator, ref curResult); |
|
|
|
Debug.Log("res : " + curResult.ToString()); |
|
|
|
|
|
|
|
resultAll &= curResult; |
|
|
|
resultAll &= curResult; |
|
|
|
resultAny |= curResult; |
|
|
|
resultAny |= curResult; |
|
|
|
} |
|
|
|
} |
|
|
@ -73,13 +93,15 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
protected override bool HasNeededProperties() |
|
|
|
protected override bool HasNeededProperties() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( conditions == null || conditions.Count == 0){ |
|
|
|
if (conditions == null || conditions.Count == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (conditionExpression condition in conditions) |
|
|
|
foreach (conditionExpression condition in conditions) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(condition.AnyVar == null || condition.AnyVar.variable == null){ |
|
|
|
if (condition.AnyVar == null || condition.AnyVar.variable == null) |
|
|
|
|
|
|
|
{ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -105,10 +127,12 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
string summary = ""; |
|
|
|
string summary = ""; |
|
|
|
string connector = ""; |
|
|
|
string connector = ""; |
|
|
|
if(anyOrAllConditions == AnyOrAllConditions.AnyOneTrue){ |
|
|
|
if (anyOrAllConditions == AnyOrAllConditions.AnyOneTrue) |
|
|
|
|
|
|
|
{ |
|
|
|
connector = " Or "; |
|
|
|
connector = " Or "; |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
connector = " And "; |
|
|
|
connector = " And "; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -118,15 +142,11 @@ namespace Fungus |
|
|
|
summary += VariableUtil.GetCompareOperatorDescription(conditions[i].CompareOperator) + " "; |
|
|
|
summary += VariableUtil.GetCompareOperatorDescription(conditions[i].CompareOperator) + " "; |
|
|
|
summary += conditions[i].AnyVar.GetDataDescription(); |
|
|
|
summary += conditions[i].AnyVar.GetDataDescription(); |
|
|
|
|
|
|
|
|
|
|
|
if(i<conditions.Count-1){ |
|
|
|
if (i < conditions.Count - 1) |
|
|
|
|
|
|
|
{ |
|
|
|
summary += connector; |
|
|
|
summary += connector; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return summary; |
|
|
|
return summary; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -139,8 +159,10 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
#region backwards compat |
|
|
|
#region backwards compat |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HideInInspector] |
|
|
|
[SerializeField] protected CompareOperator compareOperator; |
|
|
|
[SerializeField] protected CompareOperator compareOperator; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HideInInspector] |
|
|
|
[SerializeField] protected AnyVariableAndDataPair anyVar; |
|
|
|
[SerializeField] protected AnyVariableAndDataPair anyVar; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -202,13 +224,9 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
void ISerializationCallbackReceiver.OnAfterDeserialize() |
|
|
|
void ISerializationCallbackReceiver.OnAfterDeserialize() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (variable != null) |
|
|
|
if (variable != null) |
|
|
|
{ |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
anyVar.variable = variable; |
|
|
|
anyVar.variable = variable; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (variable.GetType() == typeof(BooleanVariable) && !booleanData.Equals(new BooleanData())) |
|
|
|
if (variable.GetType() == typeof(BooleanVariable) && !booleanData.Equals(new BooleanData())) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -296,22 +314,22 @@ namespace Fungus |
|
|
|
variable = null; |
|
|
|
variable = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// just checking for anyVar != null fails here. is any var beig reintilaized somewhere? |
|
|
|
// just checking for anyVar != null fails here. is any var being reintilaized somewhere? |
|
|
|
|
|
|
|
|
|
|
|
if(anyVar != null && anyVar.variable != null){ |
|
|
|
if (anyVar != null && anyVar.variable != null) |
|
|
|
|
|
|
|
{ |
|
|
|
conditionExpression c = new conditionExpression(compareOperator,anyVar); |
|
|
|
conditionExpression c = new conditionExpression(compareOperator,anyVar); |
|
|
|
if(!conditions.Contains(c)){ |
|
|
|
if (!conditions.Contains(c)) |
|
|
|
|
|
|
|
{ |
|
|
|
conditions.Add(c); |
|
|
|
conditions.Add(c); |
|
|
|
} |
|
|
|
} |
|
|
|
//added to list |
|
|
|
} |
|
|
|
anyVar = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//this is not nullabale? |
|
|
|
if (anyVar != null && anyVar.variable == null) |
|
|
|
//compareOperator = null; |
|
|
|
{ |
|
|
|
|
|
|
|
anyVar = null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|