Example #1
0
        private static ValData Calculate(Calc.Formula1 numerical, object a, object b)
        {
            switch (a)
            {
            case int num3:
                int num1 = (int)ValData.Cast(b, typeof(int));
                switch (numerical)
                {
                case Calc.Formula1.PlusEqual:
                    return(new ValData((object)(num3 + num1)));

                case Calc.Formula1.MinusEqual:
                    return(new ValData((object)(num3 - num1)));

                case Calc.Formula1.AstaEqual:
                    return(new ValData((object)(num3 * num1)));

                case Calc.Formula1.SlashEqual:
                    return(new ValData((object)(num3 / num1)));
                }
                break;

            case float num3:
                float num2 = (float)ValData.Cast(b, typeof(float));
                switch (numerical)
                {
                case Calc.Formula1.PlusEqual:
                    return(new ValData((object)(float)((double)num3 + (double)num2)));

                case Calc.Formula1.MinusEqual:
                    return(new ValData((object)(float)((double)num3 - (double)num2)));

                case Calc.Formula1.AstaEqual:
                    return(new ValData((object)(float)((double)num3 * (double)num2)));

                case Calc.Formula1.SlashEqual:
                    return(new ValData((object)(float)((double)num3 / (double)num2)));
                }
                break;

            case bool flag2:
                bool flag1 = (bool)ValData.Cast(b, typeof(bool));
                switch (numerical)
                {
                case Calc.Formula1.PlusEqual:
                    return(new ValData((object)((!flag2 ? 0 : 1) + (!flag1 ? 0 : 1) > 0)));

                case Calc.Formula1.MinusEqual:
                    return(new ValData((object)((!flag2 ? 0 : 1) - (!flag1 ? 0 : 1) > 0)));

                case Calc.Formula1.AstaEqual:
                    return(new ValData((object)(flag2 | flag1)));

                case Calc.Formula1.SlashEqual:
                    return(new ValData((object)(flag2 & flag1)));
                }
                break;

            default:
                string str      = a.ToString();
                string oldValue = b.ToString();
                if (numerical == Calc.Formula1.PlusEqual)
                {
                    return(new ValData((object)(str + oldValue)));
                }
                if (numerical == Calc.Formula1.MinusEqual)
                {
                    return(new ValData((object)str.Replace(oldValue, string.Empty)));
                }
                break;
            }
            Debug.LogError((object)(numerical.ToString() + a + b));
            return(new ValData((object)null));
        }
Example #2
0
 public static ValData operator -(ValData a, ValData b)
 {
     return(ValData.Calculate(Calc.Formula1.MinusEqual, a.o, b.o));
 }
Example #3
0
 public static ValData operator /(ValData a, ValData b)
 {
     return(ValData.Calculate(Calc.Formula1.SlashEqual, a.o, b.o));
 }
Example #4
0
 public static bool operator >=(ValData a, ValData b)
 {
     return(ValData.IF(Utils.Comparer.Type.Over, a.o, b.o));
 }