Пример #1
0
  static void render_habitat(Panel p, Vessel v, vessel_info vi)
  {
    // if habitat feature is disabled, do not show the panel
    if (!Features.Habitat) return;

    // if vessel is unmanned, do not show the panel
    if (vi.crew_count == 0) return;

    // determine some content, with colors
    string pressure_str = Lib.Color(Lib.HumanReadablePressure(vi.pressure * Sim.PressureAtSeaLevel()), vi.pressure < Settings.PressureThreshold, "yellow");
    string poisoning_str = Lib.Color(Lib.HumanReadablePerc(vi.poisoning, "F2"), vi.poisoning > Settings.PoisoningThreshold * 0.5, "yellow");

    // render panel, add some content based on enabled features
    if (!v.isEVA)
    {
      p.section("HABITAT");
      if (Features.Pressure) p.content("pressure", pressure_str);
      if (Features.Poisoning) p.content("co2 level", poisoning_str);
      if (Features.Shielding) p.content("shielding", Habitat.shielding_to_string(vi.shielding));
      if (Features.LivingSpace) p.content("living space", Habitat.living_space_to_string(vi.living_space));
      if (Features.Comfort) p.content("comfort", vi.comforts.summary(), vi.comforts.tooltip());
    }
    else
    {
      p.section("HABITAT");
      if (Features.Poisoning) p.content("co2 level", poisoning_str);
    }
  }
Пример #2
0
        static void Render_habitat(Panel p, Vessel v, VesselData vd)
        {
            // if habitat feature is disabled, do not show the panel
            if (!Features.Habitat)
            {
                return;
            }

            // if vessel is unmanned, do not show the panel
            if (vd.CrewCount == 0)
            {
                return;
            }

            // render panel, add some content based on enabled features
            p.AddSection("HABITAT");
            if (Features.Poisoning)
            {
                p.AddContent("co2 level", Lib.Color(vd.Poisoning > Settings.PoisoningThreshold, Lib.HumanReadablePerc(vd.Poisoning, "F2"), Lib.Kolor.Yellow));
            }
            if (Features.Radiation && v.isEVA)
            {
                p.AddContent("radiation", Lib.HumanReadableRadiation(vd.EnvHabitatRadiation));
            }

            if (!v.isEVA)
            {
                if (Features.Pressure)
                {
                    p.AddContent("pressure", Lib.HumanReadablePressure(vd.Pressure * Sim.PressureAtSeaLevel()));
                }
                if (Features.Shielding)
                {
                    p.AddContent("shielding", Habitat.Shielding_to_string(vd.Shielding));
                }
                if (Features.LivingSpace)
                {
                    p.AddContent("living space", Habitat.Living_space_to_string(vd.LivingSpace));
                }
                if (Features.Comfort)
                {
                    p.AddContent("comfort", vd.Comforts.Summary(), vd.Comforts.Tooltip());
                }
                if (Features.Pressure)
                {
                    p.AddContent("EVA's available", vd.EnvBreathable ? "infinite" : Lib.HumanReadableInteger(vd.Evas), vd.EnvBreathable ? "breathable atmosphere" : "approx (derived from stored N2)");
                }
            }
        }
Пример #3
0
        static void Render_habitat(Panel p, Vessel v, Vessel_info vi)
        {
            // if habitat feature is disabled, do not show the panel
            if (!Features.Habitat)
            {
                return;
            }

            // if vessel is unmanned, do not show the panel
            if (vi.crew_count == 0)
            {
                return;
            }

            // render panel, add some content based on enabled features
            p.AddSection("HABITAT");
            if (Features.Poisoning)
            {
                p.AddContent("co2 level", Lib.Color(Lib.HumanReadablePerc(vi.poisoning, "F2"), vi.poisoning > Settings.PoisoningThreshold, "yellow"));
            }
            if (!v.isEVA)
            {
                if (Features.Humidity)
                {
                    p.AddContent("humidity", Lib.Color(Lib.HumanReadablePerc(vi.humidity, "F2"), vi.humidity > Settings.HumidityThreshold, "yellow"));
                }
                if (Features.Pressure)
                {
                    p.AddContent("pressure", Lib.HumanReadablePressure(vi.pressure * Sim.PressureAtSeaLevel()));
                }
                if (Features.Shielding)
                {
                    p.AddContent("shielding", Habitat.Shielding_to_string(vi.shielding));
                }
                if (Features.LivingSpace)
                {
                    p.AddContent("living space", Habitat.Living_space_to_string(vi.living_space));
                }
                if (Features.Comfort)
                {
                    p.AddContent("comfort", vi.comforts.Summary(), vi.comforts.Tooltip());
                }
                if (Features.Pressure)
                {
                    p.AddContent("EVA's available", vi.breathable ? "infinite" : Lib.HumanReadableInteger(vi.evas), vi.breathable ? "breathable atmosphere" : "approx (derived from stored N2)");
                }
            }
        }
Пример #4
0
        private void EvaluateStatus()
        {
            UnityEngine.Profiling.Profiler.BeginSample("Kerbalism.VesselData.EvaluateStatus");
            // determine if there is enough EC for a powered state
            powered = Lib.IsPowered(Vessel);

            // calculate crew info for the vessel
            crewCount    = Lib.CrewCount(Vessel);
            crewCapacity = Lib.CrewCapacity(Vessel);

            // malfunction stuff
            malfunction = Reliability.HasMalfunction(Vessel);
            critical    = Reliability.HasCriticalFailure(Vessel);

            // communications info
            connection = ConnectionInfo.Update(Vessel, powered, EnvBlackout);

            // habitat data
            habitatInfo.Update(Vessel);
            volume   = Habitat.Tot_volume(Vessel);
            surface  = Habitat.Tot_surface(Vessel);
            pressure = Math.Min(Habitat.Pressure(Vessel), habitatInfo.MaxPressure);

            evas          = (uint)(Math.Max(0, ResourceCache.GetResource(Vessel, "Nitrogen").Amount - 330) / Settings.LifeSupportAtmoLoss);
            poisoning     = Habitat.Poisoning(Vessel);
            shielding     = Habitat.Shielding(Vessel);
            livingSpace   = Habitat.Living_space(Vessel);
            volumePerCrew = Habitat.Volume_per_crew(Vessel);
            comforts      = new Comforts(Vessel, EnvLanded, crewCount > 1, connection.linked && connection.rate > double.Epsilon);

            // data about greenhouses
            greenhouses = Greenhouse.Greenhouses(Vessel);

            Drive.GetCapacity(this, out drivesFreeSpace, out drivesCapacity);

            // solar panels data
            if (Vessel.loaded)
            {
                solarPanelsAverageExposure = SolarPanelFixer.GetSolarPanelsAverageExposure(solarPanelsExposure);
                solarPanelsExposure.Clear();
            }
            UnityEngine.Profiling.Profiler.EndSample();
        }
Пример #5
0
        static void Render_Habitat(Panel p, Vessel v, Vessel_Info vi)
        {
            // if habitat feature is disabled, do not show the panel
            if (!Features.Habitat)
            {
                return;
            }

            // if vessel is unmanned, do not show the panel
            if (vi.crew_count == 0)
            {
                return;
            }

            // render panel, add some content based on enabled features
            p.SetSection("HABITAT");
            if (Features.Poisoning)
            {
                p.SetContent("co2 level", Lib.Color(Lib.HumanReadablePerc(vi.poisoning, "F2"), vi.poisoning > Settings.PoisoningThreshold, "yellow"));
            }
            if (!v.isEVA)
            {
                if (Features.Pressure)
                {
                    p.SetContent("pressure", Lib.HumanReadablePressure(vi.pressure * Sim.PressureAtSeaLevel()));
                }
                if (Features.Shielding)
                {
                    p.SetContent("shielding", Lib.HumanReadableShielding(vi.shielding));
                }
                if (Features.LivingSpace)
                {
                    p.SetContent("living space", Habitat.Living_Space_to_String(vi.living_space));
                }
                if (Features.Comfort)
                {
                    p.SetContent("comfort", vi.comforts.Summary(), vi.comforts.Tooltip());
                }
            }
        }
Пример #6
0
        public Vessel_info(Vessel v, UInt64 vessel_id, UInt64 inc)
        {
            // NOTE: anything used here can't in turn use cache, unless you know what you are doing

            // NOTE: you can't cache vessel position
            // at any point in time all vessel/body positions are relative to a different frame of reference
            // so comparing the current position of a vessel, with the cached one of another make no sense

            // associate with an unique incremental id
            this.inc = inc;

            // determine if this is a valid vessel
            is_vessel = Lib.IsVessel(v);
            if (!is_vessel)
            {
                return;
            }

            // determine if this is a rescue mission vessel
            is_rescue = Misc.IsRescueMission(v);
            if (is_rescue)
            {
                return;
            }

            // dead EVA are not valid vessels
            if (EVA.IsDead(v))
            {
                return;
            }

            // shortcut for common tests
            is_valid = true;

            // generate id once
            id = vessel_id;

            // calculate crew info for the vessel
            crew_count    = Lib.CrewCount(v);
            crew_capacity = Lib.CrewCapacity(v);

            // get vessel position
            Vector3d position = Lib.VesselPosition(v);

            // this should never happen again
            if (Vector3d.Distance(position, v.mainBody.position) < 1.0)
            {
                throw new Exception("Shit hit the fan for vessel " + v.vesselName);
            }

            // determine if there is enough EC for a powered state
            powered = ResourceCache.Info(v, "ElectricCharge").amount > double.Epsilon;

            // determine if in sunlight, calculate sun direction and distance
            sunlight = Sim.RaytraceBody(v, position, FlightGlobals.Bodies[0], out sun_dir, out sun_dist) ? 1.0 : 0.0;

            // environment stuff
            atmo_factor        = Sim.AtmosphereFactor(v.mainBody, position, sun_dir);
            gamma_transparency = Sim.GammaTransparency(v.mainBody, v.altitude);
            underwater         = Sim.Underwater(v);
            breathable         = Sim.Breathable(v, underwater);
            landed             = Lib.Landed(v);
            zerog = !landed && (!v.mainBody.atmosphere || v.mainBody.atmosphereDepth < v.altitude);

            if (v.mainBody.flightGlobalsIndex != 0 && TimeWarp.CurrentRate > 1000.0f)
            {
                highspeedWarp(v);
            }

            // temperature at vessel position
            temperature = Sim.Temperature(v, position, sunlight, atmo_factor, out solar_flux, out albedo_flux, out body_flux, out total_flux);
            temp_diff   = Sim.TempDiff(temperature, v.mainBody, landed);

            // radiation
            radiation = Radiation.Compute(v, position, gamma_transparency, sunlight, out blackout, out magnetosphere, out inner_belt, out outer_belt, out interstellar);

            // extended atmosphere
            thermosphere = Sim.InsideThermosphere(v);
            exosphere    = Sim.InsideExosphere(v);

            // malfunction stuff
            malfunction = Reliability.HasMalfunction(v);
            critical    = Reliability.HasCriticalFailure(v);

            // communications info
            connection   = new ConnectionInfo(v, powered, blackout);
            transmitting = Science.Transmitting(v, connection.linked && connection.rate > double.Epsilon);

            // habitat data
            volume          = Habitat.Tot_volume(v);
            surface         = Habitat.Tot_surface(v);
            pressure        = Habitat.Pressure(v);
            evas            = (uint)(Math.Max(0, ResourceCache.Info(v, "Nitrogen").amount - 330) / PreferencesLifeSupport.Instance.evaAtmoLoss);
            poisoning       = Habitat.Poisoning(v);
            humidity        = Habitat.Humidity(v);
            shielding       = Habitat.Shielding(v);
            living_space    = Habitat.Living_space(v);
            volume_per_crew = Habitat.Volume_per_crew(v);
            comforts        = new Comforts(v, landed, crew_count > 1, connection.linked && connection.rate > double.Epsilon);

            // data about greenhouses
            greenhouses = Greenhouse.Greenhouses(v);

            // other stuff
            gravioli = Sim.Graviolis(v);
        }
Пример #7
0
        // pseudo-ctor
        public override void OnStart(StartState state)
        {
            // don't break tutorial scenarios
            if (Lib.DisableScenario(this))
            {
                return;
            }

            // check if has Connected Living Space mod
            hasCLS = Lib.HasAssembly("ConnectedLivingSpace");

            // if part has Gravity Ring, find it.
            gravityRing    = part.FindModuleImplementing <GravityRing>();
            hasGravityRing = gravityRing != null;

            if (volume <= 0.0 || surface <= 0.0)
            {
                Habitat prefab = part.partInfo.partPrefab.FindModuleImplementing <Habitat>();
                if (volume <= 0.0)
                {
                    volume = prefab.volume;
                }
                if (surface <= 0.0)
                {
                    surface = prefab.surface;
                }
            }

            // set RMB UI status strings
            Volume  = Lib.HumanReadableVolume(volume);
            Surface = Lib.HumanReadableSurface(surface);

            // hide toggle if specified
            Events["Toggle"].active = toggle;
            //Actions["Action"].active = toggle;

#if DEBUG
            Events["LogVolumeAndSurface"].active = true;
#else
            Events["LogVolumeAndSurface"].active = Settings.VolumeAndSurfaceLogging;
#endif
            // create animators
            if (!hasGravityRing)
            {
                inflate_anim = new Animator(part, inflate);
            }

            // configure on start
            Configure();

            perctDeployed = Lib.Level(part, "Atmosphere", true);

            switch (this.state)
            {
            case State.enabled: Set_flow(true); break;

            case State.disabled: Set_flow(false); break;

            case State.pressurizing: Set_flow(true); break;

            case State.depressurizing: Set_flow(false); break;
            }

            if (Get_inflate_string().Length == 0) // not inflatable
            {
                SetPassable(true);
                UpdateIVA(true);
            }
            else
            {
                SetPassable(Math.Truncate(Math.Abs((perctDeployed + ResourceBalance.precision) - 1.0) * 100000) / 100000 <= ResourceBalance.precision);
                UpdateIVA(Math.Truncate(Math.Abs((perctDeployed + ResourceBalance.precision) - 1.0) * 100000) / 100000 <= ResourceBalance.precision);
            }

            if (Lib.IsFlight())
            {
                // For fix IVA when crewTransfered occur, add event to define flag for FixedUpdate
                GameEvents.onCrewTransferred.Add(UpdateCrew);
            }
        }
Пример #8
0
  public vessel_info(Vessel v, uint vessel_id, UInt64 inc)
  {
    // NOTE: anything used here can't in turn use cache, unless you know what you are doing

    // NOTE: you can't cache vessel position
    // at any point in time all vessel/body positions are relative to a different frame of reference
    // so comparing the current position of a vessel, with the cached one of another make no sense

    // associate with an unique incremental id
    this.inc = inc;

    // determine if this is a valid vessel
    is_vessel = Lib.IsVessel(v);
    if (!is_vessel) return;

    // determine if this is a rescue mission vessel
    is_rescue = Misc.IsRescueMission(v);
    if (is_rescue) return;

    // dead EVA are not valid vessels
    if (EVA.IsDead(v)) return;

    // shortcut for common tests
    is_valid = true;

    // generate id once
    id = vessel_id;

    // calculate crew info for the vessel
    crew_count = Lib.CrewCount(v);
    crew_capacity = Lib.CrewCapacity(v);

    // get vessel position
    Vector3d position = Lib.VesselPosition(v);

    // this should never happen again
    if (Vector3d.Distance(position, v.mainBody.position) < 1.0)
    {
      throw new Exception("Shit hit the fan for vessel " + v.vesselName);
    }

    // determine if in sunlight, calculate sun direction and distance
    sunlight = Sim.RaytraceBody(v, position, FlightGlobals.Bodies[0], out sun_dir, out sun_dist) ? 1.0 : 0.0;

    // at the two highest timewarp speed, the number of sun visibility samples drop to the point that
    // the quantization error first became noticeable, and then exceed 100%
    // to solve this, we switch to an analytical estimation of the portion of orbit that was in sunlight
    // - we check against timewarp rate, instead of index, to avoid issues during timewarp blending
    if (v.mainBody.flightGlobalsIndex != 0 && TimeWarp.CurrentRate > 1000.0f)
    {
      sunlight = 1.0 - Sim.ShadowPeriod(v) / Sim.OrbitalPeriod(v);
    }

    // environment stuff
    atmo_factor = Sim.AtmosphereFactor(v.mainBody, position, sun_dir);
    gamma_transparency = Sim.GammaTransparency(v.mainBody, v.altitude);
    underwater = Sim.Underwater(v);
    breathable = Sim.Breathable(v, underwater);
    landed = Lib.Landed(v);

    // temperature at vessel position
    temperature = Sim.Temperature(v, position, sunlight, atmo_factor, out solar_flux, out albedo_flux, out body_flux, out total_flux);
    temp_diff = Sim.TempDiff(temperature, v.mainBody, landed);

    // radiation
    radiation = Radiation.Compute(v, position, gamma_transparency, sunlight, out blackout, out magnetosphere, out inner_belt, out outer_belt, out interstellar);

    // extended atmosphere
    thermosphere = Sim.InsideThermosphere(v);
    exosphere = Sim.InsideExosphere(v);

    // malfunction stuff
    malfunction = Reliability.HasMalfunction(v);
    critical = Reliability.HasCriticalFailure(v);

    // signal info
    antenna = new AntennaInfo(v);
    avoid_inf_recursion.Add(v.id);
    connection = Signal.connection(v, position, antenna, blackout, avoid_inf_recursion);
    transmitting = Science.transmitting(v, connection.linked);
    relaying = Signal.relaying(v, avoid_inf_recursion);
    avoid_inf_recursion.Remove(v.id);

    // habitat data
    volume = Habitat.tot_volume(v);
    surface = Habitat.tot_surface(v);
    pressure = Habitat.pressure(v);
    poisoning = Habitat.poisoning(v);
    shielding = Habitat.shielding(v);
    living_space = Habitat.living_space(v);
    comforts = new Comforts(v, landed, crew_count > 1, connection.linked);

    // data about greenhouses
    greenhouses = Greenhouse.Greenhouses(v);

    // other stuff
    gravioli = Sim.Graviolis(v);
  }
Пример #9
0
 public HabitatInfo(Habitat habitat, float distance)
 {
     this.habitat  = habitat;
     this.distance = distance;
 }