public static List <DebugMenuOption> TryPlaceOptionsForStackCount(int stackCount, bool direct) { List <DebugMenuOption> list = new List <DebugMenuOption>(); IEnumerable <ThingDef> enumerable = from def in DefDatabase <ThingDef> .AllDefs where DebugThingPlaceHelper.IsDebugSpawnable(def) && def.stackLimit >= stackCount select def; foreach (ThingDef item in enumerable) { ThingDef localDef = item; list.Add(new DebugMenuOption(localDef.LabelCap, DebugMenuOptionMode.Tool, delegate { DebugThingPlaceHelper.DebugSpawn(localDef, UI.MouseCell(), stackCount, direct); })); } if (stackCount == 1) { { foreach (ThingDef item2 in from def in DefDatabase <ThingDef> .AllDefs where def.Minifiable select def) { ThingDef localDef2 = item2; list.Add(new DebugMenuOption(localDef2.LabelCap + " (minified)", DebugMenuOptionMode.Tool, delegate { DebugThingPlaceHelper.DebugSpawn(localDef2, UI.MouseCell(), stackCount, direct); })); } return(list); } } return(list); }
public static IEnumerable <LocalTargetInfo> TargetsAt(Vector3 clickPos, TargetingParameters clickParams, bool thingsOnly = false) { List <Thing> clickableList = GenUI.ThingsUnderMouse(clickPos, 0.8f, clickParams); int i = 0; if (i < clickableList.Count) { yield return((LocalTargetInfo)clickableList[i]); /*Error: Unable to find new state assignment for yield return*/; } if (thingsOnly) { yield break; } IntVec3 cellTarg = UI.MouseCell(); if (!cellTarg.InBounds(Find.VisibleMap)) { yield break; } if (!clickParams.CanTarget(new TargetInfo(cellTarg, Find.VisibleMap, false))) { yield break; } yield return((LocalTargetInfo)cellTarg); /*Error: Unable to find new state assignment for yield return*/; }
internal void <> m__0() { IntVec3 intVec = UI.MouseCell(); Vector3 v = this.firstRectCorner.ToVector3Shifted(); Vector3 v2 = intVec.ToVector3Shifted(); if (v.x < v2.x) { v.x -= 0.5f; v2.x += 0.5f; } else { v.x += 0.5f; v2.x -= 0.5f; } if (v.z < v2.z) { v.z -= 0.5f; v2.z += 0.5f; } else { v.z += 0.5f; v2.z -= 0.5f; } Vector2 vector = v.MapToUIPosition(); Vector2 vector2 = v2.MapToUIPosition(); Widgets.DrawBox(new Rect(vector.x, vector.y, vector2.x - vector.x, vector2.y - vector.y), 3); }
private static void SpawnWorldPawn() { List <DebugMenuOption> list = new List <DebugMenuOption>(); PawnKindDef kLocal = default(PawnKindDef); Action <Pawn> act = delegate(Pawn p) { List <DebugMenuOption> list2 = new List <DebugMenuOption>(); foreach (PawnKindDef item in DefDatabase <PawnKindDef> .AllDefs.Where((PawnKindDef x) => x.race == p.def)) { kLocal = item; list2.Add(new DebugMenuOption(kLocal.defName, DebugMenuOptionMode.Tool, delegate { PawnGenerationRequest request = new PawnGenerationRequest(kLocal, p.Faction); PawnGenerator.RedressPawn(p, request); GenSpawn.Spawn(p, UI.MouseCell(), Find.CurrentMap); DebugTools.curTool = null; })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list2)); }; foreach (Pawn item2 in Find.WorldPawns.AllPawnsAlive) { Pawn pLocal = item2; list.Add(new DebugMenuOption(item2.LabelShort, DebugMenuOptionMode.Action, delegate { act(pLocal); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
private static void Rock21x21() { foreach (IntVec3 item in CellRect.CenteredOn(UI.MouseCell(), 5).ClipInsideMap(Find.CurrentMap)) { GenSpawn.Spawn(ThingDefOf.Granite, item, Find.CurrentMap); } }
private static void SpawnPawn() { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (PawnKindDef item in DefDatabase <PawnKindDef> .AllDefs.OrderBy((PawnKindDef kd) => kd.defName)) { PawnKindDef localKindDef = item; list.Add(new DebugMenuOption(localKindDef.defName, DebugMenuOptionMode.Tool, delegate { Faction faction = FactionUtility.DefaultFactionFrom(localKindDef.defaultFactionType); Pawn newPawn = PawnGenerator.GeneratePawn(localKindDef, faction); GenSpawn.Spawn(newPawn, UI.MouseCell(), Find.CurrentMap); if (faction != null && faction != Faction.OfPlayer) { Lord lord = null; if (newPawn.Map.mapPawns.SpawnedPawnsInFaction(faction).Any((Pawn p) => p != newPawn)) { lord = ((Pawn)GenClosest.ClosestThing_Global(newPawn.Position, newPawn.Map.mapPawns.SpawnedPawnsInFaction(faction), 99999f, (Thing p) => p != newPawn && ((Pawn)p).GetLord() != null)).GetLord(); } if (lord == null) { LordJob_DefendPoint lordJob = new LordJob_DefendPoint(newPawn.Position); lord = LordMaker.MakeNewLord(faction, lordJob, Find.CurrentMap); } lord.AddPawn(newPawn); } })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
private void RenderMouseAttachments() { IntVec3 c = UI.MouseCell(); if (!c.InBounds(map)) { return; } ThingDef thingDef = map.deepResourceGrid.ThingDefAt(c); if (thingDef != null) { int num = map.deepResourceGrid.CountAt(c); if (num > 0) { Vector2 vector = c.ToVector3().MapToUIPosition(); GUI.color = Color.white; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; float num2 = (UI.CurUICellSize() - 27f) / 2f; Rect rect = new Rect(vector.x + num2, vector.y - UI.CurUICellSize() + num2, 27f, 27f); Widgets.ThingIcon(rect, thingDef); Widgets.Label(new Rect(rect.xMax + 4f, rect.y, 999f, 29f), "DeepResourceRemaining".Translate(NamedArgumentUtility.Named(thingDef, "RESOURCE"), num.Named("COUNT"))); Text.Anchor = TextAnchor.UpperLeft; } } }
public static List <DebugMenuOption> TryPlaceOptionsForStackCount(int stackCount, bool direct) { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (ThingDef item in DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => IsDebugSpawnable(def) && def.stackLimit >= stackCount)) { ThingDef localDef2 = item; list.Add(new DebugMenuOption(localDef2.LabelCap, DebugMenuOptionMode.Tool, delegate { DebugSpawn(localDef2, UI.MouseCell(), stackCount, direct); })); } if (stackCount == 1) { foreach (ThingDef item2 in DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => def.Minifiable)) { ThingDef localDef = item2; list.Add(new DebugMenuOption(localDef.LabelCap + " (minified)", DebugMenuOptionMode.Tool, delegate { DebugSpawn(localDef, UI.MouseCell(), stackCount, direct); })); } return(list); } return(list); }
private static void FillWindow(Rect windowRect) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InspectRoomStats, KnowledgeAmount.FrameDisplayed); Text.Font = GameFont.Small; float num = 18f; bool flag = ShouldShowBeauty(); if (flag) { float beauty = BeautyUtility.AverageBeautyPerceptible(UI.MouseCell(), Find.CurrentMap); Rect rect = new Rect(18f, num, windowRect.width - 36f, 100f); GUI.color = BeautyDrawer.BeautyColor(beauty, 40f); Widgets.Label(rect, "BeautyHere".Translate() + ": " + beauty.ToString("F1")); num += 25f; } if (ShouldShowRoomStats()) { if (flag) { num += 5f; GUI.color = new Color(1f, 1f, 1f, 0.4f); Widgets.DrawLineHorizontal(18f, num, windowRect.width - 36f); GUI.color = Color.white; num += 8f; } Room room = UI.MouseCell().GetRoom(Find.CurrentMap, RegionType.Set_All); Rect rect2 = new Rect(18f, num, windowRect.width - 36f, 100f); GUI.color = Color.white; Widgets.Label(rect2, GetRoomRoleLabel(room)); num += 25f; Text.WordWrap = false; for (int i = 0; i < DefDatabase <RoomStatDef> .AllDefsListForReading.Count; i++) { RoomStatDef roomStatDef = DefDatabase <RoomStatDef> .AllDefsListForReading[i]; if (!roomStatDef.isHidden || DebugViewSettings.showAllRoomStats) { float stat = room.GetStat(roomStatDef); RoomStatScoreStage scoreStage = roomStatDef.GetScoreStage(stat); if (room.Role.IsStatRelated(roomStatDef)) { GUI.color = RelatedStatColor; } else { GUI.color = Color.gray; } Rect rect3 = new Rect(rect2.x, num, 100f, 23f); Widgets.Label(rect3, roomStatDef.LabelCap); Rect rect4 = new Rect(rect3.xMax + 35f, num, 50f, 23f); string label = roomStatDef.ScoreToString(stat); Widgets.Label(rect4, label); Rect rect5 = new Rect(rect4.xMax + 35f, num, 160f, 23f); Widgets.Label(rect5, (scoreStage != null) ? scoreStage.label : string.Empty); num += 25f; } } Text.WordWrap = true; } GUI.color = Color.white; }
private static void Transfer() { List <Thing> toTransfer = Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).ToList(); if (!toTransfer.Any()) { return; } List <DebugMenuOption> list = new List <DebugMenuOption>(); List <Map> maps = Find.Maps; for (int i = 0; i < maps.Count; i++) { Map map = maps[i]; if (map == Find.CurrentMap) { continue; } list.Add(new DebugMenuOption(map.ToString(), DebugMenuOptionMode.Action, delegate { for (int j = 0; j < toTransfer.Count; j++) { if (CellFinder.TryFindRandomCellNear(map.Center, map, Mathf.Max(map.Size.x, map.Size.z), (IntVec3 x) => !x.Fogged(map) && x.Standable(map), out var result)) { toTransfer[j].DeSpawn(); GenPlace.TryPlaceThing(toTransfer[j], result, map, ThingPlaceMode.Near); } else { Log.Error("Could not find spawn cell."); } } }));
private static void Take5000FlameDamage() { foreach (Thing item in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).ToList()) { item.TakeDamage(new DamageInfo(DamageDefOf.Flame, 5000f)); } }
private static void AttachFire() { foreach (Thing item in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).ToList()) { item.TryAttachFire(1f); } }
private static void DeleteRoof() { foreach (IntVec3 item in CellRect.CenteredOn(UI.MouseCell(), 1)) { Find.CurrentMap.roofGrid.SetRoof(item, null); } }
private static void BaseGen() { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (string item in DefDatabase <RuleDef> .AllDefs.Select((RuleDef x) => x.symbol).Distinct()) { string localSymbol = item; list.Add(new DebugMenuOption(item, DebugMenuOptionMode.Action, delegate { DebugTool tool = null; IntVec3 firstCorner = default(IntVec3); tool = new DebugTool("first corner...", delegate { firstCorner = UI.MouseCell(); DebugTools.curTool = new DebugTool("second corner...", delegate { IntVec3 second = UI.MouseCell(); CellRect rect = CellRect.FromLimits(firstCorner, second).ClipInsideMap(Find.CurrentMap); RimWorld.BaseGen.BaseGen.globalSettings.map = Find.CurrentMap; RimWorld.BaseGen.BaseGen.symbolStack.Push(localSymbol, rect); RimWorld.BaseGen.BaseGen.Generate(); DebugTools.curTool = tool; }, firstCorner); }); DebugTools.curTool = tool; })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
private static void MakeRoof() { foreach (IntVec3 item in CellRect.CenteredOn(UI.MouseCell(), 1)) { Find.CurrentMap.roofGrid.SetRoof(item, RoofDefOf.RoofConstructed); } }
public void DraggerOnGUI() { if (this.dragging && this.SelDes != null && this.SelDes.DragDrawMeasurements) { IntVec3 intVec = this.startDragCell - UI.MouseCell(); intVec.x = Mathf.Abs(intVec.x) + 1; intVec.z = Mathf.Abs(intVec.z) + 1; if (intVec.x >= 3) { Vector2 screenPos = (this.startDragCell.ToUIPosition() + UI.MouseCell().ToUIPosition()) / 2f; Vector2 vector = this.startDragCell.ToUIPosition(); screenPos.y = vector.y; this.DrawNumber(screenPos, intVec.x); } if (intVec.z >= 3) { Vector2 screenPos2 = (this.startDragCell.ToUIPosition() + UI.MouseCell().ToUIPosition()) / 2f; Vector2 vector2 = this.startDragCell.ToUIPosition(); screenPos2.x = vector2.x; this.DrawNumber(screenPos2, intVec.z); } Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; } }
private static void FillWindow(Rect windowRect) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InspectRoomStats, KnowledgeAmount.FrameDisplayed); Text.Font = GameFont.Small; float curY = 12f; int dividingLinesSeen = 0; if (ShouldShowBeauty()) { DrawDividingLineIfNecessary(); float beauty = BeautyUtility.AverageBeautyPerceptible(UI.MouseCell(), Find.CurrentMap); Rect rect = new Rect(22f, curY, windowRect.width - 24f - 10f, 100f); GUI.color = BeautyDrawer.BeautyColor(beauty, 40f); Widgets.Label(rect, "BeautyHere".Translate() + ": " + beauty.ToString("F1")); curY += 25f; } if (ShouldShowRoomStats()) { DrawDividingLineIfNecessary(); DoRoomInfo(UI.MouseCell().GetRoom(Find.CurrentMap, RegionType.Set_All), ref curY, windowRect); } GUI.color = Color.white; void DrawDividingLineIfNecessary() { dividingLinesSeen++; if (dividingLinesSeen > 1) { curY += 5f; GUI.color = new Color(1f, 1f, 1f, 0.4f); Widgets.DrawLineHorizontal(12f, curY, windowRect.width - 24f); GUI.color = Color.white; curY += 8f; } } }
private static void GeneratePawnsOfAllShapes() { Rot4[] array = new Rot4[4] { Rot4.North, Rot4.East, Rot4.South, Rot4.West }; IntVec3 intVec = UI.MouseCell(); foreach (BodyTypeDef allDef in DefDatabase <BodyTypeDef> .AllDefs) { IntVec3 intVec2 = intVec; Rot4[] array2 = array; for (int i = 0; i < array2.Length; i++) { Rot4 rot = array2[i]; PawnGenerationRequest request = new PawnGenerationRequest(Faction.OfPlayer.def.basicMemberKind, Faction.OfPlayer); request.ForceBodyType = allDef; Pawn pawn = PawnGenerator.GeneratePawn(request); string text = allDef.defName + "-" + rot.ToStringWord(); pawn.Name = new NameTriple(text, text, text); GenSpawn.Spawn(pawn, intVec2, Find.CurrentMap); pawn.apparel.DestroyAll(); pawn.drafter.Drafted = true; pawn.stances.SetStance(new Stance_Warmup(100000, intVec2 + rot.FacingCell, null)); intVec2 += IntVec3.South * 2; } intVec += IntVec3.East * 2; } }
public DebugTool(string label, Action clickAction, IntVec3 firstRectCorner) { this.label = label; this.clickAction = clickAction; onGUIAction = delegate { IntVec3 intVec = UI.MouseCell(); Vector3 v = firstRectCorner.ToVector3Shifted(); Vector3 v2 = intVec.ToVector3Shifted(); if (v.x < v2.x) { v.x -= 0.5f; v2.x += 0.5f; } else { v.x += 0.5f; v2.x -= 0.5f; } if (v.z < v2.z) { v.z -= 0.5f; v2.z += 0.5f; } else { v.z += 0.5f; v2.z -= 0.5f; } Vector2 vector = v.MapToUIPosition(); Vector2 vector2 = v2.MapToUIPosition(); Widgets.DrawBox(new Rect(vector.x, vector.y, vector2.x - vector.x, vector2.y - vector.y), 3); }; }
private static void Kill() { foreach (Thing item in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).ToList()) { item.Kill(); } }
private static void FlashSkygazeCell() { Pawn pawn = Find.CurrentMap.mapPawns.FreeColonists.First(); RCellFinder.TryFindSkygazeCell(UI.MouseCell(), pawn, out IntVec3 result); Find.CurrentMap.debugDrawer.FlashCell(result); MoteMaker.ThrowText(result.ToVector3Shifted(), Find.CurrentMap, "for " + pawn.Label, Color.white); }
private static void ClearArea21x21() { foreach (Thing item in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).ToList()) { _ = item; GenDebug.ClearArea(CellRect.CenteredOn(UI.MouseCell(), 10), Find.CurrentMap); } }
private static void PushHeatNeg1000() { foreach (IntVec3 allCell in Find.CurrentMap.AllCells) { _ = allCell; GenTemperature.PushHeat(UI.MouseCell(), Find.CurrentMap, -1000f); } }
private static void FuelRemove20Percent() { foreach (Thing item in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell())) { CompRefuelable compRefuelable = item.TryGetComp <CompRefuelable>(); compRefuelable?.ConsumeFuel(compRefuelable.Props.fuelCapacity * 0.2f); } }
private static void RandomizeColor() { foreach (Thing item in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell())) { if (item.TryGetComp <CompColorable>() != null) { item.SetColor(GenColor.RandomColorOpaque()); } } }
private static void FinishPlantGrowth() { foreach (Thing item in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell())) { Plant plant = item as Plant; if (plant != null) { plant.Growth = 1f; } } }
private static void BreakDown() { foreach (Thing item in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell())) { CompBreakdownable compBreakdownable = item.TryGetComp <CompBreakdownable>(); if (compBreakdownable != null && !compBreakdownable.BrokenDown) { compBreakdownable.DoBreakdown(); } } }
private static void Rot1Day() { foreach (Thing item in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell())) { CompRottable compRottable = item.TryGetComp <CompRottable>(); if (compRottable != null) { compRottable.RotProgress += 60000f; } } }
public void ProcessInputEvents() { if (this.CheckSelectedDesignatorValid()) { if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { if (this.selectedDesignator.DraggableDimensions == 0) { Designator designator = this.selectedDesignator; AcceptanceReport acceptanceReport = this.selectedDesignator.CanDesignateCell(UI.MouseCell()); if (acceptanceReport.Accepted) { designator.DesignateSingleCell(UI.MouseCell()); designator.Finalize(true); } else { Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.SilentInput); this.selectedDesignator.Finalize(false); } } else { this.dragger.StartDrag(); } Event.current.Use(); } if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { goto IL_00ec; } if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) { goto IL_00ec; } goto IL_0121; } return; IL_00ec: SoundDefOf.CancelMode.PlayOneShotOnCamera(null); this.Deselect(); this.dragger.EndDrag(); Event.current.Use(); TutorSystem.Notify_Event("ClearDesignatorSelection"); goto IL_0121; IL_0121: if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && this.dragger.Dragging) { this.selectedDesignator.DesignateMultiCell(this.dragger.DragCells); this.dragger.EndDrag(); Event.current.Use(); } }
private static bool ShouldShowBeauty() { if (!Find.PlaySettings.showBeauty) { return(false); } if (!UI.MouseCell().InBounds(Find.CurrentMap) || UI.MouseCell().Fogged(Find.CurrentMap)) { return(false); } return(UI.MouseCell().GetRoom(Find.CurrentMap) != null); }