Rename to reflect behavior instead of copying Blowfish

This commit is contained in:
Andrew Cassidy 2020-05-27 15:31:56 -07:00
parent 1ed0cfacb7
commit a90d24c141
6 changed files with 31 additions and 32 deletions

View File

@ -44,11 +44,11 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="MaterialModifiers\ColorPropertyMaterialModifier.cs" /> <Compile Include="MaterialModifiers\ColorMaterialProperty.cs" />
<Compile Include="MaterialModifiers\FloatPropertyMaterialModifier.cs" /> <Compile Include="MaterialModifiers\FloatMaterialProperty.cs" />
<Compile Include="MaterialModifiers\MaterialModifier.cs" /> <Compile Include="MaterialModifiers\MaterialProperty.cs" />
<Compile Include="MaterialModifiers\MaterialModifierCollection.cs" /> <Compile Include="MaterialModifiers\MaterialPropertyCollection.cs" />
<Compile Include="MaterialModifiers\TexturePropertyMaterialModifier.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" />

View File

@ -2,10 +2,10 @@ using System;
using UnityEngine; using UnityEngine;
namespace ConformalDecals.MaterialModifiers { namespace ConformalDecals.MaterialModifiers {
public class ColorPropertyMaterialModifier : MaterialModifier { public class ColorMaterialProperty : MaterialProperty {
private readonly Color _color; private readonly Color _color;
public ColorPropertyMaterialModifier(ConfigNode node) : base(node) { public ColorMaterialProperty(ConfigNode node) : base(node) {
_color = ParsePropertyColor(node, "color", false); _color = ParsePropertyColor(node, "color", false);
} }

View File

@ -2,10 +2,10 @@ using System;
using UnityEngine; using UnityEngine;
namespace ConformalDecals.MaterialModifiers { namespace ConformalDecals.MaterialModifiers {
public class FloatPropertyMaterialModifier : MaterialModifier { public class FloatMaterialProperty : MaterialProperty {
private readonly float _value; private readonly float _value;
public FloatPropertyMaterialModifier(ConfigNode node) : base(node) { public FloatMaterialProperty(ConfigNode node) : base(node) {
_value = ParsePropertyFloat(node, "value", false); _value = ParsePropertyFloat(node, "value", false);
} }

View File

@ -2,13 +2,13 @@ using System;
using UnityEngine; using UnityEngine;
namespace ConformalDecals.MaterialModifiers { namespace ConformalDecals.MaterialModifiers {
public abstract class MaterialModifier { public abstract class MaterialProperty {
public string PropertyName { get; } public string PropertyName { get; }
protected readonly int _propertyID; protected readonly int _propertyID;
protected MaterialModifier(ConfigNode node) { protected MaterialProperty(ConfigNode node) {
PropertyName = node.GetValue("name"); PropertyName = node.GetValue("name");
if (PropertyName == null) if (PropertyName == null)

View File

@ -3,24 +3,24 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace ConformalDecals.MaterialModifiers { namespace ConformalDecals.MaterialModifiers {
public class MaterialModifierCollection { public class MaterialPropertyCollection {
public Shader ShaderRef { get; } public Shader ShaderRef { get; }
public TexturePropertyMaterialModifier MainTexture { get; } public TextureMaterialProperty MainTextureMaterial { get; }
private List<MaterialModifier> _materialModifiers; private List<MaterialProperty> _materialModifiers;
private List<TexturePropertyMaterialModifier> _texturePropertyMaterialModifiers; private List<TextureMaterialProperty> _texturePropertyMaterialModifiers;
public MaterialModifierCollection(ConfigNode node) { public MaterialPropertyCollection(ConfigNode node) {
var shaderString = node.GetValue("shader"); var shaderString = node.GetValue("shader");
if (shaderString == null) if (shaderString == null)
throw new FormatException($"Missing shader name in material"); throw new FormatException("Missing shader name in material");
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<MaterialModifier>(); _materialModifiers = new List<MaterialProperty>();
_texturePropertyMaterialModifiers = new List<TexturePropertyMaterialModifier>(); _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);
@ -29,27 +29,27 @@ namespace ConformalDecals.MaterialModifiers {
foreach (ConfigNode propertyNode in node.nodes) { foreach (ConfigNode propertyNode in node.nodes) {
try { try {
MaterialModifier modifier; MaterialProperty property;
switch (propertyNode.name) { switch (propertyNode.name) {
case "FLOAT": case "FLOAT":
modifier = new FloatPropertyMaterialModifier(propertyNode); property = new FloatMaterialProperty(propertyNode);
break; break;
case "COLOR": case "COLOR":
modifier = new ColorPropertyMaterialModifier(propertyNode); property = new ColorMaterialProperty(propertyNode);
break; break;
case "TEXTURE": case "TEXTURE":
modifier = new TexturePropertyMaterialModifier(propertyNode); property = new TextureMaterialProperty(propertyNode);
var textureModifier = modifier as TexturePropertyMaterialModifier; var textureModifier = (TextureMaterialProperty) property;
if (textureModifier.IsMain) { if (textureModifier.IsMain) {
if (MainTexture != null) { if (MainTextureMaterial == null) {
MainTexture = textureModifier; MainTextureMaterial = textureModifier;
} }
else { else {
Debug.LogWarning( Debug.LogWarning(
$"Material texture property {textureModifier.TextureUrl} is marked as main, but material already has a main texture! \n" + $"Material texture property {textureModifier.TextureUrl} is marked as main, but material already has a main texture! \n" +
$"Defaulting to {MainTexture.TextureUrl}"); $"Defaulting to {MainTextureMaterial.TextureUrl}");
} }
} }
@ -58,10 +58,9 @@ namespace ConformalDecals.MaterialModifiers {
default: default:
throw new FormatException($"Invalid property type '{propertyNode.name}' in material"); throw new FormatException($"Invalid property type '{propertyNode.name}' in material");
break;
} }
_materialModifiers.Add(modifier); _materialModifiers.Add(property);
} }
catch (Exception e) { catch (Exception e) {

View File

@ -2,7 +2,7 @@ using System;
using UnityEngine; using UnityEngine;
namespace ConformalDecals.MaterialModifiers { namespace ConformalDecals.MaterialModifiers {
public class TexturePropertyMaterialModifier : MaterialModifier { public class TextureMaterialProperty : MaterialProperty {
public string TextureUrl { get; } public string TextureUrl { get; }
public Texture2D TextureRef { get; } public Texture2D TextureRef { get; }
@ -15,7 +15,7 @@ namespace ConformalDecals.MaterialModifiers {
public Rect TileRect { get; } public Rect TileRect { get; }
public TexturePropertyMaterialModifier(ConfigNode node) : base(node) { public TextureMaterialProperty(ConfigNode node) : base(node) {
TextureUrl = node.GetValue("textureURL"); TextureUrl = node.GetValue("textureURL");
var textureInfo = GameDatabase.Instance.GetTextureInfo(TextureUrl); var textureInfo = GameDatabase.Instance.GetTextureInfo(TextureUrl);