public CLSSpace(CLSVessel v) { this.parts = new List <ICLSPart>(); this.crew = new List <ICLSKerbal>(); this.name = ""; this.vessel = v; }
private void OnEditorShipModified(ShipConstruct vesselConstruct) { if (vesselConstruct.Parts.Count == _editorPartCount) { return; } //Debug.Log("Calling RebuildCLSVessel as the part count has changed in the editor"); if (null != _vessel) { _vessel.Clear(); _vessel = null; } if (null != EditorLogic.RootPart) { _vessel = new CLSVessel(); _vessel.Populate(EditorLogic.RootPart); // TODO recoupler support } _editorPartCount = vesselConstruct.Parts.Count; // First unhighlight the space that was selected. if (-1 != WindowSelectedSpace && WindowSelectedSpace < _vessel.Spaces.Count) { _vessel.Spaces[WindowSelectedSpace].Highlight(true); } }
public CLSSpace(CLSVessel v) { this.parts = new List<ICLSPart>(); this.crew = new List<ICLSKerbal>(); this.name = ""; this.vessel = v; }
private void RebuildCLSVessel() { if (null != _clsVessel) { _clsVessel.Clear(); _clsVessel = null; } if (vessel.rootPart == null) { return; } try { // Build new vessel information _clsVessel = new CLSVessel(); _clsVessel.Populate(vessel.rootPart); // TODO recoupler support } catch (Exception ex) { Debug.Log($"CLS rebuild Vessel Error: { ex}"); } }
private void UpdateShipConstruct() { if (null != _vessel) { _vessel.Clear(); _vessel = null; } if (EditorLogic.RootPart == null) { return; } try { // Build new vessel information _vessel = new CLSVessel(); _vessel.Populate(EditorLogic.RootPart); // Recoupler support for (int i = requestedConnections.Count - 1; i >= 0; i--) { ConnectPair connectPair = requestedConnections[i]; if (connectPair.part1.vessel != connectPair.part2.vessel) { requestedConnections.Remove(connectPair); } _vessel.MergeSpaces(connectPair.part1, connectPair.part2); } } catch (Exception ex) { Log.error(ex, "rebuild Vessel Error"); } }
public CLSSpace(CLSVessel v) { parts = new List<ICLSPart>(); crew = new List<ICLSKerbal>(); name = ""; vessel = v; }
public CLSSpace(CLSVessel v) { parts = new List <ICLSPart>(); crew = new List <ICLSKerbal>(); name = ""; vessel = v; }
// A function to throw away all the parts references, and so break the circular reference. This should be called before throwing a CLSSpace away. internal void Clear() { foreach (CLSPart p in this.parts) { p.Clear(); } this.parts.Clear(); this.vessel = null; }
private void UpdateActiveVessel() { _vessel = FlightGlobals.ActiveVessel.GetComponent <CLSVesselModule>().CLSVessel; if (!WindowVisable || WindowSelectedSpace <= -1) { return; } _vessel.Highlight(false); _vessel.Spaces[CLSAddon.WindowSelectedSpace].Highlight(true); }
// Git Issue #85. sometimes spaces are not updating on a vessel. Deleting a pod does not clear the current vessel. private void OnEditorPodPicked(Part part) { _vessel.Clear(); _vessel = null; if (null != EditorLogic.RootPart) { _vessel = new CLSVessel(); _vessel.Populate(EditorLogic.RootPart); } _editorPartCount = 1; }
// A function to throw away all the parts references, and so break the circular reference. This should be called before throwing a CLSSpace away. internal void Clear() { IEnumerator <ICLSPart> eParts = parts.GetEnumerator(); while (eParts.MoveNext()) { if (eParts.Current == null) { continue; } ((CLSPart)eParts.Current).Clear(); } parts.Clear(); vessel = null; }
public override void OnUnloadVessel() { if (null != _clsVessel) { _clsVessel.Clear(); _clsVessel = null; } // Recoupler support for (int i = CLSAddon.Instance.requestedConnections.Count - 1; i >= 0; i--) { CLSAddon.ConnectPair connectPair = CLSAddon.Instance.requestedConnections[i]; if (connectPair.part1.vessel == this.vessel) { CLSAddon.Instance.requestedConnections.Remove(connectPair); } } }
private void RebuildCLSVessel() { dirty = false; if (null != _clsVessel) { _clsVessel.Clear(); _clsVessel = null; } if (vessel.rootPart == null) { return; } try { // Build new vessel information _clsVessel = new CLSVessel(); _clsVessel.Populate(vessel.rootPart); // Recoupler support for (int i = CLSAddon.Instance.requestedConnections.Count - 1; i >= 0; i--) { CLSAddon.ConnectPair connectPair = CLSAddon.Instance.requestedConnections[i]; if (connectPair.part1.vessel != connectPair.part2.vessel) { CLSAddon.Instance.requestedConnections.Remove(connectPair); } _clsVessel.MergeSpaces(connectPair.part1, connectPair.part2); } } catch (Exception ex) { Debug.Log($"CLS rebuild Vessel Error: { ex}"); } }
private void RebuildCLSVessel() { if (HighLogic.LoadedSceneIsFlight) { RebuildCLSVessel(FlightGlobals.ActiveVessel); } else if (HighLogic.LoadedSceneIsEditor) { if (null == EditorLogic.startPod) { // There is no root part in the editor - this ought to mean that there are no parts. Juest clear out everything if (null != this.vessel) { vessel.Clear(); } this.vessel = null; this.selectedSpace = -1; } else { RebuildCLSVessel(EditorLogic.startPod); } } }
// A function to throw away all the parts references, and so break the circular reference. This should be called before throwing a CLSSpace away. internal void Clear() { foreach (CLSPart p in this.parts) { p.Clear(); } this.parts.Clear(); this.vessel = null; }
private void RebuildCLSVessel(Part newRootPart) { try { //Debug.Log("RebuildCLSVessel"); // Before we rebuild the vessel, we need to take some steps to tidy up the highlighting. // We will make a list of all the parts that are currently highlighted. We will also unhighlight parts that are highlighted. // Once the rebuild is complete we will then highlight any parts that are still in the list we created. uint flightID = 0; List<CLSPart> listHighlightedParts = new List<CLSPart>(); if (null != this.vessel) { try { foreach (CLSSpace space in vessel.Spaces) { foreach (CLSPart p in space.Parts) { Part part = (Part)p; if (flightID != part.flightID) { flightID = part.flightID; //Debug.Log("Part : "+ part.flightID + " found." ) ; } if (p.highlighted) { listHighlightedParts.Add(p); p.Highlight(false); } } } } catch (Exception ex) { Debug.Log("CLS highlighted parts gathering Error: " + ex.ToString()); } //Debug.Log("Old selected vessel had "+ listHighlightedParts.Count + " parts in it."); vessel.Clear(); } // Tidy up the old vessel information this.vessel = null; // Build new vessel information this.vessel = new CLSVessel(); this.vessel.Populate(newRootPart); } catch (Exception ex) { Debug.Log("CLS rebuild Vessel Error: " + ex.ToString()); } }
private void RebuildCLSVessel() { if (HighLogic.LoadedSceneIsFlight) { RebuildCLSVessel(FlightGlobals.ActiveVessel); } else if (HighLogic.LoadedSceneIsEditor) { if (null == EditorLogic.RootPart) { // There is no root part in the editor - this ought to mean that there are no parts. Juest clear out everything if (null != this.vessel) { vessel.Clear(); } this.vessel = null; } else { RebuildCLSVessel(EditorLogic.RootPart); } } }
// A function to throw away all the parts references, and so break the circular reference. This should be called before throwing a CLSSpace away. internal void Clear() { IEnumerator<ICLSPart> eParts = parts.GetEnumerator(); while (eParts.MoveNext()) { if (eParts.Current == null) continue; ((CLSPart)eParts.Current).Clear(); } parts.Clear(); vessel = null; }
private void RebuildCLSVessel(Part newRootPart) { //Debug.Log("RebuildCLSVessel"); // Before we rebuild the vessel, we need to take some steps to tidy up the highlighting and our idea of which space is the selected space. We will make a list of all the parts that are currently in the selected space. We will also unhighlight parts that are highlighted. Once the rebuild is complete we will work out which space will be the selected space based on the first part in our list that we find in oneof the new spaces. We can then highlight that new space. List <uint> listSelectedParts = new List <uint>(); if (-1 != selectedSpace) { foreach (CLSPart p in vessel.Spaces[selectedSpace].Parts) { Part part = (Part)p; listSelectedParts.Add(part.flightID); //Debug.Log("Part : "+ part.flightID + " currently in use." ) ; } vessel.Spaces[selectedSpace].Highlight(false); } //Debug.Log("Old selected space had "+listSelectedParts.Count + " parts in it."); // Tidy up the old vessel information if (null != this.vessel) { vessel.Clear(); } this.vessel = null; // Build new vessel information this.vessel = new CLSVessel(); this.vessel.Populate(newRootPart); // Now work out which space should be highlighted. this.selectedSpace = -1; foreach (CLSPart clsPart in this.vessel.Parts) { Part p = clsPart; //Debug.Log("New vessel contains part : " + p.flightID); if (listSelectedParts.Contains(p.flightID)) { //Debug.Log("Part " + p.partInfo.title + " was in the old selected space and is in the CLSVessel"); if (clsPart.Space != null) { // We have found the new space for a part that was in the old selected space. this.selectedSpace = this.vessel.Spaces.IndexOf(clsPart.Space); //Debug.Log("... it is also part of a space. We will use that space to be our new selected space. index:" + this.selectedSpace); break; } else { //Debug.Log("it is no longer part of a space :("); } } } if (this.selectedSpace != -1) { this.vessel.Spaces[this.selectedSpace].Highlight(true); } else { //Debug.Log("No space is selected after the rebuild."); } // Sanity check the selected space. If the CLSvessel has been rebuilt and there are no Spaces, or it references an out of range space then set it to -1 if (vessel.Spaces.Count == 0 || vessel.Spaces.Count <= this.selectedSpace) { this.selectedSpace = -1; } }
// Git Issue #85. sometimes spaces are not updating on a vessel. Deleting a pod does not clear the current vessel. private void OnEditorPodDeleted() { _vessel.Clear(); _vessel = null; _editorPartCount = 0; }