//estimates whether it is safe to deploy the chute or not
        private void CalculateSafeToDeployEstimate()
        {
            SafeState s;

            if (vessel.externalTemperature <= maxTemp || convFlux < 0)
            {
                s = SafeState.SAFE;
            }
            else
            {
                s = chuteTemperature + 0.001 * convFlux * InvThermalMass * DeployedArea * 0.35 <= maxTemp
                        ? SafeState.RISKY
                        : SafeState.DANGEROUS;
            }

            if (safeState == s)
            {
                return;
            }
            safeState = s;
            switch (safeState)
            {
            case SafeState.SAFE:
                part.stackIcon.SetBackgroundColor(XKCDColors.White);
                break;

            case SafeState.RISKY:
                part.stackIcon.SetBackgroundColor(XKCDColors.BrightYellow);
                break;

            case SafeState.DANGEROUS:
                part.stackIcon.SetBackgroundColor(XKCDColors.Red);
                break;
            }
        }
        //estimates whether it is safe to deploy the chute or not
        private void CalculateSafeToDeployEstimate()
        {
            SafeState s;

            if (this.vessel.externalTemperature <= maxTemp || this.convFlux < 0)
            {
                s = SafeState.SAFE;
            }
            else
            {
                s = this.chuteTemperature + (0.001 * this.convFlux * this.InvThermalMass * this.DeployedArea * 0.35) <= maxTemp ? SafeState.RISKY : SafeState.DANGEROUS;
            }

            if (this.safeState != s)
            {
                this.safeState = s;
                switch (this.safeState)
                {
                case SafeState.SAFE:
                    this.part.stackIcon.SetBackgroundColor(XKCDColors.White); break;

                case SafeState.RISKY:
                    this.part.stackIcon.SetBackgroundColor(XKCDColors.BrightYellow); break;

                case SafeState.DANGEROUS:
                    this.part.stackIcon.SetBackgroundColor(XKCDColors.Red); break;
                }
            }
        }
Ejemplo n.º 3
0
        //Sets the part's staging icon background colour according to the safety to deploy
        private void SetSafeToDeploy()
        {
            SafeState[] states = this.parachutes.Select(p => p.GetSafeState()).ToArray();
            SafeState   s      = states[0];

            //What this does is that if the first is not risky, and that all the following are all like the first one (safe or dangerous),
            //Then the final state is the first one. If not, the final state is risky
            if (states.Length != 1 && s != SafeState.RISKY)
            {
                //Only stay safe or dangerous if all are safe or dangerous
                for (int i = 1; i < states.Length; i++)
                {
                    if (states[i] != s)
                    {
                        s = SafeState.RISKY; break;
                    }
                }
            }
            if (s != this.safeState)
            {
                this.safeState = s;
                switch (this.safeState)
                {
                case SafeState.SAFE:
                    this.part.stackIcon.SetBackgroundColor(XKCDColors.White); break;

                case SafeState.RISKY:
                    this.part.stackIcon.SetBackgroundColor(XKCDColors.BrightYellow); break;

                case SafeState.DANGEROUS:
                    this.part.stackIcon.SetBackgroundColor(XKCDColors.Red); break;
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Load from a xlm file to enable sessions.
 /// </summary>
 public static void Load()
 {
     if (File.Exists(Application.persistentDataPath + "/flatsave.gd"))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file = File.Open(Application.persistentDataPath + "/flatsave.gd", FileMode.Open);
         SaveManager.savedState = (SafeState)bf.Deserialize(file);
         file.Close();
     }
 }
Ejemplo n.º 5
0
    /// <summary>
    /// Save the current Safe to a xlm file.
    /// </summary>
    public static void Save()
    {
        savedState = SafeState.current;
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/flatsave.gd");

        Debug.Log(savedState.player.posX);
        bf.Serialize(file, SaveManager.savedState);
        file.Close();
    }
Ejemplo n.º 6
0
 //Returns if the parachute can safely open or not
 public SafeState GetSafeState()
 {
     if (this.Vessel.externalTemperature <= this.mat.MaxTemp || this.convectiveFlux < 0)
     {
         this.safeState = SafeState.SAFE;
     }
     else
     {
         this.safeState = this.chuteTemperature + (0.00035 * this.InvThermalMass * this.convectiveFlux * this.DeployedArea) <= this.mat.MaxTemp ? SafeState.RISKY : SafeState.DANGEROUS;
     }
     return(this.safeState);
 }
Ejemplo n.º 7
0
        public Client()
        {
            InitializeComponent();

            this.client.Connected     += new EventHandler <NetSocketConnectedEventArgs>(client_Connected);
            this.client.DataArrived   += new EventHandler <NetSockDataArrivalEventArgs>(client_DataArrived);
            this.client.Disconnected  += new EventHandler <NetSocketDisconnectedEventArgs>(client_Disconnected);
            this.client.ErrorReceived += new EventHandler <NetSockErrorReceivedEventArgs>(client_ErrorReceived);
            this.client.StateChanged  += new EventHandler <NetSockStateChangedEventArgs>(client_StateChanged);

            this.SafeCall = new Safe(Log_Local);
            SafeShowLast  = new Safe(ShowLast);
            SafeCallList  = new SafeList(Log_List);
            SafeSetState  = new SafeState(SetSt_Do);
            CommandAgent.Init(client);
        }
        //estimates whether it is safe to deploy the chute or not
        private void CalculateSafeToDeployEstimate()
        {
            part.stackIcon.SetBgColor(XKCDColors.White);
            SafeState s;
            if (this.vessel.externalTemperature <= maxTemp || convFlux < 0) { s = SafeState.SAFE; }
            else
            {
                if (this.chuteTemperature + (0.001 * convFlux * this.invThermalMass * this.deployedArea * 0.35) <= maxTemp) { s = SafeState.RISKY; }
                else { s = SafeState.DANGEROUS; }
            }

            if (this.safeState != s)
            {
                this.safeState = s;
                switch(this.safeState)
                {
                    case SafeState.SAFE:
                        part.stackIcon.SetBgColor(XKCDColors.White); break;

                    case SafeState.RISKY:
                        part.stackIcon.SetBgColor(XKCDColors.BrightYellow); break;

                    case SafeState.DANGEROUS:
                        part.stackIcon.SetBgColor(XKCDColors.Red); break;
                }
            }
        }