public void load() { Log.Info("StateFunding Mod Loading"); //AppLauncher = new StateFundingApplicationLauncher(); AppLauncher = OnSpaceCentre.Instance.gameObject.AddComponent <StateFundingApplicationLauncher>(); InitGovernments(); InitEvents(); VesselHelper.LoadAliases(); StateFundingGlobal.isLoaded = true; //StateFundingGlobal.Sun = Planetarium.fetch.Sun.GetName(); Log.Info("StateFunding Mod Loaded"); if (StateFundingGlobal.needsDataInit) { Log.Info("StateFunding performing data init"); var NewView = new NewInstanceConfigView(); NewView.OnCreate((InstanceData Inst) => { for (int i = 0; i < StateFundingGlobal.fetch.Governments.ToArray().Length; i++) { Government Gov = StateFundingGlobal.fetch.Governments.ToArray()[i]; if (Gov.name == Inst.govName) { Inst.Gov = Gov; break; } } HighLogic.CurrentGame.Parameters.CustomParams <StateFundingSettings>().budgetPeriodsPerYear = Inst.Gov.budgetPeriodsPerYear; StateFundingScenario.Instance.data = Inst; StateFundingScenario.Instance.isInit = true; StateFundingGlobal.needsDataInit = false; Log.Info("StateFunding data init completed"); ReviewMgr.CompleteReview(); }); } else { for (int i = 0; i < StateFundingGlobal.fetch.Governments.ToArray().Length; i++) { Government Gov = StateFundingGlobal.fetch.Governments.ToArray()[i]; if (Gov.name == StateFundingScenario.Instance.data.govName) { StateFundingScenario.Instance.data.Gov = Gov; } } } }
public void tick() { if (GameInstance != null) { if (GameInstance.getReviews().Length > 0) { // int year = (int)(TimeHelper.Quarters(Planetarium.GetUniversalTime())); int year = (int)(TimeHelper.Periods(Planetarium.GetUniversalTime(), HighLogic.CurrentGame.Parameters.CustomParams <StateFundingSettings>().budgetPeriodsPerYear)); if (year > ReviewMgr.LastReview().year) { Log.Info("Happy New Quarter!"); if ((HighLogic.CurrentGame.Parameters.CustomParams <StateFundingSettings>().stopWarpAtBudgetPeriod&& TimeWarp.fetch != null) || (HighLogic.CurrentGame.Parameters.CustomParams <StateFundingSettings>().stopWarpOnNewYear&& year % HighLogic.CurrentGame.Parameters.CustomParams <StateFundingSettings>().budgetPeriodsPerYear == 0)) { TimeWarp.fetch.CancelAutoWarp(); TimeWarp.SetRate(0, false); } ReviewMgr.CompleteReview(); } } } }