Beispiel #1
0
        void enableDecoupler(IntegratedDecoupler id, ModuleToggleCrossfeed crossfeedToggleModule)
        {
            KSPActionParam kap = null;

            base.enabled = true;
            if (id.decouplerModule != null)
            {
                id.decouplerModule.SetStaging(true);
                id.decouplerModule.Events["ToggleStaging"].guiActiveEditor        = true; // Only seen when AdvancedTweakables is enabled
                id.decouplerModule.Fields["ejectionForcePercent"].guiActiveEditor = true;
                id.decouplerModule.enabled = true;
                //id.decouplerModule.stagingEnabled = true;
                if (integratedDecoupler == DecouplerType.Enabled)
                {
                    id.decouplerModule.SetStaging(true);
                }
                else
                {
                    id.decouplerModule.SetStaging(false);
                }
                if (crossfeedToggleModule != null)
                {
                    crossfeedToggleModule.DisableAction(kap);
                }

                // if (decouplerModule.part != null)
                SetToggleName(id.pmEvents);
                //id.pmEvents["ToggleIntegratedDecoupler"].guiName = "Integrated Decoupler";
                id.decouplerModule.Events["ToggleStaging"].guiActiveEditor = true;
                id.decouplerModule.Events["ToggleStaging"].guiActiveEditor = false;
                id.part.UpdateStageability(true, true);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Scan the provided part and all its children recursively, looking for any of them that have
        /// a IntegratedDecoupler.  Add any found modules to the list.
        /// </summary>
        /// <param name="root"></param>
        /// <param name="toInitialize"></param>
        private static void CollectToInitializerList(Part root, List <IntegratedDecoupler> toInitialize)
        {
            if (root == null)
            {
                return;
            }

            for (int i = 0; i < root.symmetryCounterparts.Count; ++i)
            {
                Part counterpart = root.symmetryCounterparts[i];
                if (!ReferenceEquals(root, counterpart))
                {
                    IntegratedDecoupler symIntegratedDecoupler = counterpart.FindModuleImplementing <IntegratedDecoupler>();
                    if (!toInitialize.Contains(symIntegratedDecoupler))
                    {
                        toInitialize.Add(symIntegratedDecoupler);
                    }
#if false
                    if (root.children == null)
                    {
                        return;
                    }
                    for (int i1 = 0; i1 < root.children.Count; ++i1)
                    {
                        CollectToInitializerList(root.children[i1], toInitialize);
                    }
#endif
                }
            }
        }
Beispiel #3
0
        void SetAllStatus(DecouplerType decouplerType, bool inEditorModified = false, bool doSymmetry = true)
        {
            for (int i = 0; i < partsInSymmetry.Count; i++)
            {
                IntegratedDecoupler symIntegratedDecoupler = partsInSymmetry[i];
                SetStatus(decouplerType, symIntegratedDecoupler);
            }


            Log.Info("SetStatus 1");
            //if (!inEditorModified)
            GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
            Log.Info("SetStatus 1");
        }
Beispiel #4
0
        /// <summary>
        /// Set the decoupler status
        /// </summary>
        /// <param name="status"></param>
        /// <param name="symIntegratedDecoupler"></param>
        void SetStatus(DecouplerType status, IntegratedDecoupler symIntegratedDecoupler)
        {
            Part counterpart = symIntegratedDecoupler.part;

            ModuleToggleCrossfeed symCrossfeedToggleModule = counterpart.FindModuleImplementing <ModuleToggleCrossfeed>();

            symIntegratedDecoupler.integratedDecoupler = status;
            if (integratedDecoupler != DecouplerType.none)
            {
                enableDecoupler(symIntegratedDecoupler, symCrossfeedToggleModule);
            }
            else
            {
                disableDecoupler(symIntegratedDecoupler, symCrossfeedToggleModule);
            }

            SetEvents(status, symIntegratedDecoupler.decouplerModule, symCrossfeedToggleModule);
        }
Beispiel #5
0
        void disableDecoupler(IntegratedDecoupler id, ModuleToggleCrossfeed crossfeedToggleModule)
        {
            KSPActionParam kap = null;

            if (id.decouplerModule != null)
            {
                id.decouplerModule.SetStaging(false);
                id.decouplerModule.Events["ToggleStaging"].guiActiveEditor        = false; // Only seen when AdvancedTweakables is enabled
                id.decouplerModule.Fields["ejectionForcePercent"].guiActiveEditor = false;
                id.decouplerModule.enabled = false;
                //id.decouplerModule.stagingEnabled = false;
                id.SetStaging(false);

                if (part != null && part.Modules != null)
                {
                    foreach (PartModule m in part.Modules)
                    {
                        if (!ReferenceEquals(m, id.decouplerModule))
                        {
                            m.SetStaging(false);
                            m.Events["ToggleStaging"].guiActiveEditor = false;
                        }
                    }
                }

                if (crossfeedToggleModule != null)
                {
                    crossfeedToggleModule.EnableAction(kap);
                }

                //if (decouplerModule.part != null  && decouplerModule.part.Events != null)
                //id.pmEvents["ToggleIntegratedDecoupler"].guiName = "No decoupler";
                SetToggleName(id.pmEvents);
                id.decouplerModule.Events["ToggleStaging"].guiActiveEditor = false;
                id.part.UpdateStageability(true, true);
            }
        }