Beispiel #1
0
        //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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        //private void Ondraw()
        //{
        //    if (!(nextchecktime < Planetarium.GetUniversalTime())) return;
        //    KnownTransfers = GetTransfers();
        //    foreach (Vessel ves in FlightGlobals.Vessels)
        //    {
        //        if (FlightGlobals.ActiveVessel.protoVessel.orbitSnapShot.ReferenceBodyIndex !=
        //            ves.protoVessel.orbitSnapShot.ReferenceBodyIndex) continue;
        //        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 completeddeliveries = new MKSLTranferList();
        //                    if (savestring.Count > 0)
        //                    {
        //                        this.Log("delivering from active" + savestring.First().transferName + " with " + savestring.First().transferList.First().resourceName + ":" + savestring.First().transferList.First().amount);
        //                    }
        //                    if (checkDeliveries(savestring, completeddeliveries))
        //                    {
        //                        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.AddRange(completeddeliveries);
        //                        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();

        //                        var savestring = MKSLc.saveCurrentTransfersList;
        //                        if (savestring.Count > 0)
        //                        {
        //                            this.Log("delivering from active" + savestring.First().transferName + " with "+ savestring.First().transferList.First().resourceName+":"+savestring.First().transferList.First().amount);
        //                        }

        //                        var completeddeliveries = new MKSLTranferList();
        //                        if (checkDeliveries(savestring, completeddeliveries))
        //                        {
        //                            MKSLc.savePreviousTransfersList.AddRange(completeddeliveries);
        //                        }

        //                    }
        //                }
        //            }
        //        }
        //    }
        //    nextchecktime = Planetarium.GetUniversalTime() + 60;
        //}

        private void Ondraw()
        {
            if (!(nextchecktime < Planetarium.GetUniversalTime()))
            {
                return;
            }
            KnownTransfers = GetTransfers();
            foreach (Vessel ves in FlightGlobals.Vessels)
            {
                if (FlightGlobals.ActiveVessel.protoVessel.orbitSnapShot.ReferenceBodyIndex !=
                    ves.protoVessel.orbitSnapShot.ReferenceBodyIndex)
                {
                    continue;
                }
                DoToVesselMKSLCentral(ves,
                                      (pm, savestring) =>
                {
                    var completeddeliveries = new MKSLTranferList();
                    if (checkDeliveries(savestring, completeddeliveries))
                    {
                        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.AddRange(completeddeliveries);
                        var previousNode = new ConfigNode();
                        previouse.Save(previousNode);
                        pm.moduleValues.SetNode("savePreviousTransfersList", previousNode);
                    }
                },
                                      MKSLc =>
                {
                    var savestring = MKSLc.saveCurrentTransfersList;

                    var completeddeliveries = new MKSLTranferList();
                    if (checkDeliveries(savestring, completeddeliveries))
                    {
                        MKSLc.savePreviousTransfersList.AddRange(completeddeliveries);
                    }
                });
            }
            nextchecktime = Planetarium.GetUniversalTime() + 60;
        }
Beispiel #4
0
        private void Ondraw()
        {
            if (!(nextchecktime < Planetarium.GetUniversalTime()))
            {
                return;
            }
            KnownTransfers = GetTransfers();
            foreach (Vessel ves in FlightGlobals.Vessels)
            {
                if (FlightGlobals.ActiveVessel.protoVessel.orbitSnapShot.ReferenceBodyIndex !=
                    ves.protoVessel.orbitSnapShot.ReferenceBodyIndex)
                {
                    continue;
                }
                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 completeddeliveries = new MKSLTranferList();
                            if (savestring.Count > 0)
                            {
                                this.Log("delivering from active" + savestring.First().transferName + " with " + savestring.First().transferList.First().resourceName + ":" + savestring.First().transferList.First().amount);
                            }
                            if (checkDeliveries(savestring, completeddeliveries))
                            {
                                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.AddRange(completeddeliveries);
                                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();

                                var savestring = MKSLc.saveCurrentTransfersList;
                                if (savestring.Count > 0)
                                {
                                    this.Log("delivering from active" + savestring.First().transferName + " with " + savestring.First().transferList.First().resourceName + ":" + savestring.First().transferList.First().amount);
                                }

                                var completeddeliveries = new MKSLTranferList();
                                if (checkDeliveries(savestring, completeddeliveries))
                                {
                                    MKSLc.savePreviousTransfersList.AddRange(completeddeliveries);
                                }
                            }
                        }
                    }
                }
            }
            nextchecktime = Planetarium.GetUniversalTime() + 60;
        }