//public void Remove(MKSLtransfer transfer) //{ // Vessel ves = FlightGlobals.Vessels.Find(x => x.id == transfer.VesselFrom.id); // if (ves.packed && !ves.loaded) //inactive vessel // { // foreach (ProtoPartSnapshot p in ves.protoVessel.protoPartSnapshots) // { // foreach (ProtoPartModuleSnapshot pm in p.modules) // { // if (pm.moduleName != "MKSLcentral") continue; // var savestring = new MKSLTranferList(); // savestring.Load(pm.moduleValues.GetNode("saveCurrentTransfersList")); // var currentNode = new ConfigNode(); // savestring.Save(currentNode); // pm.moduleValues.SetNode("saveCurrentTransfersList", currentNode); // var previouseList = pm.moduleValues.GetNode("savePreviousTransfersList"); // var previouse = new MKSLTranferList(); // previouse.Load(previouseList); // previouse.Add(transfer); // var previousNode = new ConfigNode(); // previouse.Save(previousNode); // pm.moduleValues.SetNode("savePreviousTransfersList", previousNode); // } // } // } // else //active vessel // { // foreach (Part p in ves.parts) // { // foreach (PartModule pm in p.Modules) // { // if (pm.moduleName == "MKSLcentral") // { // MKSLcentral MKSLc = p.Modules.OfType<MKSLcentral>().FirstOrDefault(); // MKSLc.saveCurrentTransfersList.RemoveAll(x => x.transferName == transfer.transferName); // MKSLc.savePreviousTransfersList.Add(transfer); // } // } // } // } // KnownTransfers.RemoveAll(x => x.transferName == transfer.transferName); //} public void Remove(MKSLtransfer transfer) { Vessel ves = FlightGlobals.Vessels.Find(x => x.id == transfer.VesselFrom.id); DoToVesselMKSLCentral(ves, (pm, savestring) => { var currentNode = new ConfigNode(); savestring.Save(currentNode); pm.moduleValues.SetNode("saveCurrentTransfersList", currentNode); var previouseList = pm.moduleValues.GetNode("savePreviousTransfersList"); var previouse = new MKSLTranferList(); previouse.Load(previouseList); previouse.Add(transfer); var previousNode = new ConfigNode(); previouse.Save(previousNode); pm.moduleValues.SetNode("savePreviousTransfersList", previousNode); }, MKSLc => { MKSLc.saveCurrentTransfersList.RemoveAll(x => x.transferName == transfer.transferName); MKSLc.savePreviousTransfersList.Add(transfer); }); KnownTransfers.RemoveAll(x => x.transferName == transfer.transferName); }
public void Remove(MKSLtransfer transfer) { Vessel ves = FlightGlobals.Vessels.Find(x => x.id == transfer.VesselFrom.id); if (ves.packed && !ves.loaded) //inactive vessel { foreach (ProtoPartSnapshot p in ves.protoVessel.protoPartSnapshots) { foreach (ProtoPartModuleSnapshot pm in p.modules) { if (pm.moduleName != "MKSLcentral") { continue; } var savestring = new MKSLTranferList(); savestring.Load(pm.moduleValues.GetNode("saveCurrentTransfersList")); var currentNode = new ConfigNode(); savestring.Save(currentNode); pm.moduleValues.SetNode("saveCurrentTransfersList", currentNode); var previouseList = pm.moduleValues.GetNode("savePreviousTransfersList"); var previouse = new MKSLTranferList(); previouse.Load(previouseList); previouse.Add(transfer); var previousNode = new ConfigNode(); previouse.Save(previousNode); pm.moduleValues.SetNode("savePreviousTransfersList", previousNode); } } } else //active vessel { foreach (Part p in ves.parts) { foreach (PartModule pm in p.Modules) { if (pm.moduleName == "MKSLcentral") { MKSLcentral MKSLc = p.Modules.OfType <MKSLcentral>().FirstOrDefault(); MKSLc.saveCurrentTransfersList.RemoveAll(x => x.transferName == transfer.transferName); MKSLc.savePreviousTransfersList.Add(transfer); } } } } KnownTransfers.RemoveAll(x => x.transferName == transfer.transferName); }