Skip to content

Commit

Permalink
Fix issue #154 : Copied part for drag cube generation must be renamed…
Browse files Browse the repository at this point in the history
… with the "Drag Rendering Clone" substring in order to have proper cleanup done by the Vessel.OnDestroy() method.
  • Loading branch information
gotmachine committed Sep 13, 2023
1 parent ec6cc91 commit bacedf3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions KSPCommunityFixes/Performance/DragCubeGeneration.cs
Expand Up @@ -230,7 +230,7 @@ public static IEnumerator RenderDragCubesCoroutine(Part part, ConfigNode dragCon
public static IEnumerator RenderDragCubesOnCopy(Part originalPart, DragCubeList dragCubeList, ConfigNode dragConfig)
{
if (originalPart.frozen)
Debug.LogWarning($"[KSPCF/DragCubeGeneration] Generating drag cubes on detached part ({originalPart.partInfo.name}) in the editor isn't supported and might give incorrect results.");
Debug.LogWarning($"[KSPCF/DragCubeGeneration] Generating drag cubes on detached part ({originalPart.partInfo.name}) in the editor isn't supported and will give incorrect results.");

int childCount = originalPart.children.Count;
if (childCount > 0)
Expand Down Expand Up @@ -284,6 +284,8 @@ public static IEnumerator RenderDragCubesOnCopy(Part originalPart, DragCubeList
}

GameObject partObject = part.gameObject;
// fix issue #154 : that substring in the name is actually checked in the Vessel.OnDestroy() method, doing a bunch of cleanup...
partObject.name += " Drag Rendering Clone";
partObject.SetActive(true);

ModuleJettison moduleJettison = null;
Expand Down Expand Up @@ -496,7 +498,7 @@ public static IEnumerator RenderDragCubesOnCopy(Part originalPart, DragCubeList
public static DragCube RenderDragCubeImmediate(Part part, string dragCubeName)
{
if (part.frozen)
Debug.LogWarning($"[KSPCF/DragCubeGeneration] Generating drag cubes on detached part ({part.partInfo.name}) in the editor isn't supported and might give incorrect results.");
Debug.LogWarning($"[KSPCF/DragCubeGeneration] Generating drag cubes on detached part ({part.partInfo.name}) in the editor isn't supported and will give incorrect results.");

DragCube dragCube = new DragCube(dragCubeName);

Expand Down

0 comments on commit bacedf3

Please sign in to comment.