public void vesselRecoverEvent(ProtoVessel v, bool unknownAsOfNow) { KCTDebug.Log("VesselRecoverEvent"); 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 (KCT_GameStates.recoveredVessel != null && v.vesselName == KCT_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(KCT_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 KCT_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(KCT_GameStates.recoveredVessel.ExtractedPartNodes); //reset the BP KCT_GameStates.recoveredVessel.buildPoints = KCT_Utilities.GetBuildTime(KCT_GameStates.recoveredVessel.ExtractedPartNodes); } if (KCT_GameStates.recoveredVessel.type == KCT_BuildListVessel.ListType.VAB) { KCT_GameStates.ActiveKSC.VABWarehouse.Add(KCT_GameStates.recoveredVessel); } else { KCT_GameStates.ActiveKSC.SPHWarehouse.Add(KCT_GameStates.recoveredVessel); } KCT_GameStates.ActiveKSC.Recon_Rollout.Add(new KCT_Recon_Rollout(KCT_GameStates.recoveredVessel, KCT_Recon_Rollout.RolloutReconType.Recovery, KCT_GameStates.recoveredVessel.id.ToString())); KCT_GameStates.recoveredVessel = null; } } }
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; } } }