mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Cleanup and check if material should inherit base normals
This commit is contained in:
parent
a90d24c141
commit
a1745f6e3a
@ -56,10 +56,10 @@ namespace ConformalDecals.MaterialModifiers {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (valueString == null)
|
if (valueString == null)
|
||||||
throw new FormatException($"Missing {typeof(T)} value {valueName} in property '{PropertyName}'");
|
throw new FormatException($"Missing {typeof(T)} value for {valueName} in property '{PropertyName}'");
|
||||||
|
|
||||||
if (valueString == string.Empty)
|
if (valueString == string.Empty)
|
||||||
throw new FormatException($"Empty {typeof(T)} value {valueName} in property '{PropertyName}'");
|
throw new FormatException($"Empty {typeof(T)} value for {valueName} in property '{PropertyName}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tryParse(valueString, out var value)) {
|
if (tryParse(valueString, out var value)) {
|
||||||
@ -71,7 +71,7 @@ namespace ConformalDecals.MaterialModifiers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
throw new FormatException($"Improperly formatted {typeof(T)} value {valueName} in property '{PropertyName}'");
|
throw new FormatException($"Improperly formatted {typeof(T)} value for {valueName} in property '{PropertyName}' : '{valueString}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,15 @@ namespace ConformalDecals.MaterialModifiers {
|
|||||||
public Shader ShaderRef { get; }
|
public Shader ShaderRef { get; }
|
||||||
public TextureMaterialProperty MainTextureMaterial { get; }
|
public TextureMaterialProperty MainTextureMaterial { get; }
|
||||||
|
|
||||||
|
public bool UseBaseNormal { get; }
|
||||||
|
|
||||||
private List<MaterialProperty> _materialModifiers;
|
private List<MaterialProperty> _materialModifiers;
|
||||||
private List<TextureMaterialProperty> _texturePropertyMaterialModifiers;
|
private List<TextureMaterialProperty> _texturePropertyMaterialModifiers;
|
||||||
|
|
||||||
public MaterialPropertyCollection(ConfigNode node) {
|
public MaterialPropertyCollection(ConfigNode node) {
|
||||||
|
_materialModifiers = new List<MaterialProperty>();
|
||||||
|
_texturePropertyMaterialModifiers = new List<TextureMaterialProperty>();
|
||||||
|
|
||||||
var shaderString = node.GetValue("shader");
|
var shaderString = node.GetValue("shader");
|
||||||
|
|
||||||
if (shaderString == null)
|
if (shaderString == null)
|
||||||
@ -19,14 +24,26 @@ namespace ConformalDecals.MaterialModifiers {
|
|||||||
if (shaderString == string.Empty)
|
if (shaderString == string.Empty)
|
||||||
throw new FormatException("Empty shader name in material");
|
throw new FormatException("Empty shader name in material");
|
||||||
|
|
||||||
_materialModifiers = new List<MaterialProperty>();
|
|
||||||
_texturePropertyMaterialModifiers = new List<TextureMaterialProperty>();
|
|
||||||
|
|
||||||
//TODO: USE SHABBY PROVIDED METHOD HERE INSTEAD
|
//TODO: USE SHABBY PROVIDED METHOD HERE INSTEAD
|
||||||
ShaderRef = Shader.Find(shaderString);
|
ShaderRef = Shader.Find(shaderString);
|
||||||
|
|
||||||
if (ShaderRef == null) throw new FormatException($"Shader not found: {shaderString}");
|
if (ShaderRef == null) throw new FormatException($"Shader not found: {shaderString}");
|
||||||
|
|
||||||
|
var useBaseNormalString = node.GetValue("useBaseNormal");
|
||||||
|
|
||||||
|
if (useBaseNormalString != null) {
|
||||||
|
if (bool.TryParse(useBaseNormalString, out var useBaseNormalRef)) {
|
||||||
|
UseBaseNormal = useBaseNormalRef;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new FormatException($"Improperly formatted bool value for 'useBaseNormal' : {useBaseNormalString}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UseBaseNormal = false;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (ConfigNode propertyNode in node.nodes) {
|
foreach (ConfigNode propertyNode in node.nodes) {
|
||||||
try {
|
try {
|
||||||
MaterialProperty property;
|
MaterialProperty property;
|
||||||
|
Loading…
Reference in New Issue
Block a user