mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Saving tests
This commit is contained in:
parent
e069f85e56
commit
9295899787
Binary file not shown.
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace ConformalDecals {
|
namespace ConformalDecals {
|
||||||
public interface IProjectionTarget {
|
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);
|
void Render(Material decalMaterial, MaterialPropertyBlock partMPB, Camera camera);
|
||||||
ConfigNode Save();
|
ConfigNode Save();
|
||||||
}
|
}
|
||||||
|
@ -208,13 +208,14 @@ namespace ConformalDecals.MaterialProperties {
|
|||||||
public T ParseProperty<T>(ConfigNode node) where T : MaterialProperty {
|
public T ParseProperty<T>(ConfigNode node) where T : MaterialProperty {
|
||||||
string propertyName = "";
|
string propertyName = "";
|
||||||
if (!ParseUtil.ParseStringIndirect(ref propertyName, node, "name")) throw new ArgumentException("node has no name");
|
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);
|
if (ParseUtil.ParseBool(node, "remove", true)) RemoveProperty(propertyName);
|
||||||
|
|
||||||
var newProperty = AddOrGetProperty<T>(propertyName);
|
var newProperty = AddOrGetProperty<T>(propertyName);
|
||||||
newProperty.ParseNode(node);
|
newProperty.ParseNode(node);
|
||||||
|
|
||||||
if (newProperty is MaterialTextureProperty textureProperty && textureProperty.isMain) {
|
if (newProperty is MaterialTextureProperty {isMain: true} textureProperty) {
|
||||||
_mainTexture = textureProperty;
|
_mainTexture = textureProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +152,18 @@ namespace ConformalDecals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnIconCreate() {
|
public override void OnIconCreate() {
|
||||||
UpdateTextures();
|
UpdateTextures();
|
||||||
@ -431,6 +443,20 @@ namespace ConformalDecals {
|
|||||||
else if (tileIndex >= 0) {
|
else if (tileIndex >= 0) {
|
||||||
materialProperties.UpdateTile(tileIndex, tileSize);
|
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
|
/// Setup decal by calling update functions relevent for the current situation
|
||||||
|
Loading…
Reference in New Issue
Block a user