Пример #1
0
        public override void ExposeData()
        {
            if (WorldSettings == null)
            {
                WorldSettings = new WorldSettings();
            }
            if (MapSettings == null)
            {
                MapSettings = new MapSettings();
            }

            base.ExposeData();
            Scribe_Deep.Look(ref WorldSettings, "WorldSettings");
            Scribe_Deep.Look(ref MapSettings, "MapSettings");

            if (Scribe.mode == LoadSaveMode.Saving)
            {
                CurrentSettings.ApplySettings(cgFieldValues);
            }

            DefsUtil.Restore();
        }
        private static void Init()
        {
            if (weighted != null && weighted.Count > 0)
            {
                return;
            }

            WorldSettings.Init();

            weighted = new List <WeightedStoneType>(WorldSettings.Commonalities.Count);

            foreach (var c in WorldSettings.Commonalities)
            {
                if (WorldSettings.CommonalityRandom)
                {
                    var i = Rand.RangeInclusive(0, 10);
                    weighted.Add(new WeightedStoneType(c.StoneDef, i));
                }
                else
                {
                    weighted.Add(new WeightedStoneType(c.StoneDef, c.Commonality));
                }
            }
        }
Пример #3
0
        public void DoWindowContents(Rect rect)
        {
            if (WorldSettings == null)
            {
                WorldSettings = new WorldSettings();
            }
            if (MapSettings == null)
            {
                MapSettings = new MapSettings();
            }
            if (CurrentSettings == null)
            {
                CurrentSettings = new CurrentSettings();
            }

            string label;

            if (toShow == ToShow.None)
            {
                label = "WorldChooseButton".Translate();
            }
            else if (toShow == ToShow.World)
            {
                label = WorldSettings.Name;
            }
            else
            {
                label = MapSettings.Name;
            }

            if (Widgets.ButtonText(new Rect(rect.x, rect.y, 300, 28), label))
            {
                List <FloatMenuOption> l = new List <FloatMenuOption>(3)
                {
                    new FloatMenuOption(WorldSettings.Name, () => { toShow = ToShow.World; }),
                    new FloatMenuOption(MapSettings.Name, () => { toShow = ToShow.Map; })
                };
                if (Current.Game != null)
                {
                    l.Add(new FloatMenuOption(CurrentSettings.Name, () => { toShow = ToShow.CurrentGame; }));
                }
                Find.WindowStack.Add(new FloatMenu(l));
            }
            rect.y += 30f;
            if (toShow == ToShow.World)
            {
                if (wsFieldValues == null)
                {
                    wsFieldValues = WorldSettings.GetFieldValues();
                }
                WorldSettings.DoWindowContents(rect, wsFieldValues);
            }
            else if (toShow == ToShow.Map)
            {
                if (msFieldValues == null)
                {
                    msFieldValues = MapSettings.GetFieldValues();
                }
                MapSettings.DoWindowContents(rect, msFieldValues);
            }
            else if (toShow == ToShow.CurrentGame)
            {
                if (cgFieldValues == null)
                {
                    cgFieldValues = CurrentSettings.GetFieldValues();
                }
                CurrentSettings.DoWindowContents(rect, cgFieldValues);
            }
        }