Beispiel #1
0
 void try_pack_unfit_construct(PackedConstruct pc)
 {
     if (try_pack_construct(pc))
     {
         RemoveUnfit(pc);
         OnVesselStored(pc);
     }
 }
Beispiel #2
0
 public bool RemoveUnfit(PackedConstruct pc)
 {
     if (unfit_constructs.Remove(pc))
     {
         OnVesselUnfittedRemoved(pc);
         return(true);
     }
     return(false);
 }
Beispiel #3
0
 protected PackedConstruct(PackedConstruct pc)
 {
     flag = pc.flag;
     vessel_node = pc.vessel_node;
     metric = pc.metric;
     name = pc.name;
     if(pc.construct != null)
         LoadConstruct();
     id = Guid.NewGuid();
 }
Beispiel #4
0
 protected PackedConstruct(PackedConstruct pc)
 {
     flag        = pc.flag;
     vessel_node = pc.vessel_node;
     metric      = pc.metric;
     name        = pc.name;
     resources   = new VesselResources(vessel_node);
     if (pc.construct != null)
     {
         LoadConstruct();
     }
     id = Guid.NewGuid();
 }
Beispiel #5
0
 bool try_store_construct(PackedConstruct pc)
 {
     GetLaunchTransform();
     if (!pc.metric.FitsAligned(launchTransform, part.partTransform, hangar_metric))
     {
         ScreenMessager.showMessage(string.Format("{0} does not fit into this hangar", pc.name), 3);
         return(false);
     }
     if (!packed_constructs.Add(pc))
     {
         ScreenMessager.showMessage(string.Format("There's no room in the hangar for {0}", pc.name), 3);
         return(false);
     }
     return(true);
 }
        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();
        }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
 void try_repack_construct(PackedConstruct pc)
 {
     if(!VesselFits(pc) ||
        !packed_constructs.TryAdd(pc))
         unfit_constructs.Add(pc);
 }
Beispiel #9
0
 public void RemoveUnfit(PackedConstruct pc)
 {
     unfit_constructs.Remove(pc);
 }
 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);
 }
Beispiel #12
0
 void remove_construct(PackedConstruct pc)
 {
     change_part_params(pc.metric, -1f);
     packed_constructs.Remove(pc.id);
 }
Beispiel #13
0
 bool try_store_construct(PackedConstruct pc)
 {
     GetLaunchTransform();
     if(!pc.metric.FitsAligned(launchTransform, part.partTransform, hangar_metric))
     {
         ScreenMessager.showMessage(string.Format("{0} does not fit into this hangar", pc.name), 3);
         return false;
     }
     if(!packed_constructs.Add(pc))
     {
         ScreenMessager.showMessage(string.Format("There's no room in the hangar for {0}", pc.name), 3);
         return false;
     }
     return true;
 }
Beispiel #14
0
 void remove_construct(PackedConstruct pc)
 {
     change_part_params(pc.metric, -1f);
     packed_constructs.Remove(pc.id);
 }
Beispiel #15
0
 public void AddUnfit(PackedConstruct pc)
 {
     unfit_constructs.Add(pc);
     OnVesselUnfittedAdded(pc);
 }