Ejemplo n.º 1
0
        public bool Test()
        {
            switch (type)
            {
            case DefineableConditionType.NONE:
                return(true);

            case DefineableConditionType.TRUE:
                return(true);

            case DefineableConditionType.FALSE:
                return(false);
            }
            string comparator = GetComparetor();

            string[] parts = Regex.Split(data, comparator);
            string   obj   = parts[0];
            string   value = parts[parts.Length - 1];

            switch (type)
            {
            case DefineableConditionType.PROPERTY_BOOL:
                ShaderProperty prop = ShaderEditor.currentlyDrawing.propertyDictionary[obj];
                if (prop == null)
                {
                    return(false);
                }
                if (comparator == "##")
                {
                    return(prop.materialProperty.floatValue == 1);
                }
                float f = Parser.ParseFloat(parts[1]);
                if (comparator == "==")
                {
                    return(prop.materialProperty.floatValue == f);
                }
                if (comparator == "!=")
                {
                    return(prop.materialProperty.floatValue != f);
                }
                if (comparator == "<")
                {
                    return(prop.materialProperty.floatValue < f);
                }
                if (comparator == ">")
                {
                    return(prop.materialProperty.floatValue > f);
                }
                if (comparator == ">=")
                {
                    return(prop.materialProperty.floatValue >= f);
                }
                if (comparator == "<=")
                {
                    return(prop.materialProperty.floatValue <= f);
                }
                break;

            case DefineableConditionType.EDITOR_VERSION:
                int c_ev = Helper.compareVersions(Config.Get().verion, value);
                if (comparator == "==")
                {
                    return(c_ev == 0);
                }
                if (comparator == "!=")
                {
                    return(c_ev != 0);
                }
                if (comparator == "<")
                {
                    return(c_ev == 1);
                }
                if (comparator == ">")
                {
                    return(c_ev == -1);
                }
                if (comparator == ">=")
                {
                    return(c_ev == -1 || c_ev == 0);
                }
                if (comparator == "<=")
                {
                    return(c_ev == 1 || c_ev == 0);
                }
                break;

            case DefineableConditionType.VRC_SDK_VERSION:
                if (VRCInterface.Get().sdk_information.type == VRCInterface.VRC_SDK_Type.NONE)
                {
                    return(false);
                }
                int c_vrc = Helper.compareVersions(VRCInterface.Get().sdk_information.installed_version, value);
                if (comparator == "==")
                {
                    return(c_vrc == 0);
                }
                if (comparator == "!=")
                {
                    return(c_vrc != 0);
                }
                if (comparator == "<")
                {
                    return(c_vrc == 1);
                }
                if (comparator == ">")
                {
                    return(c_vrc == -1);
                }
                if (comparator == ">=")
                {
                    return(c_vrc == -1 || c_vrc == 0);
                }
                if (comparator == "<=")
                {
                    return(c_vrc == 1 || c_vrc == 0);
                }
                break;

            case DefineableConditionType.TEXTURE_SET:
                ShaderProperty shaderProperty = ShaderEditor.currentlyDrawing.propertyDictionary[data];
                if (shaderProperty == null)
                {
                    return(false);
                }
                return(shaderProperty.materialProperty.textureValue != null);

            case DefineableConditionType.DROPDOWN:
                ShaderProperty dropdownProperty = ShaderEditor.currentlyDrawing.propertyDictionary[obj];
                if (dropdownProperty == null)
                {
                    return(false);
                }
                if (comparator == "##")
                {
                    return(dropdownProperty.materialProperty.floatValue == 1);
                }
                if (comparator == "==")
                {
                    return("" + dropdownProperty.materialProperty.floatValue == parts[1]);
                }
                if (comparator == "!=")
                {
                    return("" + dropdownProperty.materialProperty.floatValue != parts[1]);
                }
                break;

            case DefineableConditionType.AND:
                if (condition1 != null && condition2 != null)
                {
                    return(condition1.Test() && condition2.Test());
                }
                break;

            case DefineableConditionType.OR:
                if (condition1 != null && condition2 != null)
                {
                    return(condition1.Test() || condition2.Test());
                }
                break;
            }

            return(true);
        }