Beispiel #1
0
        public void AcquireOptics()
        {
            int opticsPriority = 0;

            foreach (Part p in FlightGlobals.ActiveVessel.parts)
            {
                if (opticsPriority != 3)
                {
                    CactEyeOptics oM = p.GetComponent <CactEyeOptics>();
                    if (oM != null)
                    {
                        //Large and functional optics get top priority
                        if (!oM.isSmallOptics && oM.isFunctional)
                        {
                            opticsPriority = 3;
                            opticsModule   = oM;
                        }
                        //Small and functional optics get second
                        else if (oM.isSmallOptics && oM.isFunctional && opticsPriority < 2)
                        {
                            opticsPriority = 2;
                            opticsModule   = oM;
                        }
                        //Nonfunctional optics get last priority
                        else if (!oM.isFunctional && opticsPriority < 1)
                        {
                            opticsPriority = 1;
                            opticsModule   = oM;
                        }
                    }
                }
            }
            if (opticsModule != null)
            {
                if (ToolbarManager.ToolbarAvailable)
                {
                    button.Visible = true;
                }

                hasOptics = true;

                if (tex == null)
                {
                    tex = new Texture2D(160, (int)(160 / FlightCamera.fetch.mainCamera.aspect));
                }
            }
            else
            {
                if (ToolbarManager.ToolbarAvailable)
                {
                    button.Visible = false;
                }

                hasOptics = false;
            }
        }
Beispiel #2
0
        public void AcquireOptics()
        {
            int opticsPriority = 0;
            foreach (Part p in FlightGlobals.ActiveVessel.parts)
            {
                if (opticsPriority != 3)
                {
                    CactEyeOptics oM = p.GetComponent<CactEyeOptics>();
                    if (oM != null)
                    {
                        //Large and functional optics get top priority
                        if (!oM.isSmallOptics && oM.isFunctional)
                        {
                            opticsPriority = 3;
                            opticsModule = oM;
                        }
                        //Small and functional optics get second
                        else if (oM.isSmallOptics && oM.isFunctional && opticsPriority < 2)
                        {
                            opticsPriority = 2;
                            opticsModule = oM;
                        }
                        //Nonfunctional optics get last priority
                        else if (!oM.isFunctional && opticsPriority < 1)
                        {
                            opticsPriority = 1;
                            opticsModule = oM;
                        }
                    }
                }
            }
            if (opticsModule != null)
            {
                if (ToolbarManager.ToolbarAvailable)
                    button.Visible = true;

                hasOptics = true;

                if (tex == null)
                {
                    tex = new Texture2D(160, (int)(160 / FlightCamera.fetch.mainCamera.aspect));
                }
            }
            else
            {
                if (ToolbarManager.ToolbarAvailable)
                {
                    button.Visible = false;
                }

                hasOptics = false;
            }
        }
Beispiel #3
0
        private bool checkSetup()
        {
            Part mount = part.parent;

            if (mount == null)
            {
                deactivate();
                status = "Processor not mounted";
                return(false);
            }

            //If there's multiple sets of optics (why?) choose the best suited one.
            Part optics         = null;
            int  opticsPriority = 0;

            foreach (Part p in vessel.parts)
            {
                if (opticsPriority != 3)
                {
                    CactEyeOptics oM = p.GetComponent <CactEyeOptics>();
                    if (oM != null)
                    {
                        //Large and functional optics get top priority
                        if (!oM.isSmallOptics && oM.isFunctional)
                        {
                            opticsPriority = 3;
                            optics         = p;
                            opticsModule   = oM;
                        }
                        //Small and functional optics get second
                        else if (oM.isSmallOptics && oM.isFunctional && opticsPriority < 2)
                        {
                            opticsPriority = 2;
                            optics         = p;
                            opticsModule   = oM;
                        }
                        //Nonfunctional optics get last priority
                        else if (!oM.isFunctional && opticsPriority < 1)
                        {
                            opticsPriority = 1;
                            optics         = p;
                            opticsModule   = oM;
                        }
                    }
                }
            }
            if (optics == null)
            {
                deactivate();
                status = "No optics detected";
                return(false);
            }
            else
            {
                if (opticsPriority == 0 || opticsPriority == 1)
                {
                    deactivate();
                    status = "Aperture closed";
                    return(false);
                }

                if (isActive)
                {
                    //Try to consume power
                    double consumeAmount = (consumeRate * (Planetarium.GetUniversalTime() - storedTime));
                    if (part.RequestResource("ElectricCharge", consumeAmount) < consumeAmount * 0.95) //separated from other if statement because it actually eats up ElectricCharge when it's called
                    {
                        deactivate();
                        status = "Insufficient ElectricCharge";
                        timer  = 0f;
                        ScreenMessages.PostScreenMessage("Processor Shutting Down (Insufficient ElectricCharge)", 6, ScreenMessageStyle.UPPER_CENTER);
                        return(false);
                    }
                    else
                    {
                        isFunctional = true;
                        status       = "Functioning...";
                        return(true);
                    }
                }
                else
                {
                    if (timer > 3f)
                    {
                        status = "Off";
                    }
                    return(true);
                }
            }
        }
Beispiel #4
0
        private bool checkSetup()
        {
            Part mount = part.parent;
            if (mount == null)
            {
                deactivate();
                status = "Processor not mounted";
                return false;
            }

            //If there's multiple sets of optics (why?) choose the best suited one.
            Part optics = null;
            int opticsPriority = 0;
            foreach (Part p in vessel.parts)
            {
                if (opticsPriority != 3)
                {
                    CactEyeOptics oM = p.GetComponent<CactEyeOptics>();
                    if (oM != null)
                    {
                        //Large and functional optics get top priority
                        if (!oM.isSmallOptics && oM.isFunctional)
                        {
                            opticsPriority = 3;
                            optics = p;
                            opticsModule = oM;
                        }
                        //Small and functional optics get second
                        else if (oM.isSmallOptics && oM.isFunctional && opticsPriority < 2)
                        {
                            opticsPriority = 2;
                            optics = p;
                            opticsModule = oM;
                        }
                        //Nonfunctional optics get last priority
                        else if (!oM.isFunctional && opticsPriority < 1)
                        {
                            opticsPriority = 1;
                            optics = p;
                            opticsModule = oM;
                        }
                    }
                }
            }
            if (optics == null)
            {
                deactivate();
                status = "No optics detected";
                return false;
            }
            else
            {
                if (opticsPriority == 0 || opticsPriority == 1)
                {
                    deactivate();
                    status = "Aperture closed";
                    return false;
                }

                if (isActive)
                {
                    //Try to consume power
                    double consumeAmount = (consumeRate * (Planetarium.GetUniversalTime() - storedTime));
                    if (part.RequestResource("ElectricCharge", consumeAmount) < consumeAmount * 0.95) //separated from other if statement because it actually eats up ElectricCharge when it's called
                    {
                        deactivate();
                        status = "Insufficient ElectricCharge";
                        timer = 0f;
                        ScreenMessages.PostScreenMessage("Processor Shutting Down (Insufficient ElectricCharge)", 6, ScreenMessageStyle.UPPER_CENTER);
                        return false;
                    }
                    else
                    {
                        isFunctional = true;
                        status = "Functioning...";
                        return true;
                    }
                }
                else
                {
                    if (timer > 3f)
                        status = "Off";
                    return true;
                }
            }
        }