Пример #1
0
        public void Update()
        {
            if (Lib.IsFlight())
            {
                Drive drive = DB.Vessel(vessel).drive;

                // if no location was ever specified, set it here
                if (drive.location == 0)
                {
                    drive.location = part.flightID;
                }

                // if this is the location the data is stored
                if (drive.location == part.flightID)
                {
                    // get data size
                    double size = drive.Size();

                    // show DATA UI button, with size info
                    Events["ToggleUI"].guiName = Lib.StatusToggle("Data", size > double.Epsilon ? Lib.HumanReadableDataSize(size) : "empty");
                    Events["ToggleUI"].active  = true;

                    // show TakeData eva action button, if there is something to take
                    Events["TakeData"].active = size > double.Epsilon;

                    // show StoreData eva action button, if active vessel is an eva kerbal and there is something to store from it
                    Vessel v = FlightGlobals.ActiveVessel;
                    Events["StoreData"].active = v != null && v.isEVA && !EVA.IsDead(v) && DB.Vessel(v).drive.Size() > double.Epsilon;

                    // hide TransferLocation button
                    Events["TransferData"].active = false;
                }
                // if this is not the location the data is stored
                else
                {
                    // hide DATA UI button
                    Events["ToggleUI"].active = false;

                    // hide EVA actions
                    Events["TakeData"].active  = false;
                    Events["StoreData"].active = false;

                    // show TransferData button
                    Events["TransferData"].active = true;
                }
            }
        }
Пример #2
0
        // transfer data between two vessels
        public static void Transfer(Vessel src, Vessel dst)
        {
            // get drives
            Drive a = DB.Vessel(src).drive;
            Drive b = DB.Vessel(dst).drive;

            // get size of data being transfered
            double amount = a.Size();

            // if there is data
            if (amount > double.Epsilon)
            {
                // transfer the data
                a.Move(b);

                // inform the user
                Message.Post
                (
                    Lib.BuildString(Lib.HumanReadableDataSize(amount), " of data transfered"),
                    Lib.BuildString("from <b>", src.vesselName, "</b> to <b>", dst.vesselName, "</b>")
                );
            }
        }
Пример #3
0
        // transfer data between two vessels
        public static void Transfer(Vessel src, Vessel dst)
        {
            // get drives
            Drive a = DB.Vessel(src).drive;
            Drive b = DB.Vessel(dst).drive;

            // get size of data being transfered
            double amount = a.Size();

            // if there is data
            if (amount > double.Epsilon)
            {
                // transfer the data
                a.Move(b);

                // inform the user
                Message.Post
                (
                    Lib.BuildString(Lib.HumanReadableDataSize(amount), " ", Localizer.Format("#KERBALISM_Science_ofdatatransfer")),
                    Lib.BuildString(Localizer.Format("#KERBALISM_Generic_FROM"), " <b>", src.vesselName, "</b> ", Localizer.Format("#KERBALISM_Generic_TO"), " <b>", dst.vesselName, "</b>")
                );
            }
        }
Пример #4
0
        public void Update()
        {
            if (drive == null)
            {
                return;
            }

            if (Lib.IsEditor())
            {
                bool update = false;
                if (dataCapacities != null)
                {
                    foreach (var c in dataCapacities)
                    {
                        if (c.Key == dataCapacityUI)
                        {
                            update |= effectiveDataCapacity != c.Value;
                            effectiveDataCapacity = c.Value;
                        }
                    }
                }

                if (sampleCapacities != null)
                {
                    foreach (var c in sampleCapacities)
                    {
                        if (c.Key == sampleCapacityUI)
                        {
                            update |= effectiveSampleCapacity != c.Value;
                            effectiveSampleCapacity = c.Value;
                        }
                    }
                }

                drive.dataCapacity   = effectiveDataCapacity;
                drive.sampleCapacity = effectiveSampleCapacity;

                Fields["sampleCapacityUI"].guiActiveEditor = sampleCapacity > 0;
                Fields["dataCapacityUI"].guiActiveEditor   = dataCapacity > 0;

                if (update)
                {
                    GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
                    UpdateCapacity();
                }
            }

            if (Lib.IsFlight())
            {
                // show DATA UI button, with size info
                Events["ToggleUI"].guiName = Lib.StatusToggle("Data", drive.Empty() ? "empty" : drive.Size());
                Events["ToggleUI"].active  = !IsPrivate();

                // show TakeData eva action button, if there is something to take
                Events["TakeData"].active = !drive.Empty();

                // show StoreData eva action button, if active vessel is an eva kerbal and there is something to store from it
                Vessel v = FlightGlobals.ActiveVessel;
                Events["StoreData"].active = !IsPrivate() && v != null && v.isEVA && !EVA.IsDead(v);

                // hide TransferLocation button
                var transferVisible = !IsPrivate();
                if (transferVisible)
                {
                    transferVisible = Drive.GetDrives(vessel, true).Count > 1;
                }
                Events["TransferData"].active    = transferVisible;
                Events["TransferData"].guiActive = transferVisible;
            }
        }
Пример #5
0
        public void Update()
        {
            UpdateCapacity();

            if (Lib.IsFlight())
            {
                // show DATA UI button, with size info
                Events["ToggleUI"].guiName = Lib.StatusToggle("Data", drive.Empty() ? "empty" : drive.Size());
                Events["ToggleUI"].active  = true;

                // show TakeData eva action button, if there is something to take
                Events["TakeData"].active = !drive.Empty();

                // show StoreData eva action button, if active vessel is an eva kerbal and there is something to store from it
                Vessel v = FlightGlobals.ActiveVessel;
                Events["StoreData"].active = v != null && v.isEVA && !EVA.IsDead(v) && drive.FilesSize() > double.Epsilon;

                // hide TransferLocation button
                Events["TransferData"].active = true;
            }
        }
Пример #6
0
        public void Update()
        {
            if (drive == null)
            {
                return;
            }

            if (Lib.IsFlight())
            {
                // show DATA UI button, with size info
                Events["ToggleUI"].guiName = Lib.StatusToggle("Data", drive.Empty() ? "empty" : drive.Size());
                Events["ToggleUI"].active  = !IsPrivate();

                // show TakeData eva action button, if there is something to take
                Events["TakeData"].active = !drive.Empty();

                // show StoreData eva action button, if active vessel is an eva kerbal and there is something to store from it
                Vessel v = FlightGlobals.ActiveVessel;
                Events["StoreData"].active = !IsPrivate() && v != null && v.isEVA && !EVA.IsDead(v);

                // hide TransferLocation button
                var transferVisible = !IsPrivate();
                if (transferVisible)
                {
                    transferVisible = Drive.GetDrives(vessel, true).Count > 1;
                }
                Events["TransferData"].active    = transferVisible;
                Events["TransferData"].guiActive = transferVisible;
            }
        }