/// <summary>
 /// Here when a ship loads in the editor.
 /// </summary>
 /// <param name="ship"></param>
 /// <param name="loadType"></param>
 private void OnEditorLoad(ShipConstruct ship, CraftBrowserDialog.LoadType loadType)
 {
     // Order of operations:
     // 1. This method (OnEditorLoad) gets called.
     // 2. PartModules' OnStart method gets called (e.g. for ModuleRoboticSlave)
     Logging.Log("Loaded vessel in editor: " + ship.shipName);
     ModuleRoboticSlave.RefreshFromRoot(ship.parts[0]);
 }
        /// <summary>
        /// Here when the editor starts up. We need this because if it starts with a ship
        /// already loaded (e.g. upon "revert to VAB"), then we don't get an OnEditorLoad
        /// notification, but we *do* still need to do the necessary initialization.
        /// </summary>
        private void OnEditorStarted()
        {
            ShipConstruct ship = EditorLogic.fetch.ship;

            if ((ship == null) || (ship.parts.Count == 0))
            {
                return;
            }

            Logging.Log("Entered editor with ship: " + ship.shipName);
            ModuleRoboticSlave.RefreshFromRoot(ship.parts[0]);
        }
Exemple #3
0
        /// <summary>
        /// This is called in a variety of circumstances: vessel is launched, or created by undocking,
        /// decoupling, planting a flag, or EVA; also triggered by new asteroid creation and rescue
        /// Kerbal contracts.
        /// </summary>
        /// <param name="vessel"></param>
        private void OnVesselCreate(Vessel vessel)
        {
            // There are a lot of cases we don't care about, and only a couple of cases where we
            // do.  We care about the case of launching a new vessel, and we also care about
            // when one vessel turns into two vessels due to undocking, decoupling, etc.
            // All the other cases we don't care about.
            //
            // Fortunately, it's easy to eliminate the don't-care-about cases, because those will
            // spawn a vessel that has zero parts in it (since they're not loaded), so we can
            // ignore those.
            if (vessel.parts.Count == 0)
            {
                return;
            }

            Logging.Log("OnVesselCreate (" + vessel.parts.Count + " parts): " + vessel.vesselName);

            // Order of operations when launching a ship appears to be:
            // 1. OnVesselCreate gets called
            // 2. The PartModules' OnStart gets called (e.g. for ModuleRoboticSlave)
            // 3. OnVesselRollout gets called
            ModuleRoboticSlave.RefreshFromRoot(vessel.parts[0]);
        }
Exemple #4
0
 /// <summary>
 /// Here when a vessel in flight is loaded.
 /// </summary>
 /// <param name="data"></param>
 private void OnVesselLoaded(Vessel vessel)
 {
     Logging.Log("Loaded vessel (" + vessel.parts.Count + " parts): " + vessel.vesselName);
     ModuleRoboticSlave.RefreshFromRoot(vessel.parts[0]);
 }