Ejemplo n.º 1
0
        /// <summary>
        /// manipulate save lists
        /// </summary>
        /// <param name="transferlist"></param>
        //converts a save string into a list of MKSLtransfers
        public void loadTransferList(List<MKSLtransfer> transferlist,string savestring, bool longsave)
        {
            transferlist.Clear();

            if (savestring == "") { return; }
            string[] deliveries = savestring.Split('@');

            if (longsave)
            {
                for (int i = deliveries.Length - 1; i >= 0; i--)
                {
                    string[] geninfo = deliveries[i].Split('>');
                    if (null != geninfo[3]) { deliveries[i] = geninfo[3]; }
                }
            }

            for (int i = deliveries.Length - 1; i >= 0; i--)
            {
                MKSLtransfer trans = new MKSLtransfer();
                trans.loadstring(deliveries[i]);
                transferlist.Add(trans);
            }
        }
Ejemplo n.º 2
0
        //removes an entry from the current transfers
        public void removeCurrentTranfer(MKSLtransfer transRemove)
        {
            //remove from current transfers save string
            string[] deliveries = saveCurrentTransfers.Split('@');
            string newSaveCurrentTransfers = "";
            foreach (String delivery in deliveries)
            {
                string[] geninfo = delivery.Split('>');

                MKSLtransfer transfer = new MKSLtransfer();
                transfer.loadstring(geninfo[3]);
                string geninfo3 = geninfo[3];
                //if return is true then add the returned
                if (transfer.transferName != transRemove.transferName)
                {
                    if (newSaveCurrentTransfers == "")
                    {
                        newSaveCurrentTransfers = delivery;

                    }
                    else
                    {
                        newSaveCurrentTransfers = saveCurrentTransfers + "@" + delivery;
                    }
                }

            }

            //add to previous transfers save string
            if (savePreviousTransfers == "")
            {
                savePreviousTransfers = transRemove.savestring();
            }
            else
            {
                savePreviousTransfers = savePreviousTransfers + "@" + transRemove.savestring();
            }

            saveCurrentTransfers = newSaveCurrentTransfers;

            loadTransferList(currentTransfers, saveCurrentTransfers, true);
            loadTransferList(previousTransfers, savePreviousTransfers, false);
        }
Ejemplo n.º 3
0
        private bool attemptDelivery(ref string delivery)
        {
            MKSLtransfer transfer = new MKSLtransfer();

            transfer.loadstring(delivery);

            //check if orbit changed of destination if destination is orbital
            if(transfer.orbit)
            {
                if (!checkStaticOrbit(FlightGlobals.ActiveVessel, transfer.SMA, transfer.ECC, transfer.INC))
                {
                    transfer.delivered = false;
                    delivery = transfer.savestring();
                    return true;
                }
            }

            //check if location changed of destination if destination is surface
            if (transfer.orbit)
            {
                if (!checkStaticLocation(FlightGlobals.ActiveVessel, transfer.LON, transfer.LAT))
                {
                    transfer.delivered = false;
                    delivery = transfer.savestring();
                    return true;
                }
            }

            makeDelivery(transfer);

            //delivery = transfer.longsavestring();
            //return false;

            delivery = transfer.savestring();
            return (true);
        }