public void DelNodes(Part p) { Log.Info("Deleting Nodes"); #if true for (int idx = p.attachNodes.Count() - 1; idx >= 0; idx--) { if (p.attachNodes[idx].id.Length >= NODE_PREFIX.Length) { if (p.attachNodes[idx].id.Substring(0, NODE_PREFIX.Length) == NODE_PREFIX) { p.attachNodes.Remove(p.attachNodes[idx]); } } } #else for (int idx = p.children.Count() - 1; idx > 0; idx--) { var part = p.children[idx]; Log.Info("part.partInfo.name: " + part.partInfo.name); if (part.partInfo.name == "integratedSepMotor") { Log.Info("Deleting part"); // p.removeChild(part); // EditorLogic.fetch.ship.Parts.Remove(part); EditorLogic.DeletePart(part); } } #endif }
/// <summary> /// Deletes a part. /// </summary> /// <param name="part">The part to delete.</param> public static void Delete(Part part) { if (part == null) { throw new ArgumentNullException("part"); } if (part.children != null && part.children.Count > 0) { throw new ArgumentException("Specified part has children and may not be deleted.", "part"); } // First, get the parent part and delete the child part. Part parent = part.parent; parent.removeChild(part); // Second, do the creepy stalker way of forcing EditorLogic to change the selected part. EditorLogic.fetch.OnSubassemblyDialogDismiss(part); // Third, ask the editor to destroy the part, which requires the part to have been selected previously. EditorLogic.DeletePart(part); // Finally, poke the staging logic to sort out any changes due to deleting this part. Staging.SortIcons(); }
/// <summary> /// Deletes a part. /// </summary> /// <param name="part">The part to delete.</param> //public static public void Delete(Part part) { if (HighLogic.LoadedSceneIsEditor) { if (part == null) { throw new ArgumentNullException("part"); } if (part.children != null && part.children.Count > 0) { throw new ArgumentException("Specified part has children and may not be deleted.", "part"); } // First, get the parent part and delete the child part. Part parent = part.parent; parent.removeChild(part); // Second, do the creepy stalker way of forcing EditorLogic to change the selected part. EditorLogic.fetch.OnSubassemblyDialogDismiss(part); // Third, ask the editor to destroy the part, which requires the part to have been selected previously. EditorLogic.DeletePart(part); // Finally, poke the staging logic to sort out any changes due to deleting this part. Staging.SortIcons(); } if (HighLogic.LoadedSceneIsFlight) { switch (part.name) { case "strutConnector": badStruts.Remove(part); part.Die(); GameEvents.onVesselWasModified.Fire(part.vessel); break; case "fuelLine": badFuelLines.Remove(part); part.Die(); GameEvents.onVesselWasModified.Fire(part.vessel); break; default: break; } } }
/* * Free and clear the editor */ private void ClearEditor() { if (_config.clearEditor) { EditorLockManager.resetEditorLocks(); EditorPartList.Instance.Refresh(); if (_selectedPartbranch != null) { disablePartHighlight(_selectedPartbranch); EditorLogic.fetch.OnSubassemblyDialogDismiss(EditorLogic.RootPart); Log.dbg("{0} {1} - {2}", _config.clearEditor, _selectedPartbranch, EditorLogic.SelectedPart); EditorLogic.DeletePart(EditorLogic.RootPart); _selectedPartbranch = null; } } }
/* * Free and clear the editor */ private void ClearEditor() { if (_config.clearEditor) { EditorLockManager.resetEditorLocks(); EditorPartList.Instance.Refresh(); if (_selectedPartbranch != null) { disablePartHighlight(_selectedPartbranch); EditorLogic.fetch.OnSubassemblyDialogDismiss(EditorLogic.RootPart); Debug.Log(string.Format("{0}{1} {2} - {3}", Constants.logPrefix, _config.clearEditor, _selectedPartbranch, EditorLogic.SelectedPart)); EditorLogic.DeletePart(EditorLogic.RootPart); _selectedPartbranch = null; } } }
private void clearSymmetricParts(Part aPart) { aPart.symmetryCounterparts.ForEach(p => { if (editorLogic.ship.Contains(p)) { detachPart(p); EditorLogic.DeletePart(p); } else if (p != null) { Destroy(p.gameObject); } }); aPart.symmetryCounterparts = new List <Part>(); foreach (Part child in aPart.GetComponentsInChildren <Part>()) { child.symmetryCounterparts.RemoveAll(scp => scp == null); } }
private void OnPartEvent(ConstructionEventType ct, Part p) { if (!HighLogic.CurrentGame.Parameters.CustomParams <KeoCacheOptions>().allowMultipleOnVessel&& p != null && p == this.part) { if (ct == ConstructionEventType.PartAttached) { // count up all the TravelBugs here int numBugs = 0; for (int i = EditorLogic.fetch.ship.parts.Count - 1; i >= 0; i--) { numBugs += (EditorLogic.fetch.ship.parts[i].Modules.GetModules <KeoTravelBugModule>().Count); } Log.Info("numBugs on vessel: " + numBugs); if (numBugs > 1) { ScreenMessages.PostScreenMessage("Multiple TravelBugs on same vessel not allowed!", 10f, ScreenMessageStyle.UPPER_CENTER); ScreenMessages.PostScreenMessage("Deleting extra TravelBug", 10f, ScreenMessageStyle.UPPER_CENTER); EditorLogic.DeletePart(this.part); } } } }