getValueFunction(ComparedValue comparedValue) { switch (comparedValue) { case ComparedValue.CasterHealth: return((c1, c2, f) => c1.Health); case ComparedValue.CasterPercentHealth: return((c1, c2, f) => c1.Health / c1.Stats.maxHP); case ComparedValue.CasterSecondary: return((c1, c2, f) => c1.Secondary); case ComparedValue.CasterPercentSecondary: return((c1, c2, f) => c1.Secondary / c1.Stats.maxSecondary); case ComparedValue.TargetHealth: return((c1, c2, f) => c2.Health); case ComparedValue.TargetPercentHealth: return((c1, c2, f) => c2.Health / c1.Stats.maxHP); case ComparedValue.TargetSecondary: return((c1, c2, f) => c2.Secondary); case ComparedValue.TargetPercentSecondary: return((c1, c2, f) => c2.Secondary / c2.Stats.maxSecondary); default: case ComparedValue.Value: return((c1, c2, f) => f); } }
public void constructFunction(ComparedValue comparedValue, ValueComparison comparison, float value) { var comparisonFunction = getComparison(comparison, value); var valueFunction = getValueFunction(comparedValue); func = (c1, c2, f) => comparisonFunction(valueFunction(c1, c2, f)); }
public override int GetHashCode() { unchecked { var hashCode = TargetPropertyName?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ (ComparedValue?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (int)ValueComparingOperator; return(hashCode); } }
public ValueCondition(ComparedValue comparedValue, ValueComparison comparison, float value) { constructFunction(comparedValue, comparison, value); }
getValueFunction(ComparedValue comparedValue) { switch(comparedValue) { case ComparedValue.CasterHealth: return (c1, c2, f) => c1.Health; case ComparedValue.CasterPercentHealth: return (c1, c2, f) => c1.Health / c1.Stats.maxHP; case ComparedValue.CasterSecondary: return (c1, c2, f) => c1.Secondary; case ComparedValue.CasterPercentSecondary: return (c1, c2, f) => c1.Secondary / c1.Stats.maxSecondary; case ComparedValue.TargetHealth: return (c1, c2, f) => c2.Health; case ComparedValue.TargetPercentHealth: return (c1, c2, f) => c2.Health / c1.Stats.maxHP; case ComparedValue.TargetSecondary: return (c1, c2, f) => c2.Secondary; case ComparedValue.TargetPercentSecondary: return (c1, c2, f) => c2.Secondary / c2.Stats.maxSecondary; default: case ComparedValue.Value: return (c1, c2, f) => f; } }
public override int GetHashCode() { unchecked { return(((TargetPropertyName != null ? TargetPropertyName.GetHashCode() : 0) * 397) ^ (int)ValueComparingOperator ^ ComparedValue.GetHashCode()); } }