void process_construct(ShipConstruct construct) { var pc = new PackedConstruct(construct, HighLogic.CurrentGame.flagURL); //check if the construct contains launch clamps if (pc.construct.HasLaunchClamp()) { Utils.Message("\"{0}\" has launch clamps. Remove them before storing.", pc.name); pc.UnloadConstruct(); return; } pc.UpdateMetric(); try_store_packed_vessel(pc, false); SetHighlightedContent(pc, Storage.Contains(pc) ? ContentState.Fits : ContentState.DoesntFit); pc.UnloadConstruct(); }
void vessel_selected(string filename, string flagname) { EditorLogic EL = EditorLogic.fetch; if (EL == null) { return; } //load vessel config vessel_selector = null; PackedConstruct pc = new PackedConstruct(filename, flagname); if (pc.construct == null) { Utils.Log("PackedConstruct: unable to load ShipConstruct from {0}. " + "This usually means that some parts are missing " + "or some modules failed to initialize.", filename); ScreenMessager.showMessage(string.Format("Unable to load {0}", filename), 3); return; } //check if the construct contains launch clamps if (Utils.HasLaunchClamp(pc.construct)) { ScreenMessager.showMessage(string.Format("{0} has launch clamps. Remove them before storing.", pc.name), 3); pc.UnloadConstruct(); return; } //check if it's possible to launch such vessel bool cant_launch = false; PreFlightCheck preFlightCheck = new PreFlightCheck(new Callback(() => cant_launch = false), new Callback(() => cant_launch = true)); preFlightCheck.AddTest(new PreFlightTests.ExperimentalPartsAvailable(pc.construct)); preFlightCheck.RunTests(); pc.UnloadConstruct(); //cleanup loaded parts and try to store construct if (cant_launch) { return; } if (try_store_construct(pc)) { change_part_params(pc.metric); } }
void vessel_selected(string filename, string flagname) { EditorLogic EL = EditorLogic.fetch; if(EL == null) return; //load vessel config vessel_selector = null; var pc = new PackedConstruct(filename, flagname); if(pc.construct == null) { Utils.Log("PackedConstruct: unable to load ShipConstruct from {0}. " + "This usually means that some parts are missing " + "or some modules failed to initialize.", filename); ScreenMessager.showMessage("Unable to load {0}", filename); return; } //check if the construct contains launch clamps if(Utils.HasLaunchClamp(pc.construct)) { ScreenMessager.showMessage("\"{0}\" has launch clamps. Remove them before storing.", pc.name); pc.UnloadConstruct(); return; } //check if it's possible to launch such vessel bool cant_launch = false; var preFlightCheck = new PreFlightCheck(new Callback(() => cant_launch = false), new Callback(() => cant_launch = true)); preFlightCheck.AddTest(new PreFlightTests.ExperimentalPartsAvailable(pc.construct)); preFlightCheck.RunTests(); //cleanup loaded parts and try to store construct if(cant_launch) pc.UnloadConstruct(); else StartCoroutine(delayed_try_store_construct(pc)); }
IEnumerator<YieldInstruction> delayed_try_store_construct(PackedConstruct pc) { if(pc.construct == null) yield break; Utils.LockEditor(scLock); for(int i = 0; i < 3; i++) yield return new WaitForEndOfFrame(); pc.UpdateMetric(Storage.ComputeHull); try_store_vessel(pc); pc.UnloadConstruct(); Utils.LockEditor(scLock, false); }