Skip to content

Commit

Permalink
v2.8.10 - Fixing the fix fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbian committed Dec 22, 2019
1 parent 70b13cf commit 44b59d3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
32 changes: 26 additions & 6 deletions ModelMultiShurikenPersistFX.cs
Expand Up @@ -206,6 +206,8 @@ public int CurrentlyActiveParticles
}
}

public string node_backup = string.Empty;

private bool activated = true;

private bool loaded = false;
Expand Down Expand Up @@ -609,7 +611,7 @@ public override void OnInitialize()
// Ship spawned somehow don't call OnLoad...
if (transformName != string.Empty)
{
OnLoad(null);
Restore();
}

List<Transform> transforms = new List<Transform>(hostPart.FindModelTransforms(transformName));
Expand Down Expand Up @@ -745,7 +747,20 @@ private static void DisableCollider(GameObject go)
}
}
}


public void Backup(ConfigNode node)
{
node_backup = SmokeScreenUtil.WriteRootNode(node);
//print("Backup node_backup is\n " + node_backup.Replace(Environment.NewLine, Environment.NewLine + "ModelMultiParticlePersistFX "));
}

public void Restore()
{
//print("Restore node_backup is\n " + node_backup.Replace(Environment.NewLine, Environment.NewLine + "ModelMultiParticlePersistFX "));
ConfigNode node = ConfigNode.Parse(node_backup);
OnLoad(node);
}

private ConfigNode GetEffectConfig()
{
ConfigNode partConfig = PartLoader.getPartInfoByName(hostPart.protoPartSnapshot.partName).partConfig;
Expand All @@ -758,10 +773,9 @@ public override void OnLoad(ConfigNode node)
{
//print("OnLoad");

// Use the actual part cfg instead of what KSP provides us for 2 reasons:
// - this effect config goes beyond the 7 deep serialization restriction and we get a node without the InputCurves
// Use the actual part cfg instead of what KSP provides u
// - the node provided for the root part after a load/scene change is empty
if (HighLogic.LoadedScene != GameScenes.LOADING)
if (HighLogic.LoadedScene != GameScenes.LOADING && !node.HasNode())
{
node = GetEffectConfig();

Expand All @@ -775,6 +789,11 @@ public override void OnLoad(ConfigNode node)
}
}

// Backup the config because this effect config goes beyond the 7 deep serialization restriction and we get a node without the InputCurves
// A cheap hack but fixing this takes way too much compile/reloading...

Backup(node);

//print("OnLoad :\n" + node);

emission = new MultiInputCurve("emission");
Expand Down Expand Up @@ -1153,7 +1172,8 @@ private void windowGUI(int ID)
// Set the node with what was in the .cfg
if (GUILayout.Button("Import"))
{
nodeText = SmokeScreenUtil.WriteRootNode(GetEffectConfig());
//nodeText = SmokeScreenUtil.WriteRootNode(GetEffectConfig());
nodeText = string.Copy(node_backup);
//print("Displaying node \n " + nodeText.Replace("\n", "\n" + "ModelMultiParticlePersistFX "));
}

Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Expand Up @@ -34,5 +34,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.8.9.0")]
[assembly: AssemblyFileVersion("2.8.9.0")]
[assembly: AssemblyVersion("2.8.10.0")]
[assembly: AssemblyFileVersion("2.8.10.0")]

0 comments on commit 44b59d3

Please sign in to comment.