コード例 #1
0
ファイル: HangarStorage.cs プロジェクト: AxleGreaser/hangar
 void try_pack_unfit_construct(PackedConstruct pc)
 {
     if (try_pack_construct(pc))
     {
         RemoveUnfit(pc);
         OnVesselStored(pc);
     }
 }
コード例 #2
0
ファイル: HangarStorage.cs プロジェクト: AxleGreaser/hangar
 public bool RemoveUnfit(PackedConstruct pc)
 {
     if (unfit_constructs.Remove(pc))
     {
         OnVesselUnfittedRemoved(pc);
         return(true);
     }
     return(false);
 }
コード例 #3
0
ファイル: VesselWrappers.cs プロジェクト: pjslauta/hangar
 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();
 }
コード例 #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();
 }
コード例 #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);
 }
コード例 #6
0
        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();
        }
コード例 #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);
            }
        }
コード例 #8
0
ファイル: HangarStorage.cs プロジェクト: pjslauta/hangar
 void try_repack_construct(PackedConstruct pc)
 {
     if(!VesselFits(pc) ||
        !packed_constructs.TryAdd(pc))
         unfit_constructs.Add(pc);
 }
コード例 #9
0
ファイル: HangarStorage.cs プロジェクト: pjslauta/hangar
 public void RemoveUnfit(PackedConstruct pc)
 {
     unfit_constructs.Remove(pc);
 }
コード例 #10
0
 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));
 }
コード例 #11
0
 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);
 }
コード例 #12
0
 void remove_construct(PackedConstruct pc)
 {
     change_part_params(pc.metric, -1f);
     packed_constructs.Remove(pc.id);
 }
コード例 #13
0
ファイル: Hangar.cs プロジェクト: kevin-ye/hangar
 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;
 }
コード例 #14
0
ファイル: Hangar.cs プロジェクト: kevin-ye/hangar
 void remove_construct(PackedConstruct pc)
 {
     change_part_params(pc.metric, -1f);
     packed_constructs.Remove(pc.id);
 }
コード例 #15
0
ファイル: HangarStorage.cs プロジェクト: AxleGreaser/hangar
 public void AddUnfit(PackedConstruct pc)
 {
     unfit_constructs.Add(pc);
     OnVesselUnfittedAdded(pc);
 }