Пример #1
0
        public void VesselRecoverEvent(ProtoVessel v, bool unknownAsOfNow)
        {
            KCTDebug.Log("VesselRecoverEvent");
            if (!PresetManager.Instance.ActivePreset.GeneralSettings.Enabled)
            {
                return;
            }
            if (!KCTGameStates.IsSimulatedFlight && !v.vesselRef.isEVA)
            {
                if (KCTGameStates.RecoveredVessel != null && v.vesselName == KCTGameStates.RecoveredVessel.ShipName)
                {
                    //rebuy the ship if ScrapYard isn't overriding funds
                    if (!ScrapYardWrapper.OverrideFunds)
                    {
                        Utilities.SpendFunds(KCTGameStates.RecoveredVessel.Cost, TransactionReasons.VesselRollout);    //pay for the ship again
                    }

                    //pull all of the parts out of the inventory
                    //This is a bit funky since we grab the part id from our part, grab the inventory part out, then try to reapply that ontop of our part
                    if (ScrapYardWrapper.Available)
                    {
                        foreach (ConfigNode partNode in KCTGameStates.RecoveredVessel.ExtractedPartNodes)
                        {
                            string     id = ScrapYardWrapper.GetPartID(partNode);
                            ConfigNode inventoryVersion = ScrapYardWrapper.FindInventoryPart(id);
                            if (inventoryVersion != null)
                            {
                                //apply it to our copy of the part
                                ConfigNode ourTracker = partNode.GetNodes("MODULE").FirstOrDefault(n => string.Equals(n.GetValue("name"), "ModuleSYPartTracker", StringComparison.Ordinal));
                                if (ourTracker != null)
                                {
                                    ourTracker.SetValue("TimesRecovered", inventoryVersion.GetValue("_timesRecovered"));
                                    ourTracker.SetValue("Inventoried", inventoryVersion.GetValue("_inventoried"));
                                }
                            }
                        }

                        //process the vessel in ScrapYard
                        ScrapYardWrapper.ProcessVessel(KCTGameStates.RecoveredVessel.ExtractedPartNodes);

                        //reset the BP
                        KCTGameStates.RecoveredVessel.BuildPoints       = Utilities.GetBuildTime(KCTGameStates.RecoveredVessel.ExtractedPartNodes);
                        KCTGameStates.RecoveredVessel.IntegrationPoints = MathParser.ParseIntegrationTimeFormula(KCTGameStates.RecoveredVessel);
                    }

                    if (KCTGameStates.RecoveredVessel.Type == BuildListVessel.ListType.VAB)
                    {
                        KCTGameStates.ActiveKSC.VABWarehouse.Add(KCTGameStates.RecoveredVessel);
                    }
                    else
                    {
                        KCTGameStates.ActiveKSC.SPHWarehouse.Add(KCTGameStates.RecoveredVessel);
                    }

                    KCTGameStates.ActiveKSC.Recon_Rollout.Add(new ReconRollout(KCTGameStates.RecoveredVessel, ReconRollout.RolloutReconType.Recovery, KCTGameStates.RecoveredVessel.Id.ToString()));
                    KCTGameStates.RecoveredVessel = null;
                }
            }
        }
Пример #2
0
        private void SYReady()
        {
            if (HighLogic.LoadedSceneIsEditor && KCTGameStates.EditorShipEditingMode && KCTGameStates.EditedVessel != null)
            {
                KCTDebug.Log("Removing SY tracking of this vessel.");
                string id = ScrapYardWrapper.GetPartID(KCTGameStates.EditedVessel.ExtractedPartNodes[0]);
                ScrapYardWrapper.SetProcessedStatus(id, false);

                KCTDebug.Log("Adding parts back to inventory for editing...");
                foreach (ConfigNode partNode in KCTGameStates.EditedVessel.ExtractedPartNodes)
                {
                    if (ScrapYardWrapper.PartIsFromInventory(partNode))
                    {
                        ScrapYardWrapper.AddPartToInventory(partNode, false);
                    }
                }
            }
        }
Пример #3
0
        private void SYReady()
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(SYReady);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (HighLogic.LoadedSceneIsEditor && GameStates.EditorShipEditingMode && GameStates.editedVessel != null)
                {
                    Log.Info("Removing SY tracking of this vessel.");
                    string id = ScrapYardWrapper.GetPartID(GameStates.editedVessel.ExtractedPartNodes[0]);
                    ScrapYardWrapper.SetProcessedStatus(id, false);

                    Log.Info("Adding parts back to inventory for editing...");
                    foreach (ConfigNode partNode in GameStates.editedVessel.ExtractedPartNodes)
                    {
                        if (ScrapYardWrapper.PartIsFromInventory(partNode))
                        {
                            ScrapYardWrapper.AddPartToInventory(partNode, false);
                        }
                    }
                }
            }
        }
Пример #4
0
        public void vesselRecoverEvent(ProtoVessel v, bool unknownAsOfNow)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(vesselRecoverEvent);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled)
                {
                    return;
                }
                if (!v.vesselRef.isEVA)
                {
                    // if (KCT_GameStates.settings.Debug && HighLogic.LoadedScene != GameScenes.TRACKSTATION && (v.wasControllable || v.protoPartSnapshots.Find(p => p.modules.Find(m => m.moduleName.ToLower() == "modulecommand") != null) != null))
                    if (GameStates.recoveredVessel != null && v.vesselName == GameStates.recoveredVessel.shipName)
                    {
                        //KCT_GameStates.recoveredVessel = new KCT_BuildListVessel(v);
                        //rebuy the ship if ScrapYard isn't overriding funds
                        if (!ScrapYardWrapper.OverrideFunds)
                        {
                            KCT_Utilities.SpendFunds(GameStates.recoveredVessel.cost, TransactionReasons.VesselRollout);   //pay for the ship again
                        }

                        //pull all of the parts out of the inventory
                        //This is a bit funky since we grab the part id from our part, grab the inventory part out, then try to reapply that ontop of our part
                        if (ScrapYardWrapper.Available)
                        {
                            foreach (ConfigNode partNode in GameStates.recoveredVessel.ExtractedPartNodes)
                            {
                                string     id = ScrapYardWrapper.GetPartID(partNode);
                                ConfigNode inventoryVersion = ScrapYardWrapper.FindInventoryPart(id);
                                if (inventoryVersion != null)
                                {
                                    //apply it to our copy of the part
                                    ConfigNode ourTracker = partNode.GetNodes("MODULE").FirstOrDefault(n => string.Equals(n.GetValue("name"), "ModuleSYPartTracker", StringComparison.Ordinal));
                                    if (ourTracker != null)
                                    {
                                        ourTracker.SetValue("TimesRecovered", inventoryVersion.GetValue("_timesRecovered"));
                                        ourTracker.SetValue("Inventoried", inventoryVersion.GetValue("_inventoried"));
                                    }
                                }
                            }


                            //process the vessel in ScrapYard
                            ScrapYardWrapper.ProcessVessel(GameStates.recoveredVessel.ExtractedPartNodes);

                            //reset the BP
                            GameStates.recoveredVessel.buildPoints = KCT_Utilities.GetBuildTime(GameStates.recoveredVessel.ExtractedPartNodes);
                        }
                        if (GameStates.recoveredVessel.type == BuildListVessel.ListType.VAB)
                        {
                            GameStates.ActiveKSC.VABWarehouse.Add(GameStates.recoveredVessel);
                        }
                        else
                        {
                            GameStates.ActiveKSC.SPHWarehouse.Add(GameStates.recoveredVessel);
                        }

                        GameStates.ActiveKSC.Recon_Rollout.Add(new Recon_Rollout(GameStates.recoveredVessel, Recon_Rollout.RolloutReconType.Recovery, GameStates.recoveredVessel.id.ToString()));
                        GameStates.recoveredVessel = null;
                    }
                }
            }
        }