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.active.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.Singleton.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.active.propertyDictionary[data]; if (shaderProperty == null) { return(false); } return(shaderProperty.materialProperty.textureValue != null); case DefineableConditionType.DROPDOWN: ShaderProperty dropdownProperty = ShaderEditor.active.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); }
public bool Test() { 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: ThryEditor.ShaderProperty prop = ThryEditor.currentlyDrawing.propertyDictionary[obj]; if (prop == null) { return(false); } if (comparator == "##") { return(prop.materialProperty.floatValue == 1); } if (comparator == "==") { return("" + prop.materialProperty.floatValue == parts[1]); } if (comparator == "!=") { return("" + prop.materialProperty.floatValue != parts[1]); } 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); } break; case DefineableConditionType.VRC_SDK_VERSION: int c_vrc = Helper.compareVersions(VRCInterface.Get().installed_sdk_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); } 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); }
public bool Test() { Init(); if (_hasConstantValue) { return(_constantValue); } MaterialProperty materialProperty = null; switch (type) { case DefineableConditionType.PROPERTY_BOOL: materialProperty = GetMaterialProperty(); if (materialProperty == null) { return(false); } if (_compareType == CompareType.NONE) { return(materialProperty.floatValue == 1); } if (_compareType == CompareType.EQUAL) { return(materialProperty.floatValue == _floatValue); } if (_compareType == CompareType.NOT_EQUAL) { return(materialProperty.floatValue != _floatValue); } if (_compareType == CompareType.SMALLER) { return(materialProperty.floatValue < _floatValue); } if (_compareType == CompareType.BIGGER) { return(materialProperty.floatValue > _floatValue); } if (_compareType == CompareType.BIGGER_EQ) { return(materialProperty.floatValue >= _floatValue); } if (_compareType == CompareType.SMALLER_EQ) { return(materialProperty.floatValue <= _floatValue); } break; case DefineableConditionType.TEXTURE_SET: materialProperty = GetMaterialProperty(); if (materialProperty == null) { return(false); } return(materialProperty.textureValue != null); case DefineableConditionType.DROPDOWN: materialProperty = GetMaterialProperty(); if (materialProperty == null) { return(false); } if (_compareType == CompareType.NONE) { return(materialProperty.floatValue == 1); } if (_compareType == CompareType.EQUAL) { return("" + materialProperty.floatValue == _value); } if (_compareType == CompareType.NOT_EQUAL) { return("" + materialProperty.floatValue != _value); } break; case DefineableConditionType.PROPERTY_IS_ANIMATED: return(ShaderOptimizer.IsAnimated(_materialInsteadOfEditor, _obj)); case DefineableConditionType.PROPERTY_IS_NOT_ANIMATED: return(!ShaderOptimizer.IsAnimated(_materialInsteadOfEditor, _obj)); 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); }