public void Init()
        {
            if (!isInitialized)
            {
                this.isInitialized = true;

                //List<TabRecord> tabs = new List<TabRecord>(2);
                //Tabs selectedTab;
                if (Current.Game != null)
                {
                    this.currentStoryTeller = Current.Game.storyteller.def;

                    /*selectedTab = Tabs.ATS_Game;
                     * tabs.Add(new TabRecord(
                     *  Tabs.ATS_Game.ToString().Translate(),
                     *  delegate { selectedTab = Tabs.ATS_Game; },
                     *  selectedTab == Tabs.ATS_Game));*/
                }
                else
                {
                    this.currentStoryTeller = null;

                    /*selectedTab = Tabs.ATS_Global;
                     * tabs.Add(new TabRecord(
                     *  Tabs.ATS_Global.ToString().Translate(),
                     *  delegate { selectedTab = Tabs.ATS_Global; },
                     *  selectedTab == Tabs.ATS_Global));*/
                }

                if (Settings.GlobalOrbitalTrade == null)
                {
                    Settings.GlobalOrbitalTrade = StoryTellerDefaultsUtil.GetGlobalDefault(IncidentDefOf.OrbitalTraderArrival);
                }

                if (Settings.GameOrbitalTrade == null && StoryTellerUtil.HasOrbitalTraders())
                {
                    Settings.GameOrbitalTrade = new OnOffIncident
                    {
                        Incident  = Settings.GlobalOrbitalTrade.Incident,
                        Days      = Settings.GlobalOrbitalTrade.Days,
                        Instances = Settings.GlobalOrbitalTrade.Instances,
                    };
                }
            }
            this.MakeBuffers();
        }
        public static void Initialize()
        {
#if DEBUG
            Log.Warning("WorldComp.InitializeNewGame");
#endif
            if (StoryTellerUtil.HasOrbitalTraders())
            {
                if (Settings.GlobalOrbitalTrade == null)
                {
                    Settings.GlobalOrbitalTrade = StoryTellerDefaultsUtil.GetGlobalDefault(IncidentDefOf.OrbitalTraderArrival);
                }

                Settings.GameOrbitalTrade = new OnOffIncident
                {
                    Incident  = Settings.GlobalOrbitalTrade.Incident,
                    Days      = Settings.GlobalOrbitalTrade.Days,
                    Instances = Settings.GlobalOrbitalTrade.Instances,
                };

                StoryTellerUtil.ApplyOrbitalTrade(
                    Settings.GameOrbitalTrade.Days, Settings.GameOrbitalTrade.Instances);
            }
        }
        public override void ExposeData()
        {
            base.ExposeData();

            OnOffIncident gameOT = Settings.GameOrbitalTrade;

            Scribe_Deep.Look(ref gameOT, "AdjustableTradeShips.OrbitalTrader");

            Settings.GameOrbitalTrade = gameOT;

            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                if (Settings.GameOrbitalTrade == null)
                {
                    Initialize();
                }
                else
                {
                    StoryTellerUtil.ApplyOrbitalTrade(
                        Settings.GameOrbitalTrade.Days, Settings.GameOrbitalTrade.Instances);
                }
            }
        }
Beispiel #4
0
        public static void Initialize()
        {
#if DEBUG
            Log.Warning("WorldComp.InitializeNewGame");
#endif
            if (Settings.GlobalOrbitalTrade == null)
            {
                Settings.GlobalOrbitalTrade = StoryTellerDefaultsUtil.GetGlobalDefault(IncidentDefOf.OrbitalTraderArrival);
            }

            if (Settings.GameOrbitalTrade == null)
            {
                Settings.GameOrbitalTrade = new OnOffIncident()
                {
                    Incident  = Settings.GlobalOrbitalTrade.Incident,
                    Days      = Settings.GlobalOrbitalTrade.Days,
                    Instances = Settings.GlobalOrbitalTrade.Instances,
                };
            }

            if (Settings.GameWeightBuffer == null || Settings.GameWeightBuffer.Trim() == "")
            {
                Settings.GameWeight       = Settings.GlobalWeight;
                Settings.GameWeightBuffer = Settings.GlobalWeightBuffer;
            }

            if (StoryTellerUtil.HasOrbitalTraders())
            {
                StoryTellerUtil.ApplyOrbitalTrade(
                    Settings.GameOrbitalTrade.Days, Settings.GameOrbitalTrade.Instances);
            }
            else if (StoryTellerUtil.HasRandom())
            {
                StoryTellerUtil.ApplyRandom(IncidentCategoryDefOf.OrbitalVisitor, Settings.GameWeight);
            }
        }
        public override void DoSettingsWindowContents(Rect inRect)
        {
            this.Init();

            // Draw Contents
            // Global
            Text.Font = GameFont.Small;
            float y = 60;

            Widgets.Label(new Rect(0, y, 600, 40), "AdjustableTradeShips.Global".Translate());
            y += 40;

            Widgets.Label(new Rect(20, y, 600, 40), "AdjustableTradeShips.TradeShips".Translate());
            y += 40;


            NumberInput(40, y, ref Settings.GlobalOrbitalTrade.Instances, ref globalOtBuffers.Instances, MIN_ONOFF_VALUE, MAX_VALUE);

            Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.OTS".Translate());
            y += 40;

            NumberInput(40, y, ref Settings.GlobalOrbitalTrade.Days, ref globalOtBuffers.Days, MIN_ONOFF_VALUE, MAX_VALUE);

            Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.Days".Translate());
            y += 40;

            if (Widgets.ButtonText(new Rect(0, y, 100, 32), "AdjustableTradeShips.Default".Translate()))
            {
                OnOffIncident ooi = StoryTellerDefaultsUtil.GetGlobalDefault(IncidentDefOf.OrbitalTraderArrival);
                Settings.GlobalOrbitalTrade.Days      = ooi.Days;
                globalOtBuffers.Days                  = ooi.Days.ToString();
                Settings.GlobalOrbitalTrade.Instances = ooi.Instances;
                globalOtBuffers.Instances             = ooi.Instances.ToString();
            }

            if (Widgets.ButtonText(new Rect(200, y, 100, 32), "AdjustableTradeShips.Apply".Translate()))
            {
                StoryTellerUtil.ApplyOrbitalTrade(Settings.GlobalOrbitalTrade.Days, Settings.GlobalOrbitalTrade.Instances);
                Messages.Message("AdjustableTradeShips.GlobalSettingsApplied".Translate(), MessageTypeDefOf.PositiveEvent);
                this.globalOtBuffers = null;
            }
            y += 40;

            // Current Game
            if (Current.Game != null)
            {
                Widgets.DrawLineHorizontal(20, y, inRect.width - 40);
                y += 40;

                Widgets.Label(new Rect(0, y, 600, 40), "AdjustableTradeShips.CurrentGame".Translate());
                y += 40;

                if (StoryTellerUtil.HasOrbitalTraders() && Settings.GameOrbitalTrade != null)
                {
                    Widgets.Label(new Rect(20, y, 600, 40), "AdjustableTradeShips.TradeShips".Translate());
                    y += 40;

                    // Game Orbital Trade
                    NumberInput(40, y, ref Settings.GameOrbitalTrade.Instances, ref gameOtBuffers.Instances, MIN_ONOFF_VALUE, MAX_VALUE);

                    Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.OTS".Translate());
                    y += 40;

                    NumberInput(40, y, ref Settings.GameOrbitalTrade.Days, ref gameOtBuffers.Days, MIN_ONOFF_VALUE, MAX_VALUE);

                    Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.Days".Translate());
                    y += 40;

                    if (Widgets.ButtonText(new Rect(0, y, 100, 32), "AdjustableTradeShips.Default".Translate()))
                    {
                        if (StoryTellerDefaultsUtil.TryGetStoryTellerDefault(IncidentDefOf.OrbitalTraderArrival, out OnOffIncident ooi))
                        {
                            Settings.GameOrbitalTrade.Days      = ooi.Days;
                            gameOtBuffers.Days                  = ooi.Days.ToString();
                            Settings.GameOrbitalTrade.Instances = ooi.Instances;
                            gameOtBuffers.Instances             = ooi.Instances.ToString();
                        }
                        else
                        {
                            ooi = StoryTellerDefaultsUtil.GetGlobalDefault(IncidentDefOf.OrbitalTraderArrival);
                            Settings.GameOrbitalTrade.Days      = ooi.Days;
                            gameOtBuffers.Days                  = ooi.Days.ToString();
                            Settings.GameOrbitalTrade.Instances = ooi.Instances;
                            gameOtBuffers.Instances             = ooi.Instances.ToString();
                        }
                    }

                    if (Widgets.ButtonText(new Rect(200, y, 100, 32), "AdjustableTradeShips.Apply".Translate()))
                    {
                        StoryTellerUtil.ApplyOrbitalTrade(Settings.GameOrbitalTrade.Days, Settings.GameOrbitalTrade.Instances);
                        Messages.Message("AdjustableTradeShips.GameSettingsApplied".Translate(), MessageTypeDefOf.PositiveEvent);
                        this.gameOtBuffers = null;
                    }
                }
                else if (StoryTellerUtil.HasRandom())
                {
                    if (this.weightBuffer == null)
                    {
                        if (StoryTellerUtil.TryGetRandomWeight(IncidentCategoryDefOf.OrbitalVisitor, out float weight))
                        {
                            this.weight       = weight;
                            this.weightBuffer = weight.ToString();
                        }
                    }

                    NumberInput(20, y, "Orbital Visitor Weight", ref this.weight, ref this.weightBuffer, MIN_VALUE, MAX_VALUE);
                    y += 40;

                    if (Widgets.ButtonText(new Rect(0, y, 100, 32), "AdjustableTradeShips.Default".Translate()))
                    {
                        this.weight       = 1.0f;
                        this.weightBuffer = "1.0";
                    }

                    if (Widgets.ButtonText(new Rect(200, y, 100, 32), "AdjustableTradeShips.Apply".Translate()))
                    {
                        StoryTellerUtil.ApplyRandom(IncidentCategoryDefOf.OrbitalVisitor, this.weight);
                        Messages.Message("AdjustableTradeShips.GameSettingsApplied".Translate(), MessageTypeDefOf.PositiveEvent);
                        this.weightBuffer = this.weight.ToString();
                    }
                }
                else
                {
                    Widgets.Label(new Rect(20, y, 300, 32), Current.Game.storyteller.def.label + ": " + "AdjustableTradeShips.CannotModifyOrbitalTraderTimes".Translate());
                }
                y += 25;
            }
        }