Exemplo n.º 1
0
        private bool ChangeSizeCustomDrawer(Rect rect)
        {
            var world = Current.Game != null ? Current.Game.World : null;

            if (world == null)
            {
                if (Widgets.ButtonText(rect, "setting_changeMapSize_noWorld".Translate()))
                {
                    SoundDefOf.ClickReject.PlayOneShotOnCamera();
                }
            }
            else
            {
                var sizes = cachedMapSizes ?? (cachedMapSizes = RerollToolbox.GetAvailableMapSizes().Select(pair =>
                                                                                                            new KeyValuePair <int, string>(pair.Key, string.Format("{0}x{0}{1}", pair.Key, pair.Value != null ? " - " + pair.Value : null))
                                                                                                            ).ToList());
                var currentIndex = sizes.FindIndex(p => p.Key == world.info.initialMapSize.x);
                if (currentIndex < 0)
                {
                    currentIndex = 0;
                }
                if (Widgets.ButtonText(rect, sizes[currentIndex].Value))
                {
                    Find.WindowStack.Add(new FloatMenu(sizes.Select(p =>
                                                                    new FloatMenuOption(p.Value, () => world.info.initialMapSize = new IntVec3(p.Key, 1, p.Key))
                                                                    ).ToList()));
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        public static string WithCostSuffix(string translationKey, PaidOperationType type, int desiredPreviewsPage = 0)
        {
            var cost   = RerollToolbox.GetOperationCost(type, desiredPreviewsPage);
            var suffix = cost > 0 ? "Reroll2_costSuffix".Translate(cost.ToString("0.#")) : String.Empty;

            return(translationKey.Translate(suffix));
        }
Exemplo n.º 3
0
        internal void OnMapGenerated(Map map, MapGeneratorDef usedMapGenerator)
        {
            RerollToolbox.StoreGeneratedThingIdsInMapState(map);
            var mapState = RerollToolbox.GetStateForMap(map);

            mapState.UsedMapGenerator = usedMapGenerator;
            if (!rerollInProgress)
            {
                mapState.ResourceBalance = MaxResourceBalance;
            }
        }
Exemplo n.º 4
0
 public void RerollGeysers()
 {
     geyserReroll.DoReroll();
     if (PaidRerollsSetting)
     {
         RerollToolbox.SubtractResourcePercentage(Find.CurrentMap, Resources.Settings.MapRerollSettings.geyserRerollCost);
     }
     if (OnGeysersRerolled != null)
     {
         OnGeysersRerolled();
     }
 }
Exemplo n.º 5
0
        public void DoReroll()
        {
            var map    = Find.CurrentMap;
            var logger = MapRerollController.Instance.Logger;

            if (RerollInProgress)
            {
                logger.Error("Cannot reroll geysers- reroll already in progress");
                return;
            }
            if (map == null)
            {
                logger.Error("No visible map- cannot reroll geysers");
                return;
            }
            var state = RerollToolbox.GetStateForMap(map);

            if (state.UsedMapGenerator == null)
            {
                logger.Error($"Cannot reroll geysers: map {map} does not have a recorded MapGeneratorDef");
                return;
            }
            var geyserDef  = ThingDefOf.SteamGeyser;
            var genStepDef = state.UsedMapGenerator.genSteps.FirstOrDefault(g => g.genStep is GenStep_ScatterThings &&
                                                                            (g.genStep as GenStep_ScatterThings).thingDef == geyserDef);

            if (genStepDef == null)
            {
                logger.Error($"Cannot reroll geysers: map generator {state.UsedMapGenerator} does not have a geyser GenStep");
                return;
            }
            drawnArrows.Clear();
            activeSteamEffects.Clear();
            var geysersOnMap = map.listerThings.AllThings.Where(t => t.def == geyserDef);
            var oldGeysers   = new HashSet <Thing>(geysersOnMap);

            genStepDef.genStep.Generate(map, new GenStepParams());
            var newGeysers = map.listerThings.AllThings.Where(t => t.def == geyserDef).Except(oldGeysers);

            BeginGeyserSpawning(oldGeysers, newGeysers, map);
        }
Exemplo n.º 6
0
        public override void MapLoaded(Map map)
        {
            geyserReroll = new GeyserRerollTool();
            if (rerollInProgress)
            {
                RerollToolbox.KillMapIntroDialog();
                if (OnMapRerolled != null)
                {
                    OnMapRerolled();
                }
            }

            if (pauseScheduled)
            {
                pauseScheduled = false;
                HugsLibController.Instance.DoLater.DoNextUpdate(() => Find.TickManager.CurTimeSpeed = TimeSpeed.Paused);
            }

            RerollToolbox.TryStopPawnVomiting(map);
            uiController.MapLoaded(rerollInProgress);
            rerollInProgress = false;
        }
Exemplo n.º 7
0
 public void RerollMap(string seed)
 {
     rerollInProgress = true;
     RerollToolbox.DoMapReroll(seed);
 }