コード例 #1
0
ファイル: LifeSupportManager.cs プロジェクト: Gnurfos/USI-LS
        public LifeSupportStatus FetchKerbal(ProtoCrewMember crew)
        {
            if (!IsKerbalTracked(crew.name))
            {
                var k = new LifeSupportStatus();
                k.KerbalName        = crew.name;
                k.HomeBodyId        = FlightGlobals.GetHomeBodyIndex();
                k.LastPlanet        = FlightGlobals.GetHomeBodyIndex();
                k.LastMeal          = Planetarium.GetUniversalTime();
                k.LastEC            = Planetarium.GetUniversalTime();
                k.LastAtHome        = Planetarium.GetUniversalTime();
                k.LastSOIChange     = Planetarium.GetUniversalTime();
                k.MaxOffKerbinTime  = Planetarium.GetUniversalTime() + 648000;
                k.TimeEnteredVessel = Planetarium.GetUniversalTime();
                k.CurrentVesselId   = "?UNKNOWN?";
                k.PreviousVesselId  = "??UNKNOWN??";
                k.LastUpdate        = Planetarium.GetUniversalTime();
                k.IsGrouchy         = false;
                k.OldTrait          = crew.experienceTrait.Title;
                TrackKerbal(k);
            }

            LifeSupportStatus kerbal = null;
            var count = LifeSupportInfo.Count;

            for (int i = 0; i < count; ++i)
            {
                if (LifeSupportInfo[i].KerbalName == crew.name)
                {
                    kerbal = LifeSupportInfo[i];
                    break;
                }
            }
            return(kerbal);
        }
コード例 #2
0
        protected void checkCompletion()
        {
            if (isCompleted)
            {
                return;
            }

            //If the experiment hasn't been completed then we can't be complete.
            WBIResearchContract contract = (WBIResearchContract)Root;

            if (contract.versionNumber >= WBIResearchContract.CurrentContractVersion)
            {
                if (contract.experimentCompleted == false)
                {
                    base.SetIncomplete();
                    return;
                }
            }

            //Check situation
            if (FlightGlobals.ActiveVessel.mainBody.flightGlobalsIndex == FlightGlobals.GetHomeBodyIndex() &&
                (FlightGlobals.ActiveVessel.situation == Vessel.Situations.LANDED || FlightGlobals.ActiveVessel.situation == Vessel.Situations.SPLASHED))
            {
                isCompleted = true;
                base.SetComplete();
            }
            else
            {
                base.SetIncomplete();
            }
        }
コード例 #3
0
        public LifeSupportStatus FetchKerbal(ProtoCrewMember crew)
        {
            if (!IsKerbalTracked(crew.name))
            {
                var k = new LifeSupportStatus();
                k.KerbalName        = crew.name;
                k.HomeBodyId        = FlightGlobals.GetHomeBodyIndex();
                k.LastPlanet        = FlightGlobals.GetHomeBodyIndex();
                k.LastMeal          = Planetarium.GetUniversalTime();
                k.LastEC            = Planetarium.GetUniversalTime();
                k.LastAtHome        = Planetarium.GetUniversalTime();
                k.LastSOIChange     = Planetarium.GetUniversalTime();
                k.MaxOffKerbinTime  = Planetarium.GetUniversalTime() + 648000;
                k.TimeEnteredVessel = Planetarium.GetUniversalTime();
                k.CurrentVesselId   = "?UNKNOWN?";
                k.PreviousVesselId  = "??UNKNOWN??";
                k.LastUpdate        = Planetarium.GetUniversalTime();
                k.IsGrouchy         = false;
                k.OldTrait          = crew.experienceTrait.Title;
                TrackKerbal(k);
            }

            var kerbal = LifeSupportInfo.FirstOrDefault(k => k.KerbalName == crew.name);

            return(kerbal);
        }
コード例 #4
0
ファイル: Planner.cs プロジェクト: tinygrox/Kerbalism
        ///<summary> Initializes the Planner for use </summary>
        internal static void Initialize()
        {
            // set the ui styles
            SetStyles();

            // set default body index to home
            body_index = FlightGlobals.GetHomeBodyIndex();

            // resource panels
            // - add all resources defined in the Profiles Supply configs except EC
            Profile.supplies.FindAll(k => k.resource != "ElectricCharge").ForEach(k => supplies.Add(k.resource));

            // special panels
            // - stress & radiation panels require that a rule using the living_space/radiation modifier exist (current limitation)
            if (Features.LivingSpace && Profile.rules.Find(k => k.modifiers.Contains("living_space")) != null)
            {
                panel_special.Add("qol");
            }
            if (Features.Radiation && Profile.rules.Find(k => k.modifiers.Contains("radiation")) != null)
            {
                panel_special.Add("radiation");
            }
            if (Features.Reliability)
            {
                panel_special.Add("reliability");
            }

            // environment panels
            if (Features.Pressure || Features.Poisoning)
            {
                panel_environment.Add("habitat");
            }
            panel_environment.Add("environment");
        }
コード例 #5
0
  // ctor
  public Planner()
  {
    // set default body index & situation
    body_index = FlightGlobals.GetHomeBodyIndex();
    situation_index = 1;

    // left menu style
    leftmenu_style = new GUIStyle(HighLogic.Skin.label);
    leftmenu_style.richText = true;
    leftmenu_style.normal.textColor = new Color(0.75f, 0.75f, 0.75f, 1.0f);
    leftmenu_style.fixedWidth = 120.0f;
    leftmenu_style.stretchHeight = true;
    leftmenu_style.fontSize = 10;
    leftmenu_style.alignment = TextAnchor.MiddleLeft;

    // mid menu style
    midmenu_style = new GUIStyle(leftmenu_style);
    midmenu_style.fixedWidth = 0.0f;
    midmenu_style.stretchWidth = true;
    midmenu_style.alignment = TextAnchor.MiddleCenter;

    // right menu style
    rightmenu_style = new GUIStyle(leftmenu_style);
    rightmenu_style.alignment = TextAnchor.MiddleRight;

    // row style
    row_style = new GUIStyle();
    row_style.stretchWidth = true;
    row_style.fixedHeight = 16.0f;

    // title style
    title_style = new GUIStyle(HighLogic.Skin.label);
    title_style.normal.background = Lib.GetTexture("black-background");
    title_style.normal.textColor = Color.white;
    title_style.stretchWidth = true;
    title_style.stretchHeight = false;
    title_style.fixedHeight = 16.0f;
    title_style.fontSize = 12;
    title_style.border = new RectOffset(0, 0, 0, 0);
    title_style.padding = new RectOffset(3, 4, 3, 4);
    title_style.alignment = TextAnchor.MiddleCenter;

    // content style
    content_style = new GUIStyle(HighLogic.Skin.label);
    content_style.richText = true;
    content_style.normal.textColor = Color.white;
    content_style.stretchWidth = true;
    content_style.stretchHeight = true;
    content_style.fontSize = 12;
    content_style.alignment = TextAnchor.MiddleLeft;

    // quote style
    quote_style = new GUIStyle(HighLogic.Skin.label);
    quote_style.richText = true;
    quote_style.normal.textColor = Color.white;
    quote_style.stretchWidth = true;
    quote_style.stretchHeight = true;
    quote_style.fontSize = 11;
    quote_style.alignment = TextAnchor.LowerCenter;
  }
コード例 #6
0
ファイル: Sim.cs プロジェクト: DanvanNaos/Kerbalism
 // return difference from survival temperature
 // - as a special case, there is no temp difference when landed on the home body
 public static double TempDiff(double k, CelestialBody body, bool landed)
 {
     if (body.flightGlobalsIndex == FlightGlobals.GetHomeBodyIndex() && landed)
     {
         return(0.0);
     }
     return(Math.Max(Math.Abs(k - Settings.SurvivalTemperature) - Settings.SurvivalRange, 0.0));
 }
コード例 #7
0
ファイル: Sim.cs プロジェクト: gotmachine/Kerbalism-1
 // return difference from survival temperature
 // - as a special case, there is no temp difference when landed on the home body
 public static double TempDiff(double k, CelestialBody body, bool landed)
 {
     if (body.flightGlobalsIndex == FlightGlobals.GetHomeBodyIndex() && landed)
     {
         return(0.0);
     }
     return(Math.Max(Math.Abs(k - PreferencesLifeSupport.Instance.survivalTemperature) - PreferencesLifeSupport.Instance.survivalRange, 0.0));
 }
コード例 #8
0
 /// <summary>
 /// Returns the Maximum distance between homebody & targetbody
 /// </summary>
 /// <param name="mainbody"></param>
 /// <param name="targetbody"></param>
 /// <returns></returns>
 public static double getMaxDistance(CelestialBody homeBody, CelestialBody targetBody)
 {
     if (FlightGlobals.Bodies[FlightGlobals.GetHomeBodyIndex()].orbitingBodies.Contains(targetBody))
     {
         return(targetBody.orbit.PeR + 1);
     }
     else
     {
         return(homeBody.orbit.ApR + targetBody.orbit.ApR);
     }
 }
コード例 #9
0
 protected virtual void checkSituation()
 {
     if (FlightGlobals.ActiveVessel.mainBody.flightGlobalsIndex == FlightGlobals.GetHomeBodyIndex() &&
         (FlightGlobals.ActiveVessel.situation == Vessel.Situations.LANDED || FlightGlobals.ActiveVessel.situation == Vessel.Situations.SPLASHED))
     {
         isCompleted = true;
         base.SetComplete();
     }
     else
     {
         base.SetIncomplete();
     }
 }
コード例 #10
0
        /// <summary>
        /// Returns List of all Bodies orbiting Sun & Homebody
        /// </summary>
        /// <returns>CelestialBody</returns>
        public static List <CelestialBody> GetCelestialBodies()
        {
            List <CelestialBody> celestialBodies = new List <CelestialBody>();

            if (!ResearchBodiesAPI)
            {
                foreach (CelestialBody celestialBody in FlightGlobals.Bodies[0].orbitingBodies)
                {
                    if (celestialBody != FlightGlobals.GetHomeBody())
                    {
                        celestialBodies.Add(celestialBody);
                    }
                }

                foreach (CelestialBody celestialBody in FlightGlobals.Bodies[FlightGlobals.GetHomeBodyIndex()].orbitingBodies)
                {
                    celestialBodies.Add(celestialBody);
                }
                return(celestialBodies);
            }
            else
            {
                Dictionary <CelestialBody, RBWrapper.CelestialBodyInfo> RBbodies = RBWrapper.RBactualAPI.CelestialBodies;
                foreach (CelestialBody celestialBody in FlightGlobals.Bodies[0].orbitingBodies)
                {
                    if (celestialBody != FlightGlobals.GetHomeBody())
                    {
                        if (RBbodies.ContainsKey(celestialBody))
                        {
                            RBWrapper.CelestialBodyInfo RBbodyInfo = RBbodies[celestialBody];
                            if (RBbodyInfo.isResearched)
                            {
                                celestialBodies.Add(celestialBody);
                            }
                        }
                    }
                }
                foreach (CelestialBody celestialBody in FlightGlobals.Bodies[FlightGlobals.GetHomeBodyIndex()].orbitingBodies)
                {
                    RBWrapper.RBactualAPI.CelestialBodies.TryGetValue(celestialBody, out RBWrapper.CelestialBodyInfo celestialBodyInfo);
                    if (celestialBodyInfo.isResearched)
                    {
                        Debug.Log(celestialBody.name);
                        celestialBodies.Add(celestialBody);
                    }
                }

                return(celestialBodies);
            }
        }
コード例 #11
0
        protected override void checkSituation()
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            if (FlightGlobals.ActiveVessel.mainBody.flightGlobalsIndex == FlightGlobals.GetHomeBodyIndex() &&
                (FlightGlobals.ActiveVessel.situation == Vessel.Situations.LANDED ||
                 FlightGlobals.ActiveVessel.situation == Vessel.Situations.SPLASHED ||
                 FlightGlobals.ActiveVessel.situation == Vessel.Situations.PRELAUNCH))
            {
                if (kerbal == null)
                {
                    KerbalRoster roster = HighLogic.CurrentGame.CrewRoster;
                    if (roster.Exists(kerbalName))
                    {
                        kerbal = roster[kerbalName];
                    }
                }
                if (kerbal == null)
                {
                    isCompleted = false;
                    SetIncomplete();
                }

                if (FlightGlobals.ActiveVessel.GetVesselCrew().Contains(kerbal))
                {
                    isCompleted = true;
                    base.SetComplete();
                }
                else
                {
                    isCompleted = false;
                    SetIncomplete();
                }
            }
            else
            {
                base.SetIncomplete();
            }
        }
コード例 #12
0
ファイル: RTSettings.cs プロジェクト: spJL/RemoteTech
        /// <summary>
        /// Utilise KSP's GameDatabase to get a list of cfgs, included our Default_Settings.cfg, contained the 'RemoteTechSettings'
        /// node and process each cfg accordingly
        ///
        /// NOTE: Please do not use the static 'Default_Settings.cfg' file directly because we want third-party modders to apply
        /// ModuleManager patches of their tweaks, like no signal delay, to our default-settings cfg that will be used when a
        /// player starts a new game. (refer to our online manual for more details)
        /// </summary>
        public static Settings Load()
        {
            // Create a blank object of settings
            var settings       = new Settings();
            var defaultSuccess = false;

            // Exploit KSP's GameDatabase to find our MM-patched cfg of default settings (from GameData/RemoteTech/Default_Settings.cfg)
            var cfgs = GameDatabase.Instance.GetConfigs("RemoteTechSettings");

            for (var i = 0; i < cfgs.Length; i++)
            {
                if (cfgs[i].url.Equals(DefaultSettingCfgURL))
                {
                    defaultSuccess = ConfigNode.LoadObjectFromConfig(settings, cfgs[i].config);
                    RTLog.Notify("Load default settings into object with {0}: LOADED {1}", cfgs[i].config, defaultSuccess ? "OK" : "FAIL");
                    break;
                }
            }

            if (!defaultSuccess) // disable itself and write explanation to KSP's log
            {
                RTLog.Notify("RemoteTech is disabled because the default cfg '{0}' is not found", DefaultSettingCfgURL);
                return(null);
                // the main impact of returning null is the endless loop of invoking Load() in the KSP's loading screen
            }

            settings.SettingsLoaded = true;

            // Disable RemoteTech on Training missions
            if (RTUtil.IsGameScenario)
            {
                settings.RemoteTechEnabled = false;
                settings.CommNetEnabled    = true;
            }

            // stop and return default settings if we are on the KSP loading screen OR in training scenarios
            if (string.IsNullOrEmpty(SaveSettingFile))
            {
                return(settings);
            }

            // try to load from the save-settings.cfg (MM-patches will not touch because it is outside GameData)
            var load = ConfigNode.Load(SaveSettingFile);

            if (load == null)
            {
                // write the RT settings to the player's save folder
                settings.Save();
                settings.FirstStart = true;
            }
            else
            {
                // old or new format?
                if (load.HasNode("RemoteTechSettings"))
                {
                    load = load.GetNode("RemoteTechSettings");
                }

                // replace the default settings with save-setting file
                var success = ConfigNode.LoadObjectFromConfig(settings, load);
                RTLog.Notify("Found and load save settings into object with {0}: LOADED {1}", load, success ? "OK" : "FAIL");
            }

            // find third-party mods' RemoteTech settings
            SearchAndPreparePresets(settings);

            // Detect if the celestial body, that Mission Control is on (default body index 1), is Kerbin
            var KSCMC = settings.GroundStations.Find(x => x.GetName().Equals("Mission Control"));                   // leave extra ground stations to modders, who need to provide MM patches

            if (KSCMC != null && !KSCMC.GetBody().name.Equals("Kerbin") && KSCMC.GetBody().flightGlobalsIndex == 1) // Kopernicus or similar map changes the planet
            {
                KSCMC.SetBodyIndex(FlightGlobals.GetHomeBodyIndex());
                RTLog.Notify("KSC's Mission Control is on the wrong planet (not Kerbin/Earth) (Any Kopernicus/similar map would change). Relocated to the homeworld's body index {0}.", FlightGlobals.GetHomeBodyIndex());
            }

            RTSettings.OnSettingsLoaded.Fire();

            return(settings);
        }