Exemplo n.º 1
0
        public void Save(ConfigNode node)
        {
            ConfigNode settingsNode;

            if (node.HasNode(configNodeName))
            {
                settingsNode = node.GetNode(configNodeName);
                settingsNode.ClearData();
            }
            else
            {
                settingsNode = node.AddNode(configNodeName);
            }
            settingsNode.AddValue("Enabled", Enabled);
            settingsNode.AddValue("Difficulty", Difficulty);
            settingsNode.AddValue("ResearchCost", ResearchCost);
            settingsNode.AddValue("ProgressResearchCost", ProgressResearchCost);
            settingsNode.AddValue("ScienceReward", ScienceReward);
            settingsNode.AddValue("UseAppLauncher", UseAppLauncher);
            settingsNode.AddValue("DebugLogging", DebugLogging);
            settingsNode.AddValue("chances", chances);
            settingsNode.AddValue("enableInSandbox", enableInSandbox);
            settingsNode.AddValue("allowTSlevel1", allowTSlevel1);

            foreach (var entry in Database.instance.CelestialBodies)
            {
                ConfigNode CBNode = entry.Value.Save(settingsNode);
                RSTUtils.Utilities.Log_Debug("RBGameSettings Saving Entry = {0}", entry.Key.GetName());
                //CBNode.AddValue("body", entry.Key.GetName());
            }
            RSTLogWriter.Log("RBGameSettings Saving Complete");
        }
Exemplo n.º 2
0
 public void ApplySettings()
 {
     RSTLogWriter.Log("Database ApplySettings");
     if (HighLogic.CurrentGame != null)
     {
         //if (RB_SettingsParms == null)
         RB_SettingsParms = HighLogic.CurrentGame.Parameters.CustomParams <ResearchBodies_SettingsParms>();
         if (ResearchBodies.Instance != null)
         {
             ResearchBodies.Enabled = RB_SettingsParms.RBEnabled;
         }
         chances       = RB_SettingsParms.DiscoverySeed;
         allowTSlevel1 = RB_SettingsParms.Enabledtslvl1;
         if (RB_SettingsParms.french)
         {
             if (Locales.currentLocale.LocaleFull != "Français")
             {
                 Locales.setLocale("Français");
                 if (ResearchBodiesController.instance != null)
                 {
                     ResearchBodiesController.instance.French = true;
                 }
             }
         }
         else
         {
             Locales.setLocale("");
         }
         RSTLogWriter.debuggingOn = HighLogic.CurrentGame.Parameters.CustomParams <ResearchBodies_SettingsParms>().DebugLogging;
     }
     else
     {
         RSTLogWriter.Log("Database Failed to apply settings - Fatal Error");
     }
 }
Exemplo n.º 3
0
        public override void OnAwake()
        {
            RSTLogWriter.Log("OnAwake in " + HighLogic.LoadedScene);
            base.OnAwake();

            GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequested);

            if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                RSTLogWriter.Log("Adding SpaceCenterManager");
                var RBC = gameObject.AddComponent <ResearchBodiesController>();
                children.Add(RBC);
            }
            else if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                RSTLogWriter.Log("Adding FlightManager");
                var RBC = gameObject.AddComponent <ResearchBodiesController>();
                children.Add(RBC);
            }
            else if (HighLogic.LoadedScene == GameScenes.EDITOR)
            {
                RSTLogWriter.Log("Adding EditorController");
                var RBC = gameObject.AddComponent <ResearchBodiesController>();
                children.Add(RBC);
            }
            else if (HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                RSTLogWriter.Log("Adding TrackingStationController");
                var RBC = gameObject.AddComponent <ResearchBodiesController>();
                children.Add(RBC);
            }
        }
Exemplo n.º 4
0
        public static void LaunchResearchPlan(CelestialBody cb)
        {
            CelestialBody cbKey = Database.instance.ContainsBodiesKey(cb.bodyName);

            if (cbKey != null && Database.instance.CelestialBodies[cbKey].researchState == 0)
            {
                if (Funding.Instance != null)
                {
                    //if (Funding.Instance.Funds >= Database.Instance.RB_SettingsParms.ResearchCost)
                    if (Funding.Instance.Funds >= Database.instance.RB_SettingsParms.ResearchCost)
                    {
                        //Funding.Instance.AddFunds(-Database.Instance.RB_SettingsParms.ResearchCost, TransactionReasons.None);
                        Funding.Instance.AddFunds(-Database.instance.RB_SettingsParms.ResearchCost, TransactionReasons.Progression);
                        Research(cbKey, 10);
                    }
                    else
                    {
                        ScreenMessages.PostScreenMessage(Localizer.Format("#autoLOC_RBodies_00014", cbKey.displayName), 3.0f, ScreenMessageStyle.UPPER_CENTER);
                    }
                }
                else
                {
                    if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER)
                    {
                        Research(cbKey, 10);
                    }
                }
            }
            else
            {
                RSTLogWriter.Log(Localizer.Format("#autoLOC_RBodies_00015", cb.displayName));
            }
        }
Exemplo n.º 5
0
 public override void OnLoad(ConfigNode gameNode)
 {
     base.OnLoad(gameNode);
     RBgameSettings.Load(gameNode);
     // Load the global settings
     //if (File.Exists(globalConfigFilename))
     //{
     //    globalNode = ConfigNode.Load(globalConfigFilename);
     //    foreach (Savable s in children.Where(c => c is Savable))
     //    {
     //        s.Load(globalNode);
     //    }
     //}
     RSTLogWriter.debuggingOn = RBgameSettings.DebugLogging;
     if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX && !Database.instance.enableInSandbox)
     {
         RBgameSettings.Enabled = false;
     }
     enabled  = RBgameSettings.Enabled;
     APIReady = true;
     if (RSTLogWriter.debuggingOn)
     {
         RSTLogWriter.Log_Debug("Scenario: " + HighLogic.LoadedScene + " OnLoad: \n ");
     }
     //    RSTLogWriter.Log_Debug("Scenario: " + HighLogic.LoadedScene + " OnLoad: \n " + gameNode + "\n" + globalNode);
     else
     {
         RSTLogWriter.Log("ResearchBodies Scenario Onload Completed.");
     }
 }
Exemplo n.º 6
0
        public void Start()
        {
            ConfigNode[] cfgs = GameDatabase.Instance.GetConfigNodes("RESEARCHBODIES");
            foreach (ConfigNode node in cfgs)
            {
                if (node.GetValue("loadAs") == "locale")
                {
                    Locale l = new Locale(node);
                    locales.Add(l);
                    RSTLogWriter.Log("Added locale \"{0}\"", l.LocaleId);
                }
            }

            if (locales.Count == 0)
            {
                RSTLogWriter.Log("No locale added !");
            }
            else
            {
                RSTLogWriter.Log("Added {0}  locales", locales.Count);
            }
            RSTLogWriter.Flush();
            Locales.setLocale("");
            Available = true;
        }
Exemplo n.º 7
0
 public void OnDestroy()
 {
     RSTLogWriter.Log("OnDestroy");
     GameEvents.onGameStatePostLoad.Remove(onGameStatePostLoad);
     GameEvents.OnGameSettingsApplied.Remove(ApplySettings);
     //GameEvents.onGameStateLoad.Remove(ApplySettings);
 }
 public static void LaunchResearchPlan(CelestialBody cb)
 {
     if (Database.instance.CelestialBodies[cb].researchState == 0)
     {
         if (Funding.Instance != null)
         {
             if (Funding.Instance.Funds >= ResearchBodies.Instance.RBgameSettings.ResearchCost)
             {
                 Funding.Instance.AddFunds(-ResearchBodies.Instance.RBgameSettings.ResearchCost, TransactionReasons.None);
                 Research(cb, 10);
             }
             else
             {
                 ScreenMessages.PostScreenMessage(
                     string.Format(Locales.currentLocale.Values["launchPlan_notEnoughScience"], cb.GetName()),
                     3.0f, ScreenMessageStyle.UPPER_CENTER);
             }
         }
         else
         {
             if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER)
             {
                 Research(cb, 10);
             }
         }
     }
     else
     {
         RSTLogWriter.Log(string.Format(Locales.currentLocale.Values["launchPlan_alreadyStarted"], cb.GetName()));
     }
 }
Exemplo n.º 9
0
        internal bool IsViewObstructed(Transform Origin, Transform Target)
        {
            float distance = Vector3.Distance(Target.position, Origin.position);

            RaycastHit[] hitInfo;
            Vector3      direction = (Target.position - Origin.position).normalized;

            if (RSTLogWriter.debuggingOn)
            {
                Debug.DrawRay(Origin.position, direction * distance, Color.red, 5f);
            }
            hitInfo = Physics.RaycastAll(new Ray(Origin.position, direction), distance, 3245585, QueryTriggerInteraction.Ignore);

            for (int i = 0; i < hitInfo.Length; i++)
            {
                if (hitInfo[i].transform.name != Target.transform.name)
                {
                    RSTLogWriter.Log_Debug("View Obstructed by {0} , Origin: {1} , Target {2} , Direction {3} , Hit: {4}, Layer: {5}",
                                           hitInfo[i].collider.name, Origin.position, Target.position, direction, hitInfo[i].transform.position, hitInfo[i].collider.gameObject.layer);
                    return(true);
                }
            }

            RSTLogWriter.Log_Debug("No View obstruction");
            return(false);
        }
Exemplo n.º 10
0
 public void onGameStatePostLoad(ConfigNode node)
 {
     RSTLogWriter.Log("onGameStatePostLoad");
     if (HighLogic.CurrentGame != null)
     {
         RB_SettingsParms = HighLogic.CurrentGame.Parameters.CustomParams <ResearchBodies_SettingsParms>();
         ApplySettings();
         foreach (KeyValuePair <CelestialBody, CelestialBodyInfo> CB in CelestialBodies)
         {
             CB.Value.ignore = CB.Value.IgnoreData.GetLevel(HighLogic.CurrentGame.Parameters.CustomParams <ResearchBodies_SettingsParms>().difficulty);
             if (CB.Value.ignore)
             {
                 CB.Value.isResearched  = true;
                 CB.Value.researchState = 100;
             }
             //else
             //{
             //    CB.Value.isResearched = false;
             //    CB.Value.researchState = 0;
             //}
         }
     }
     else
     {
         RSTLogWriter.Log("Highlogic.CurrentGame is NULL cannot set Settings!!");
     }
 }
Exemplo n.º 11
0
 public ResearchBodies()
 {
     RSTLogWriter.Log("ResearchBodies Constructor");
     Instance       = this;
     APIReady       = false;
     RBgameSettings = new RBGameSettings();
     //globalConfigFilename = Path.Combine(RSTLogWriter.AssemblyFolder, "PluginData/Config.cfg").Replace("\\", "/");
     //RSTLogWriter.Log("globalConfigFilename = " + globalConfigFilename);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Call this to signal that you have found a celestial body.
 /// It will set the celestial body to discovered.
 /// </summary>
 /// <param name="scienceReward">The scienceReward additional amount that is added to the base scienceReward for finding a body</param>
 /// <param name="bodyFound">The Celestial Body found</param>
 /// <param name="withParent">Will return true if the Parent Body has also been found</param>
 /// <param name="parentBody">The parent body that was discovered as well if withParent is true</param>
 /// <returns></returns>
 public static bool FoundBody(int scienceReward, CelestialBody bodyFound, out bool withParent, out CelestialBody parentBody)
 {
     withParent = false;
     parentBody = null;
     if (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX)  //If not sandbox add the Science Points reward!
     {
         //var sciencePtsReward = scienceReward + Database.Instance.RB_SettingsParms.ScienceReward;
         var sciencePtsReward = scienceReward + Database.instance.RB_SettingsParms.ScienceReward;
         ResearchAndDevelopment.Instance.AddScience(sciencePtsReward, TransactionReasons.None);
         ScreenMessages.PostScreenMessage("Added " + sciencePtsReward + " science points !", 5f);
     }
     //Check if the referencebody is also not known. If so, we discover both the body and it's referencebody (parent).
     if (bodyFound.referenceBody != null && bodyFound != bodyFound.referenceBody && bodyFound.referenceBody.DiscoveryInfo.Level == DiscoveryLevels.Presence)
     {
         CelestialBody cbKey = Database.instance.ContainsBodiesKey(bodyFound.referenceBody.bodyName);
         if (cbKey != null)
         {
             Database.instance.CelestialBodies[cbKey].isResearched = true;
         }
         cbKey = Database.instance.ContainsBodiesKey(bodyFound.bodyName);
         if (cbKey != null)
         {
             Database.instance.CelestialBodies[cbKey].isResearched = true;
             var tempEntry = new KeyValuePair <CelestialBody, CelestialBodyInfo>(bodyFound, Database.instance.CelestialBodies[bodyFound]);
             setCBContractWeight(tempEntry, false);
         }
         withParent = true;
         parentBody = bodyFound.referenceBody;
         //check for Barycenter as well.
         if (bodyFound.referenceBody.referenceBody != null)
         {
             if ((bodyFound.referenceBody.referenceBody.DiscoveryInfo.Level == DiscoveryLevels.Appearance ||
                  bodyFound.referenceBody.referenceBody.DiscoveryInfo.Level == DiscoveryLevels.Presence) &&
                 Database.instance.CelestialBodies.ContainsKey(bodyFound.referenceBody.referenceBody))
             {
                 Database.instance.CelestialBodies[bodyFound.referenceBody.referenceBody].isResearched = true;
                 var tempEntry = new KeyValuePair <CelestialBody, CelestialBodyInfo>(bodyFound.referenceBody.referenceBody, Database.instance.CelestialBodies[bodyFound.referenceBody.referenceBody]);
                 setCBContractWeight(tempEntry, false);
             }
         }
         RSTLogWriter.Log("Found body {0} orbiting around {1} !", bodyFound.GetName(), bodyFound.referenceBody.GetName());
     }
     else //No parent or parent is already discovered. So we just found this body.
     {
         CelestialBody cbKey = Database.instance.ContainsBodiesKey(bodyFound.bodyName);
         if (cbKey != null)
         {
             Database.instance.CelestialBodies[cbKey].isResearched = true;
             var tempEntry = new KeyValuePair <CelestialBody, CelestialBodyInfo>(cbKey, Database.instance.CelestialBodies[cbKey]);
             setCBContractWeight(tempEntry, false);
         }
         withParent = false;
         RSTLogWriter.Log("Found body {0} !", bodyFound.GetName());
     }
     RSTLogWriter.Flush();
     return(true);
 }
Exemplo n.º 13
0
        public void OnGUI()
        {
            if (!enable)
            {
                instructor_Werner.Instructor.enabled = false;
                instructor_Linus.Instructor.enabled  = false;
                return;
            }
            instructor_Werner.Instructor.enabled = true;
            instructor_Linus.Instructor.enabled  = true;
            try
            {
                if (!Textures.StylesSet)
                {
                    Textures.SetupStyles();
                }
            }
            catch (Exception ex)
            {
                RSTLogWriter.Log("Unable to set GUI Styles to draw the GUI");
                RSTLogWriter.Log("Exception: {0}", ex);
            }

            GUI.skin = Textures.ObsSkin;
            #if DEBUGFACILITY
            if (showObsdebugUI)
            {
                observRect = GUILayout.Window(_RBwindowId + 1, observRect, DrawObservDebug, "Research Bodies");
            }
            #endif

            if (!showGUI)
            {
                return;
            }

            if (PSystemSetup.Instance.GetSpaceCenterFacility("TrackingStation").GetFacilityDamage() > 0)
            {
                ScreenMessages.PostScreenMessage(Locales.FmtLocaleString("#autoLOC_RBodies_00018"), 3.0f, ScreenMessageStyle.UPPER_CENTER);
                return;
            }

            try
            {
                windowRect.ClampInsideScreen();
                windowRect = GUILayout.Window(_RBwindowId, windowRect, DrawWindow, "Research Bodies");
                Utilities.DrawToolTip();
            }
            catch (Exception ex)
            {
                RSTLogWriter.Log("Unable to draw GUI");
                RSTLogWriter.Log("Exception: {0}", ex);
            }
        }
Exemplo n.º 14
0
 public void Awake()
 {
     if (instance != null)
     {
         RSTLogWriter.Log("Singleton instance of Databse already exists. Destroying this one");
         Destroy(this);
     }
     instance = this;
     DontDestroyOnLoad(this);
     difficultyStrings = new string[] { Locales.currentLocale.Values["start_easy"], Locales.currentLocale.Values["start_normal"], Locales.currentLocale.Values["start_medium"], Locales.currentLocale.Values["start_hard"] };
 }
 private void TryWithDrawContract(Contract c)
 {
     try
     {
         RSTLogWriter.Log("WithDrew contract \"{0}\"", c.Title);
         c.Withdraw(); //Changed to Withdraw - this will not penalize reputation.
     }
     catch (Exception e)
     {
         RSTLogWriter.Log("Unable to Withraw contract ! {0}", e);
     }
 }
Exemplo n.º 16
0
 public ResearchBodies()
 {
     RSTLogWriter.Log("ResearchBodies Constructor");
     if (Instance != null)
     {
         RSTLogWriter.Log("Instance exists, destroying Usurper");
         Destroy(this);
     }
     Instance       = this;
     APIReady       = false;
     RBgameSettings = new RBGameSettings();
 }
Exemplo n.º 17
0
 protected void OnDestroy()
 {
     RSTLogWriter.Log("OnDestroy");
     Instance = null;
     APIReady = false;
     foreach (Component child in children)
     {
         RSTLogWriter.Log("ResearchBodies Child Destroy for " + child.name);
         Destroy(child);
     }
     children.Clear();
     GameEvents.onGameSceneLoadRequested.Remove(OnGameSceneLoadRequested);
 }
Exemplo n.º 18
0
 public void Awake()
 {
     RSTLogWriter.Log("Awake");
     if (instance != null)
     {
         RSTLogWriter.Log("Singleton instance of Database already exists. Destroying this one");
         Destroy(this);
     }
     instance = this;
     DontDestroyOnLoad(this);
     GameEvents.onGameStatePostLoad.Add(onGameStatePostLoad);
     GameEvents.OnGameSettingsApplied.Add(ApplySettings);
     //GameEvents.onGameStateLoad.Add(ApplySettings);
 }
Exemplo n.º 19
0
        public void Start()
        {
            ConfigNode[] cfgs = GameDatabase.Instance.GetConfigNodes("RESEARCHBODIES");
            foreach (ConfigNode node in cfgs)
            {
                if (node.GetValue("loadAs") == "locale")
                {
                    Locale l = new Locale(node);
                    locales.Add(l);
                    RSTLogWriter.Log_Debug("Added locale \"{0}\"", l.LocaleId);
                }
            }

            if (File.Exists(PathcacheLocalePath))
            {
                StreamReader sr   = new StreamReader(PathcacheLocalePath);
                string       line = sr.ReadLine();
                foreach (Locale l in locales)
                {
                    if (l.LocaleId == line)
                    {
                        currentLocale = l;
                        RSTLogWriter.Log_Debug("Loaded {0}  from cache", l.LocaleFull);
                    }
                }
                sr.Close();
            }
            else
            {
                foreach (Locale l in locales)
                {
                    if (l.LocaleId == "en")
                    {
                        currentLocale = l;
                    }
                }
                TextWriter tw = new StreamWriter(PathcacheLocalePath);
                tw.Write(currentLocale.LocaleId);
                tw.Close();
            }

            if (locales.Count == 0)
            {
                RSTLogWriter.Log_Debug("No locale added !");
            }
            else
            {
                RSTLogWriter.Log_Debug("Added {0}  locales", locales.Count);
            }
        }
Exemplo n.º 20
0
 public void Awake()
 {
     RSTLogWriter.Log("Awake");
     if (instance != null)
     {
         RSTLogWriter.Log("Singleton instance of Database already exists. Destroying this one");
         Destroy(this);
     }
     instance = this;
     DontDestroyOnLoad(this);
     GameEvents.onGameStatePostLoad.Add(onGameStatePostLoad);
     GameEvents.OnGameSettingsApplied.Add(ApplySettings);
     //GameEvents.onGameStateLoad.Add(ApplySettings);
     BodyList     = new List <CelestialBody>();
     VesselsInSOI = new Dictionary <string, CBVesselSOIInfo>();
 }
Exemplo n.º 21
0
 internal static void LoadIconAssets()
 {
     try
     {
         LoadImageFromFile(ref ApplauncherIcon, "RBAppLaunchericon.png", PathIconsPath);
         LoadImageFromFile(ref ToolbarIcon, "RBToolBaricon.png", PathIconsPath);
         LoadImageFromFile(ref TooltipBox, "RBToolTipBox.png", PathIconsPath);
         LoadImageFromFile(ref BtnRedCross, "RBbtnRedCross.png", PathIconsPath);
         LoadImageFromFile(ref BtnResize, "RBbtnResize.png", PathIconsPath);
         LoadImageFromFile(ref BtnResizeHeight, "RBbtnResizeHeight.png", PathIconsPath);
         LoadImageFromFile(ref BtnResizeWidth, "RBbtnResizeWidth.png", PathIconsPath);
     }
     catch (Exception)
     {
         RSTLogWriter.Log("ResearchBodies Failed to Load Textures - are you missing a file?");
     }
 }
Exemplo n.º 22
0
 internal static void LoadIconAssets()
 {
     try
     {
         LoadImageFromFile(ref TooltipBox, "RBToolTipBox.png", PathIconsPath);
         LoadImageFromFile(ref ObsWinBgnd, "RBObservBackGround.png", PathIconsPath);
         LoadImageFromFile(ref BtnRedCross, "RBbtnRedCross.png", PathIconsPath);
         LoadImageFromFile(ref BtnResize, "RBbtnResize.png", PathIconsPath);
         LoadImageFromFile(ref BtnResizeHeight, "RBbtnResizeHeight.png", PathIconsPath);
         LoadImageFromFile(ref BtnResizeWidth, "RBbtnResizeWidth.png", PathIconsPath);
         LoadImageFromFile(ref SpriteObservatory, "SpriteObservPicker.png", PathIconsPath);
     }
     catch (Exception)
     {
         RSTLogWriter.Log("ResearchBodies Failed to Load Textures - are you missing a file?");
     }
 }
 public static void StopResearchPlan(CelestialBody cb)
 {
     if (Database.instance.CelestialBodies[cb].researchState >= 10)
     {
         if (Funding.Instance != null)
         {
             Funding.Instance.AddFunds(ResearchBodies.Instance.RBgameSettings.ResearchCost, TransactionReasons.None);
         }
         Database.instance.CelestialBodies[cb].researchState = 0;
         KeyValuePair <CelestialBody, CelestialBodyInfo> cbd =
             new KeyValuePair <CelestialBody, CelestialBodyInfo>(cb,
                                                                 Database.instance.CelestialBodies[cb]);
         ResearchBodiesController.instance.SetIndividualBodyDiscoveryLevel(cbd);
     }
     else
     {
         RSTLogWriter.Log(string.Format(Locales.currentLocale.Values["stopPlan_hasntBeenStarted"], cb.GetName()));
     }
 }
Exemplo n.º 24
0
        public static void StopResearchPlan(CelestialBody cb)
        {
            CelestialBody cbKey = Database.instance.ContainsBodiesKey(cb.bodyName);

            if (cbKey != null && Database.instance.CelestialBodies[cbKey].researchState >= 10)
            {
                if (Funding.Instance != null)
                {
                    Funding.Instance.AddFunds(Database.instance.RB_SettingsParms.ResearchCost, TransactionReasons.Progression);
                }
                Database.instance.CelestialBodies[cbKey].researchState = 0;
                KeyValuePair <CelestialBody, CelestialBodyInfo> cbd =
                    new KeyValuePair <CelestialBody, CelestialBodyInfo>(cbKey, Database.instance.CelestialBodies[cbKey]);
                ResearchBodiesController.instance.SetIndividualBodyDiscoveryLevel(cbd);
            }
            else
            {
                RSTLogWriter.Log(Localizer.Format("#autoLOC_RBodies_00016", cb.displayName));
            }
        }
Exemplo n.º 25
0
 public void ApplySettings()
 {
     RSTLogWriter.Log("Database ApplySettings");
     if (HighLogic.CurrentGame != null)
     {
         //if (RB_SettingsParms == null)
         RB_SettingsParms = HighLogic.CurrentGame.Parameters.CustomParams <ResearchBodies_SettingsParms>();
         if (ResearchBodies.Instance != null)
         {
             ResearchBodies.Enabled = RB_SettingsParms.RBEnabled;
         }
         chances                  = RB_SettingsParms.DiscoverySeed;
         allowTSlevel1            = RB_SettingsParms.Enabledtslvl1;
         RSTLogWriter.debuggingOn = HighLogic.CurrentGame.Parameters.CustomParams <ResearchBodies_SettingsParms>().DebugLogging;
     }
     else
     {
         RSTLogWriter.Log("Database Failed to apply settings - Fatal Error");
     }
 }
Exemplo n.º 26
0
 public override void OnSave(ConfigNode gameNode)
 {
     //APIReady = false;
     base.OnSave(gameNode);
     RBgameSettings.Save(gameNode);
     //foreach (Savable s in children.Where(c => c is Savable))
     //{
     //    s.Save(globalNode);
     //}
     //globalNode.Save(globalConfigFilename);
     if (RSTLogWriter.debuggingOn)
     {
         RSTLogWriter.Log_Debug("Scenario: " + HighLogic.LoadedScene + " OnSave: \n");
     }
     //    RSTLogWriter.Log_Debug("Scenario: " + HighLogic.LoadedScene + " OnSave: \n" + gameNode + "\n" + globalNode);
     else
     {
         RSTLogWriter.Log("ResearchBodies Scenario OnSave completed.");
     }
 }
Exemplo n.º 27
0
 public override void OnLoad(ConfigNode gameNode)
 {
     Database.instance.ResetBodiesforLoad();
     base.OnLoad(gameNode);
     RBgameSettings.Load(gameNode);
     if (Database.instance.RB_SettingsParms != null)
     {
         RSTLogWriter.debuggingOn = Database.instance.RB_SettingsParms.DebugLogging;
     }
     APIReady = true;
     if (RSTLogWriter.debuggingOn)
     {
         RSTLogWriter.Log_Debug("Scenario: " + HighLogic.LoadedScene + " OnLoad: \n ");
     }
     //    RSTLogWriter.Log_Debug("Scenario: " + HighLogic.LoadedScene + " OnLoad: \n " + gameNode + "\n" + globalNode);
     else
     {
         RSTLogWriter.Log("ResearchBodies Scenario Onload Completed.");
     }
     RSTLogWriter.Flush();
 }
Exemplo n.º 28
0
 public override bool RequirementMet(ConfiguredContract contract)
 {
     if (contract == null)
     {
         return(false);
     }
     if (contract.ContractState == Contract.State.Active)
     {
         return(true);
     }
     for (int i = 0; i < PSystemSetup.Instance.SpaceCenterFacilities.Length; i++)
     {
         if (PSystemSetup.Instance.SpaceCenterFacilities[i].name == facility)
         {
             int level = Mathf.RoundToInt(ScenarioUpgradeableFacilities.GetFacilityLevel(facility) + 1);
             return(level >= minLevel);
         }
     }
     RSTLogWriter.Log("Observatory NOT found....");
     return(false);
 }
Exemplo n.º 29
0
        public void Save(ConfigNode node)
        {
            ConfigNode settingsNode;

            if (node.HasNode(configNodeName))
            {
                settingsNode = node.GetNode(configNodeName);
                settingsNode.ClearData();
            }
            else
            {
                settingsNode = node.AddNode(configNodeName);
            }

            node.AddValue("lastTimeCheckedSOIs", lastTimeCheckedSOIs);

            foreach (var entry in Database.instance.CelestialBodies)
            {
                ConfigNode CBNode = entry.Value.Save(settingsNode);
                Utilities.Log_Debug("RBGameSettings Saving Entry = {0}", entry.Key.bodyName);
            }

            if (Database.instance.VesselsInSOI.Count > 0)
            {
                ConfigNode cbSOINode = settingsNode.AddNode("VESSELSINSOI");
                var        dictEnum  = Database.instance.VesselsInSOI.GetEnumerator();
                while (dictEnum.MoveNext())
                {
                    var        entry         = dictEnum.Current;
                    ConfigNode vesselSOINode = entry.Value.Save(cbSOINode);
                    Utilities.Log_Debug("RBGameSettings Saving Vessel in SOI Entry = {0}", entry.Key);
                }

                dictEnum.Dispose();
            }

            RSTLogWriter.Log("RBGameSettings Saving Complete");
            RSTLogWriter.Flush();
        }
Exemplo n.º 30
0
        public void Save(ConfigNode node)
        {
            ConfigNode settingsNode;

            if (node.HasNode(configNodeName))
            {
                settingsNode = node.GetNode(configNodeName);
                settingsNode.ClearData();
            }
            else
            {
                settingsNode = node.AddNode(configNodeName);
            }

            foreach (var entry in Database.instance.CelestialBodies)
            {
                ConfigNode CBNode = entry.Value.Save(settingsNode);
                Utilities.Log_Debug("RBGameSettings Saving Entry = {0}", entry.Key.bodyName);
            }
            RSTLogWriter.Log("RBGameSettings Saving Complete");
            RSTLogWriter.Flush();
        }