예제 #1
0
  // return quality-of-life bonus
  public static double Bonus(Vessel v, string k_name)
  {
    // get QoL data from db
    kerbal_data kd = DB.KerbalData(k_name);

    // calculate quality of life bonus
    return Bonus(kd.living_space, kd.entertainment, Lib.Landed(v), Signal.Link(v).linked, Lib.CrewCount(v) < 2u);
  }
예제 #2
0
        void setLocks(Vessel v)
        {
            // lock controls for EVA death
            if (v.isEVA && EVA.IsDead(v))
            {
                InputLockManager.SetControlLock(ControlTypes.EVA_INPUT, "eva_dead_lock");
            }

            // lock controls for probes without signal
            if (v.GetCrewCount() == 0 && !Signal.Link(v).linked)
            {
                InputLockManager.SetControlLock(ControlTypes.ALL_SHIP_CONTROLS, "no_signal_lock");
                FlightInputHandler.state.mainThrottle = 0.0f;
            }
        }
예제 #3
0
  GUIContent indicator_signal(Vessel v)
  {
    GUIContent state = new GUIContent();
    link_data ld = Signal.Link(v);
    switch(ld.status)
    {
      case link_status.direct_link:
        state.image = icon_signal_direct;
        state.tooltip = "Direct link";
        break;

      case link_status.indirect_link:
        state.image = icon_signal_relay;
        if (ld.path.Count == 1)
        {
          state.tooltip = "Signal relayed by <b>" + ld.path[ld.path.Count - 1] + "</b>";
        }
        else
        {
          state.tooltip = "Signal relayed by:";
          for(int i=ld.path.Count-1; i>0; --i) state.tooltip += "\n<b>" + ld.path[i] + "</b>";
        }
        break;

      case link_status.no_link:
        state.image = icon_signal_none;
        state.tooltip = !Signal.Blackout(v) ? "No signal" : "Blackout";
        break;

      case link_status.no_antenna:
        state.image = icon_signal_none;
        state.tooltip = "No antenna";
        break;
    }
    return state;
  }
예제 #4
0
  // return quality-of-life bonus
  public static double Bonus(Vessel v)
  {
    // deduce crew count and capacity
    int crew_count = Lib.CrewCount(v);
    int crew_capacity = Lib.CrewCapacity(v);

    // deduce entertainment bonus, multiplying all entertainment factors
    double entertainment = 1.0;
    if (v.loaded)
    {
      foreach(Entertainment m in v.FindPartModulesImplementing<Entertainment>())
      {
        entertainment *= m.rate;
      }
    }
    else
    {
      foreach(ProtoPartSnapshot part in v.protoVessel.protoPartSnapshots)
      {
        foreach(ProtoPartModuleSnapshot m in part.modules)
        {
          if (m.moduleName == "Entertainment") entertainment *= Lib.GetProtoValue<double>(m, "rate");
        }
      }
    }

    // calculate quality of life bonus
    return Bonus((uint)crew_count, (uint)crew_capacity, entertainment, Lib.Landed(v), Signal.Link(v).linked);
  }
예제 #5
0
        // called at every frame
        public void Update()
        {
            // FIXME: can't double-click on vessel to switch active one, if line is rendered

            // hide all lines
            foreach (var l in lines)
            {
                l.Value.Show(false);
            }

            // do nothing if db isn't ready
            if (!DB.Ready())
            {
                return;
            }

            // do nothing if signal is disabled
            if (!Kerbalism.features.signal)
            {
                return;
            }

            // do nothing if not in map view or tracking station
            if (!MapView.MapIsEnabled)
            {
                return;
            }

            // get homebody position
            Vector3d home = FlightGlobals.GetHomeBody().position;

            // iterate all vessels
            foreach (Vessel v in FlightGlobals.Vessels)
            {
                // skip invalid vessels
                if (!Lib.IsVessel(v))
                {
                    continue;
                }

                // skip resque missions
                if (Lib.IsResqueMission(v))
                {
                    continue;
                }

                // skip EVA kerbals
                if (v.isEVA)
                {
                    continue;
                }

                // get vessel data
                vessel_data vd = DB.VesselData(v.id);

                // do nothing if showlink is disabled
                if (vd.cfg_showlink == 0)
                {
                    continue;
                }

                // get link status
                link_data ld = Signal.Link(v);

                // if there is an antenna
                if (ld.status != link_status.no_antenna)
                {
                    // get line renderer from the cache
                    Line line = getLine(v.id);

                    // start of the line
                    Vector3d a = Lib.VesselPosition(v);

                    // determine end of line and color
                    Vector3d b;
                    Color    clr;
                    if (ld.status == link_status.direct_link)
                    {
                        b   = home;
                        clr = Color.green;
                    }
                    else if (ld.status == link_status.indirect_link)
                    {
                        Vessel relay = FlightGlobals.Vessels.Find(k => k.id == ld.path_id[ld.path.Count - 1]);
                        if (relay == null)
                        {
                            line.Show(false); continue;
                        }                                    //< skip if it doesn't exist anymore
                        b   = Lib.VesselPosition(relay);
                        clr = Color.yellow;
                    }
                    else // no link
                    {
                        b   = home;
                        clr = Color.red;
                    }

                    // setup the line and show it
                    line.UpdatePoints(a, b, clr);
                    line.Show(true);
                }
            }
        }
예제 #6
0
파일: Cache.cs 프로젝트: zajc3w/Kerbalism
  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

    // 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 resque mission vessel
    is_resque = Lib.IsResqueMission(v);
    if (is_resque) return;

    // dead EVA are not valid vessels
    if (v.isEVA && EVA.KerbalData(v).eva_dead) 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 once
    position = Lib.VesselPosition(v);

    // 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;

    // if the orbit length vs simulation step is lower than an acceptable threshold, use discrete sun visibility
    if (v.mainBody.flightGlobalsIndex != 0)
    {
      double orbit_period = Sim.OrbitalPeriod(v);
      if (orbit_period / Kerbalism.elapsed_s < 16.0) sunlight = 1.0 - Sim.ShadowPeriod(v) / orbit_period;
    }

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

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

    // calculate radiation
    radiation = Radiation.Compute(v, position, gamma_transparency, sunlight, out blackout, out inside_pause, out inside_belt);

    // calculate malfunction stuff
    max_malfunction = Reliability.MaxMalfunction(v);
    avg_quality = Reliability.AverageQuality(v);

    // calculate signal info
    antenna = new antenna_data(v);
    avoid_inf_recursion.Add(v.id);
    link = Signal.Link(v, position, antenna, blackout, avoid_inf_recursion);
    avoid_inf_recursion.Remove(v.id);

    // partial data about modules, used by vessel info/monitor
    scrubbers = Scrubber.PartialData(v);
    recyclers = Recycler.PartialData(v);
    greenhouses = Greenhouse.PartialData(v);

    // woot relativity
    time_dilation = Sim.TimeDilation(v);
  }