diff --git a/GameData/ConformalDecals/Plugins/ConformalDecals.dll b/GameData/ConformalDecals/Plugins/ConformalDecals.dll index 2336c5f..f0aadc2 100644 Binary files a/GameData/ConformalDecals/Plugins/ConformalDecals.dll and b/GameData/ConformalDecals/Plugins/ConformalDecals.dll differ diff --git a/Source/ConformalDecals/IProjectionTarget.cs b/Source/ConformalDecals/IProjectionTarget.cs index 31f6f58..cc09042 100644 --- a/Source/ConformalDecals/IProjectionTarget.cs +++ b/Source/ConformalDecals/IProjectionTarget.cs @@ -2,7 +2,7 @@ namespace ConformalDecals { public interface IProjectionTarget { - void Project(Matrix4x4 orthoMatrix, Transform projector, Bounds projectionBounds); + bool Project(Matrix4x4 orthoMatrix, Transform projector, Bounds projectionBounds); void Render(Material decalMaterial, MaterialPropertyBlock partMPB, Camera camera); ConfigNode Save(); } diff --git a/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs b/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs index 5ffafbd..eb44179 100644 --- a/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs +++ b/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs @@ -208,13 +208,14 @@ namespace ConformalDecals.MaterialProperties { public T ParseProperty(ConfigNode node) where T : MaterialProperty { string propertyName = ""; if (!ParseUtil.ParseStringIndirect(ref propertyName, node, "name")) throw new ArgumentException("node has no name"); + Logging.Log($"Parsing material property {propertyName}"); if (ParseUtil.ParseBool(node, "remove", true)) RemoveProperty(propertyName); var newProperty = AddOrGetProperty(propertyName); newProperty.ParseNode(node); - if (newProperty is MaterialTextureProperty textureProperty && textureProperty.isMain) { + if (newProperty is MaterialTextureProperty {isMain: true} textureProperty) { _mainTexture = textureProperty; } diff --git a/Source/ConformalDecals/ModuleConformalDecal.cs b/Source/ConformalDecals/ModuleConformalDecal.cs index 0e9ccdc..3838b40 100644 --- a/Source/ConformalDecals/ModuleConformalDecal.cs +++ b/Source/ConformalDecals/ModuleConformalDecal.cs @@ -152,6 +152,18 @@ namespace ConformalDecals { } } + /// + public override void OnSave(ConfigNode node) { + // SAVE TARGETS + if (HighLogic.LoadedSceneIsFlight) { + foreach (var partTarget in _targets.Values) { + if (partTarget.enabled) node.AddNode(partTarget.Save()); + } + } + + base.OnSave(node); + } + /// public override void OnIconCreate() { UpdateTextures(); @@ -431,6 +443,20 @@ namespace ConformalDecals { else if (tileIndex >= 0) { materialProperties.UpdateTile(tileIndex, tileSize); } + + // PARSE TARGETS + if (HighLogic.LoadedSceneIsFlight) { + foreach (var partTargetNode in node.GetNodes(ProjectionPartTarget.NodeName)) { + try { + var partTarget = new ProjectionPartTarget(partTargetNode, part.vessel, useBaseNormal); + _targets.Add(partTarget.part, partTarget); + } + catch (Exception e) { + this.LogWarning($"Encountered error while parsing part node: {e}"); + } + + } + } } /// Setup decal by calling update functions relevent for the current situation