コード例 #1
0
        private void UpdateStatus(VesselSupplyStatus v)
        {
            if (_lastUpdate < ResourceUtilities.FLOAT_TOLERANCE)
            {
                _lastUpdate = Planetarium.GetUniversalTime();
            }

            bool fullRefresh = false;

            if (Planetarium.GetUniversalTime() > _lastUpdate + 5d) //A reasonable time for easing in everything
            {
                fullRefresh = true;
                _lastUpdate = Planetarium.GetUniversalTime();
            }

            var newRecMult = (float)LifeSupportManager.GetRecyclerMultiplier(vessel);
            var newSpace   = (float)LifeSupportManager.CalculateVesselHabExtraTime(vessel);
            var newHabMult = (float)LifeSupportManager.CalculateVesselHabMultiplier(vessel, _currentCrew);
            //If we're the active vessel, and we're past easing, we always take calc values.
            //Otherwise, let's use the cache.
            var useCur = fullRefresh && vessel.id == FlightGlobals.ActiveVessel.id;

            //Start with intelligent defaults.
            if (v.RecyclerMultiplier < ResourceUtilities.FLOAT_TOLERANCE)
            {
                v.RecyclerMultiplier = 1f;
            }
            if (newRecMult < ResourceUtilities.FLOAT_TOLERANCE)
            {
                newRecMult = 1f;
            }
            //And take the lowest (non-zero)
            if (useCur || newRecMult < v.RecyclerMultiplier)
            {
                v.RecyclerMultiplier = newRecMult;
            }

            //Hab we want the best ones.
            if (useCur || newSpace > v.ExtraHabSpace)
            {
                v.ExtraHabSpace = newSpace;
            }

            if (useCur || newHabMult > v.VesselHabMultiplier)
            {
                v.VesselHabMultiplier = newHabMult;
            }

            LifeSupportManager.Instance.TrackVessel(v);
        }