Example #1
0
        public override void OnStart(StartState state)
        {
            if (state == StartState.Editor) return;
            part.force_activate ();

            // create objects
            visualHelper = new VisualHelper (this.vessel.transform);
            if (gnc == null) {
                flightData = new FlightData ();
                bus = new Bus ();
                gnc = new GNC (flightData, bus, this);
            }
            teleporter = new Teleporter (flightData);

            // register gui handler
            RenderingManager.AddToPostDrawQueue (0, new Callback (drawGUI));
        }
Example #2
0
        public override void OnLoad(ConfigNode node)
        {
            // get config node
            ConfigNode n = node.GetNode ("config");
            if (n == null) {
                return;
            }

            // gnc config
            if (n.HasValue ("gncConfig")) {
                try {
                    string gncConfigString = n.GetValue ("gncConfig");
                    GNCconfig gncConfig = (GNCconfig)KSP.IO.IOUtils.DeserializeFromBinary (Convert.FromBase64String (gncConfigString.Replace ("*", "=").Replace ("|", "/")));
                    // OnStart not been called yet?
                    if(gnc == null) {
                        flightData = new FlightData ();
                        bus = new Bus ();
                        gnc = new GNC (flightData, bus, this);
                    }
                    gnc.restoreConfiguration (gncConfig);
                } catch (Exception e) {
                    print ("ORDA_computer.OnLoad: gnc exception: " + e.ToString());
                }
            }

            // gui config
            if (n.HasValue ("guiConfig")) {
                try {
                    string guiConfigString = n.GetValue ("guiConfig");
                    GUIconfig guiConfig = (GUIconfig)KSP.IO.IOUtils.DeserializeFromBinary (Convert.FromBase64String (guiConfigString.Replace ("*", "=").Replace ("|", "/")));
                    restoreGUIConfiguration (guiConfig);
                } catch (Exception e) {
                    print ("ORDA_computer.OnLoad: gui exception: " + e.ToString());
                }
            }
        }