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
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
@ -37,23 +37,23 @@
|
|||||||
<Reference Include="Shabby, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
<Reference Include="Shabby, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
<HintPath>dlls/Shabby.dll</HintPath>
|
<HintPath>dlls/Shabby.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System"/>
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core"/>
|
||||||
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
<HintPath>dlls/UnityEngine.dll</HintPath>
|
<HintPath>dlls/UnityEngine.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="MaterialModifiers\ColorMaterialProperty.cs" />
|
<Compile Include="MaterialModifiers\ColorMaterialProperty.cs"/>
|
||||||
<Compile Include="MaterialModifiers\FloatMaterialProperty.cs" />
|
<Compile Include="MaterialModifiers\FloatMaterialProperty.cs"/>
|
||||||
<Compile Include="MaterialModifiers\MaterialProperty.cs" />
|
<Compile Include="MaterialModifiers\MaterialProperty.cs"/>
|
||||||
<Compile Include="MaterialModifiers\MaterialPropertyCollection.cs" />
|
<Compile Include="MaterialModifiers\MaterialPropertyCollection.cs"/>
|
||||||
<Compile Include="MaterialModifiers\TextureMaterialProperty.cs" />
|
<Compile Include="MaterialModifiers\TextureMaterialProperty.cs"/>
|
||||||
<Compile Include="ModuleConformalDecal.cs" />
|
<Compile Include="ModuleConformalDecal.cs"/>
|
||||||
<Compile Include="Logging.cs" />
|
<Compile Include="Logging.cs"/>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>sh -e -c "cp -v '$(TargetPath)' '$(SolutionDir)/Releases/ConformalDecals/Gamedata'"</PostBuildEvent>
|
<PostBuildEvent>sh -e -c "cp -v '$(TargetPath)' '$(SolutionDir)/Releases/ConformalDecals/Gamedata'"</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -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