Exemple #1
0
    public override void OnStart(PartModule.StartState state)
    {
        debug.debugMode = debugMode;

        FARActive = AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name.Equals("FerramAerospaceResearch", StringComparison.InvariantCultureIgnoreCase));
        // This line breaks the plugin :(
        if (FARActive)
        {
            foreach (BaseField f in Fields)
            {
                f.guiActive = false;
            }
            foreach (BaseEvent e in Events)
            {
                e.active = false;
                e.guiActive = false;
                e.guiActiveEditor = false;
            }
            foreach (BaseAction a in Actions)
            {
                a.active = false;
            }
            this.enabled = false;
            return;
        }

        //debug.debugMessage("FSwing OnStart: " + part.name);

        #region fligth mode

        if (HighLogic.LoadedSceneIsFlight)
        {

            findTransforms(true);

            // Check if a stock wing module is present, if not, manipulate FSliftSurface stuff instead.
            if (affectStockWingModule)
            {
                //Debug.Log("FSwing: getting stock wing module");
                stockWingModule = part as ControlSurface;
                if (stockWingModule != null)
                {
                    //Debug.Log("FSwing: success");
                }
                else
                {
                    debug.debugMessage("FSwing: did not Find stock wing module");
                    affectStockWingModule = false;
                }
            }

            // get the main lift surface for the leading edge to manipulate
            if (affectStockWingModule)
            {
                useCtrlSrf = false;
            }
            else
            {
                FSliftSurface[] surfaces = part.GetComponents<FSliftSurface>();
                foreach (FSliftSurface surface in surfaces)
                {
                    if (surface.liftTransformName == leadingEdgeLiftSurface)
                    {
                        mainLift = surface;
                        mainLiftAreaDefault = surface.wingArea;
                        //Debug.Log("FSwing: Slat assigned main lift to: " + surface.liftTransformName);
                        break;
                    }
                }
                if (mainLift == null) debug.debugMessage("FSwing: leading edge missing main FSliftSurface: " + leadingEdgeLiftSurface);
            }
        }
        #endregion

        #region help popup

        helpPopup = new Firespitter.gui.HelpPopup("Wing setup help", helpTextInternal);

        /*helpSection = new PopupSection();
        PopupElement helpText = new PopupElement(helpTextnternal, true);
        helpSection.AddElement(helpText, 300f);
        if (windowID == 0)
            windowID = FSGUIwindowID.getNextID();
        helpPopup = new FSGUIPopup(part, "FSwing", 0, windowID, windowRect, "Wing setup help");
        helpPopup.sections.Add(helpSection);
        helpPopup.useInEditor = true;
        helpPopup.useInFlight = true;*/

        #endregion

        originalCtrlSurfaceRange = ctrlSurfaceRange;

        if (affectStockWingModule || !showTweakables)
        {
            Fields["pitchResponse"].guiActive = false;
            Fields["pitchResponse"].guiActiveEditor = false;
            Fields["rollResponse"].guiActive = false;
            Fields["rollResponse"].guiActiveEditor = false;
            Fields["yawResponse"].guiActive = false;
            Fields["yawResponse"].guiActiveEditor = false;
            Fields["flapResponse"].guiActive = false;
            Fields["flapResponse"].guiActiveEditor = false;
        }

        ApplyDamage(partHealth);
    }
Exemple #2
0
    public override void OnStart(PartModule.StartState state)
    {
        debug.debugMode = debugMode;

        FARActive = AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name.Equals("FerramAerospaceResearch", StringComparison.InvariantCultureIgnoreCase));
        // This line breaks the plugin :(
        if (FARActive)
        {
            foreach (BaseField f in Fields)
            {
                f.guiActive = false;
            }
            foreach (BaseEvent e in Events)
            {
                e.active          = false;
                e.guiActive       = false;
                e.guiActiveEditor = false;
            }
            foreach (BaseAction a in Actions)
            {
                a.active = false;
            }
            this.enabled = false;
            return;
        }

        //debug.debugMessage("FSwing OnStart: " + part.name);

        #region fligth mode

        if (HighLogic.LoadedSceneIsFlight)
        {
            findTransforms(true);

            // Check if a stock wing module is present, if not, manipulate FSliftSurface stuff instead.
            if (affectStockWingModule)
            {
                //Debug.Log("FSwing: getting stock wing module");
                stockWingModule = part as ControlSurface;
                if (stockWingModule != null)
                {
                    //Debug.Log("FSwing: success");
                }
                else
                {
                    debug.debugMessage("FSwing: did not Find stock wing module");
                    affectStockWingModule = false;
                }
            }

            // get the main lift surface for the leading edge to manipulate
            if (affectStockWingModule)
            {
                useCtrlSrf = false;
            }
            else
            {
                FSliftSurface[] surfaces = part.GetComponents <FSliftSurface>();
                foreach (FSliftSurface surface in surfaces)
                {
                    if (surface.liftTransformName == leadingEdgeLiftSurface)
                    {
                        mainLift            = surface;
                        mainLiftAreaDefault = surface.wingArea;
                        //Debug.Log("FSwing: Slat assigned main lift to: " + surface.liftTransformName);
                        break;
                    }
                }
                if (mainLift == null)
                {
                    debug.debugMessage("FSwing: leading edge missing main FSliftSurface: " + leadingEdgeLiftSurface);
                }
            }
        }
        #endregion

        #region help popup

        helpPopup = new Firespitter.gui.HelpPopup("Wing setup help", helpTextInternal);

        /*helpSection = new PopupSection();
         * PopupElement helpText = new PopupElement(helpTextnternal, true);
         * helpSection.AddElement(helpText, 300f);
         * if (windowID == 0)
         *  windowID = FSGUIwindowID.getNextID();
         * helpPopup = new FSGUIPopup(part, "FSwing", 0, windowID, windowRect, "Wing setup help");
         * helpPopup.sections.Add(helpSection);
         * helpPopup.useInEditor = true;
         * helpPopup.useInFlight = true;*/

        #endregion

        originalCtrlSurfaceRange = ctrlSurfaceRange;

        if (affectStockWingModule || !showTweakables)
        {
            Fields["pitchResponse"].guiActive       = false;
            Fields["pitchResponse"].guiActiveEditor = false;
            Fields["rollResponse"].guiActive        = false;
            Fields["rollResponse"].guiActiveEditor  = false;
            Fields["yawResponse"].guiActive         = false;
            Fields["yawResponse"].guiActiveEditor   = false;
            Fields["flapResponse"].guiActive        = false;
            Fields["flapResponse"].guiActiveEditor  = false;
        }

        ApplyDamage(partHealth);
    }