// Verse.Dialog_DebugActionsMenu public static void DoListingItems_World_PostFix(Dialog_DebugActionsMenu __instance) { //Traverse.Create(__instance).Method("DoLabel", new object[] { "Tools - Spawning" }); AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DoLabel").Invoke(__instance, new object[] { "Tools - Spawning" }); AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolWorld").Invoke(__instance, new object[] { "Place Road", new Action(() => //Traverse.Create(__instance).Method("DebugToolWorld", new object[] {"Place Road", new Action(delegate { int num = GenWorld.MouseTile(false); //Tile tile = Find.WorldGrid[num]; //GlobalTargetInfo startInfo = default(GlobalTargetInfo); GlobalTargetInfo endInfo = default(GlobalTargetInfo); //Find.WorldTargeter.StopTargeting(); //Find.WorldTargeter.BeginTargeting(delegate(GlobalTargetInfo t) //{ // startInfo = t; // return true; //}, // true, null, false, null, delegate(GlobalTargetInfo target) // { // return "Start Road Here."; // }); //Find.WorldTargeter.StopTargeting(); DebugTools.curTool = null; Find.WorldTargeter.BeginTargeting(delegate(GlobalTargetInfo s) { endInfo = s; Find.World.grid.OverlayRoad(num, endInfo.Tile, RoadDefOf.DirtRoad); Find.World.renderer.RegenerateAllLayersNow(); return(true); }, true, null, false, null, delegate(GlobalTargetInfo target) { return("End Road Here."); }); }) }); }
protected override void DoListingItems() { base.DoListingItems(); #if DEBUG if (WorldRendererUtility.WorldRenderedNow) { DoGap(); DoLabel("Tools - MFI"); base.DebugToolWorld("Spawn pirate base", () => { int tile = GenWorld.MouseTile(false); if (tile < 0 || Find.World.Impassable(tile)) { Messages.Message("Impassable", MessageTypeDefOf.RejectInput, false); } else { Faction faction = (from x in Find.FactionManager.AllFactions where !x.def.hidden && !x.defeated && !x.IsPlayer && x.HostileTo(other: Faction.OfPlayer) && x.def.permanentEnemy select x).First(); Settlement factionBase = (Settlement)WorldObjectMaker.MakeWorldObject(def: WorldObjectDefOf.Settlement); factionBase.SetFaction(newFaction: faction); factionBase.Tile = tile; factionBase.Name = SettlementNameGenerator.GenerateSettlementName(factionBase: factionBase); Find.WorldObjects.Add(o: factionBase); } } ); DebugToolWorld("Test annual Expo", new AnnualExpoDialogue(null, null, null, Find.FactionManager.RandomAlliedFaction()).DebugLogChances); } #endif }
private static void SpawnScout() { int tile = GenWorld.MouseTile(); if (tile < 0 || Find.World.Impassable(tile)) { Messages.Message("Impassable", MessageTypeDefOf.RejectInput, historical: false); } else { RimWorld.Planet.Settlement s = Find.WorldObjects.SettlementAt(tile); if (s != null) { RimWarSettlementComp rwsc = WorldUtility.GetRimWarSettlementAtTile(tile); if (rwsc != null) { WorldUtility.Get_WCPT().AttemptScoutMission(WorldUtility.GetRimWarDataForFaction(s.Faction), s, rwsc, false, false, true); } } } }
public static bool HandleClicks(WorldSelector __instance) { if (Event.current.type == EventType.MouseDown) { if (Event.current.button == 1 && __instance.SelectedObjects.Count > 0) { bool found = false; foreach (var ship in __instance.SelectedObjects.OfType <AirShipWorldObject>()) { found = true; ship.ClickedNewTile(GenWorld.MouseTile()); } if (found) { Event.current.Use(); return(false); } } } return(true); }
public static void SendCmd(DebugSource source, int hash, Map map) { var writer = new LoggingByteWriter(); writer.Log.Node($"Debug tool {source}, map {map.ToStringSafe()}"); int cursorX = 0, cursorZ = 0; if (map != null) { cursorX = UI.MouseCell().x; cursorZ = UI.MouseCell().z; } else { cursorX = GenWorld.MouseTile(false); } writer.WriteInt32(Multiplayer.session.playerId); writer.WriteInt32((int)source); writer.WriteInt32(cursorX); writer.WriteInt32(cursorZ); writer.WriteInt32(hash); if (map != null) { writer.WriteInt32(Find.Selector.SingleSelectedThing?.thingIDNumber ?? -1); } else { writer.WriteInt32(Find.WorldSelector.SingleSelectedObject?.ID ?? -1); } Multiplayer.WriterLog.AddCurrentNode(writer); var mapId = map?.uniqueID ?? ScheduledCommand.Global; Multiplayer.Client.SendCommand(CommandType.DebugTools, mapId, writer.ToArray()); }
private void DoTileTooltips() { if (!Mouse.IsInputBlockedNow) { int num = GenWorld.MouseTile(snapToExpandableWorldObjects: true); if (num != -1) { int num2 = 0; while (true) { if (num2 >= paths.Count) { return; } if (paths[num2].NodesReversed.Contains(num)) { break; } num2++; } string str = GetTileTip(num, num2); Text.Font = GameFont.Small; Vector2 size = Text.CalcSize(str); size.x += 20f; size.y += 20f; Vector2 mouseAttachedWindowPos = GenUI.GetMouseAttachedWindowPos(size.x, size.y); Rect rect = new Rect(mouseAttachedWindowPos, size); Find.WindowStack.ImmediateWindow(1859615246, rect, WindowLayer.Super, delegate { Text.Font = GameFont.Small; Rect rect2 = rect.AtZero().ContractedBy(10f); Widgets.Label(rect2, str); }); } } }
protected virtual GlobalTargetInfo CurrentTargetUnderMouse() { if (!IsTargeting) { return(GlobalTargetInfo.Invalid); } List <WorldObject> list = GenWorldUI.WorldObjectsUnderMouse(Verse.UI.MousePositionOnUI); if (list.Any()) { return(list[0]); } if (!canTargetTiles) { return(GlobalTargetInfo.Invalid); } int num = GenWorld.MouseTile(false); if (num >= 0) { return(new GlobalTargetInfo(num)); } return(GlobalTargetInfo.Invalid); }
public void WorldRoutePlannerOnGUI() { if (this.active) { if (KeyBindingDefOf.Cancel.KeyDownEvent) { if (this.currentFormCaravanDialog != null) { Find.WindowStack.Add(this.currentFormCaravanDialog); } else { SoundDefOf.Tick_Low.PlayOneShotOnCamera(null); } this.Stop(); Event.current.Use(); } else { GenUI.DrawMouseAttachment(WorldRoutePlanner.MouseAttachment); if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { Caravan caravan = Find.WorldSelector.SelectableObjectsUnderMouse().FirstOrDefault <WorldObject>() as Caravan; int tile = (caravan == null) ? GenWorld.MouseTile(true) : caravan.Tile; if (tile >= 0) { RoutePlannerWaypoint waypoint = this.MostRecentWaypointAt(tile); if (waypoint != null) { if (waypoint == this.waypoints[this.waypoints.Count - 1]) { this.TryRemoveWaypoint(waypoint, true); } else { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption("AddWaypoint".Translate(), delegate() { this.TryAddWaypoint(tile, true); }, MenuOptionPriority.Default, null, null, 0f, null, null)); list.Add(new FloatMenuOption("RemoveWaypoint".Translate(), delegate() { this.TryRemoveWaypoint(waypoint, true); }, MenuOptionPriority.Default, null, null, 0f, null, null)); Find.WindowStack.Add(new FloatMenu(list)); } } else { this.TryAddWaypoint(tile, true); } Event.current.Use(); } } this.DoRouteDetailsBox(); if (!this.DoChooseRouteButton()) { this.DoTileTooltips(); } } } }
private void SelectUnderMouse(bool canSelectTile = true) { if (Current.ProgramState == ProgramState.Playing) { Thing thing = Find.ColonistBar.ColonistOrCorpseAt(UI.MousePositionOnUIInverted); Pawn pawn = thing as Pawn; if (thing != null && (pawn == null || !pawn.IsCaravanMember())) { if (thing.Spawned) { CameraJumper.TryJumpAndSelect(thing); } else { CameraJumper.TryJump(thing); } return; } } bool clickedDirectlyOnCaravan; bool usedColonistBar; List <WorldObject> list = SelectableObjectsUnderMouse(out clickedDirectlyOnCaravan, out usedColonistBar).ToList(); if (usedColonistBar || (clickedDirectlyOnCaravan && list.Count >= 2)) { canSelectTile = false; } if (list.Count == 0) { if (!ShiftIsHeld) { ClearSelection(); if (canSelectTile) { selectedTile = GenWorld.MouseTile(); } } } else if (list.Where((WorldObject obj) => selected.Contains(obj)).FirstOrDefault() != null) { if (!ShiftIsHeld) { int tile = (canSelectTile ? GenWorld.MouseTile() : (-1)); SelectFirstOrNextFrom(list, tile); return; } foreach (WorldObject item in list) { if (selected.Contains(item)) { Deselect(item); } } } else { if (!ShiftIsHeld) { ClearSelection(); } Select(list[0]); } }
public void WorldRoutePlannerOnGUI() { if (!active) { return; } if (KeyBindingDefOf.Cancel.KeyDownEvent) { if (currentFormCaravanDialog != null) { Find.WindowStack.Add(currentFormCaravanDialog); } else { SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } Stop(); Event.current.Use(); return; } GenUI.DrawMouseAttachment(MouseAttachment); if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { int tile = (Find.WorldSelector.SelectableObjectsUnderMouse().FirstOrDefault() as Caravan)?.Tile ?? GenWorld.MouseTile(snapToExpandableWorldObjects: true); if (tile >= 0) { RoutePlannerWaypoint waypoint = MostRecentWaypointAt(tile); if (waypoint != null) { if (waypoint == waypoints[waypoints.Count - 1]) { TryRemoveWaypoint(waypoint); } else { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption("AddWaypoint".Translate(), delegate { TryAddWaypoint(tile); })); list.Add(new FloatMenuOption("RemoveWaypoint".Translate(), delegate { TryRemoveWaypoint(waypoint); })); Find.WindowStack.Add(new FloatMenu(list)); } } else { TryAddWaypoint(tile); } Event.current.Use(); } } DoRouteDetailsBox(); if (!DoChooseRouteButton()) { DoTileTooltips(); } }
private void SelectUnderMouse(bool canSelectTile = true) { if (Current.ProgramState == ProgramState.Playing) { Thing thing = Find.ColonistBar.ColonistOrCorpseAt(UI.MousePositionOnUIInverted); Pawn pawn = thing as Pawn; if (thing != null && (pawn == null || !pawn.IsCaravanMember())) { if (thing.Spawned) { CameraJumper.TryJumpAndSelect(thing); } else { CameraJumper.TryJump(thing); } return; } } bool flag = default(bool); bool flag2 = default(bool); List <WorldObject> list = this.SelectableObjectsUnderMouse(out flag, out flag2).ToList(); if (flag2 || (flag && list.Count >= 2)) { canSelectTile = false; } if (list.Count == 0) { if (!this.ShiftIsHeld) { this.ClearSelection(); if (canSelectTile) { this.selectedTile = GenWorld.MouseTile(false); } } } else { WorldObject worldObject = (from obj in list where this.selected.Contains(obj) select obj).FirstOrDefault(); if (worldObject != null) { if (!this.ShiftIsHeld) { int tile = (!canSelectTile) ? (-1) : GenWorld.MouseTile(false); this.SelectFirstOrNextFrom(list, tile); } else { foreach (WorldObject item in list) { if (this.selected.Contains(item)) { this.Deselect(item); } } } } else { if (!this.ShiftIsHeld) { this.ClearSelection(); } this.Select(list[0], true); } } }
private void HandleWorldClicks() { if (Event.current.type == EventType.MouseDown) { if (Event.current.button == 0) { if (Event.current.clickCount == 1) { this.dragBox.active = true; this.dragBox.start = UI.MousePositionOnUIInverted; } if (Event.current.clickCount == 2) { this.SelectAllMatchingObjectUnderMouseOnScreen(); } Event.current.Use(); } if (Event.current.button == 1) { if (this.selected.Count > 0) { if (this.selected.Count == 1 && this.selected[0] is Caravan) { Caravan caravan = (Caravan)this.selected[0]; if (caravan.IsPlayerControlled) { if (!FloatMenuMakerWorld.TryMakeFloatMenu(caravan)) { this.AutoOrderToTile(caravan, GenWorld.MouseTile(false)); } } } else { for (int i = 0; i < this.selected.Count; i++) { Caravan caravan2 = this.selected[i] as Caravan; if (caravan2 != null && caravan2.IsPlayerControlled) { this.AutoOrderToTile(caravan2, GenWorld.MouseTile(false)); } } } Event.current.Use(); } } } if (Event.current.rawType == EventType.MouseUp) { if (Event.current.button == 0) { if (this.dragBox.active) { this.dragBox.active = false; if (!this.dragBox.IsValid) { this.SelectUnderMouse(true); } else { this.SelectInsideDragBox(); } } } Event.current.Use(); } }
public void WorldRoutePlannerOnGUI() { if (this.active) { if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) { if (this.currentFormCaravanDialog != null) { Find.WindowStack.Add(this.currentFormCaravanDialog); } else { SoundDefOf.TickLow.PlayOneShotOnCamera(null); } this.Stop(); Event.current.Use(); } else { GenUI.DrawMouseAttachment(WorldRoutePlanner.MouseAttachment); if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { Caravan caravan = Find.WorldSelector.SelectableObjectsUnderMouse().FirstOrDefault() as Caravan; int tile = (caravan == null) ? GenWorld.MouseTile(true) : caravan.Tile; if (tile >= 0) { RoutePlannerWaypoint waypoint = this.MostRecentWaypointAt(tile); if (waypoint != null) { if (waypoint == this.waypoints[this.waypoints.Count - 1]) { this.TryRemoveWaypoint(waypoint, true); } else { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption("AddWaypoint".Translate(), delegate { this.TryAddWaypoint(tile, true); }, MenuOptionPriority.Default, null, null, 0f, null, null)); list.Add(new FloatMenuOption("RemoveWaypoint".Translate(), delegate { this.TryRemoveWaypoint(waypoint, true); }, MenuOptionPriority.Default, null, null, 0f, null, null)); Find.WindowStack.Add(new FloatMenu(list)); } } else { this.TryAddWaypoint(tile, true); } Event.current.Use(); } } float num = (float)UI.screenWidth; Vector2 bottomWindowSize = WorldRoutePlanner.BottomWindowSize; double x = (num - bottomWindowSize.x) / 2.0; float num2 = (float)UI.screenHeight; Vector2 bottomWindowSize2 = WorldRoutePlanner.BottomWindowSize; double y = num2 - bottomWindowSize2.y - 45.0; Vector2 bottomWindowSize3 = WorldRoutePlanner.BottomWindowSize; float x2 = bottomWindowSize3.x; Vector2 bottomWindowSize4 = WorldRoutePlanner.BottomWindowSize; Rect rect = new Rect((float)x, (float)y, x2, bottomWindowSize4.y); if (Current.ProgramState == ProgramState.Entry) { rect.y -= 22f; } Find.WindowStack.ImmediateWindow(1373514241, rect, WindowLayer.Dialog, delegate { if (this.active) { GUI.color = Color.white; Text.Anchor = TextAnchor.UpperCenter; Text.Font = GameFont.Small; float num3 = 6f; if (this.waypoints.Count >= 2) { Widgets.Label(new Rect(0f, num3, rect.width, 25f), "RoutePlannerEstTimeToFinalDest".Translate(this.GetTicksToWaypoint(this.waypoints.Count - 1).ToStringTicksToDays("0.#"))); } else if (this.cantRemoveFirstWaypoint) { Widgets.Label(new Rect(0f, num3, rect.width, 25f), "RoutePlannerAddOneOrMoreWaypoints".Translate()); } else { Widgets.Label(new Rect(0f, num3, rect.width, 25f), "RoutePlannerAddTwoOrMoreWaypoints".Translate()); } num3 = (float)(num3 + 20.0); if (this.CaravanPawns.NullOrEmpty()) { GUI.color = new Color(0.8f, 0.6f, 0.6f); Widgets.Label(new Rect(0f, num3, rect.width, 25f), "RoutePlannerUsingAverageTicksPerMoveWarning".Translate()); } else if (this.currentFormCaravanDialog == null && this.CaravanAtTheFirstWaypoint != null) { GUI.color = Color.gray; Widgets.Label(new Rect(0f, num3, rect.width, 25f), "RoutePlannerUsingTicksPerMoveOfCaravan".Translate(this.CaravanAtTheFirstWaypoint.LabelCap)); } num3 = (float)(num3 + 20.0); GUI.color = Color.gray; Widgets.Label(new Rect(0f, num3, rect.width, 25f), "RoutePlannerPressRMBToAddAndRemoveWaypoints".Translate()); num3 = (float)(num3 + 20.0); if (this.currentFormCaravanDialog != null) { Widgets.Label(new Rect(0f, num3, rect.width, 25f), "RoutePlannerPressEscapeToReturnToCaravanFormationDialog".Translate()); } else { Widgets.Label(new Rect(0f, num3, rect.width, 25f), "RoutePlannerPressEscapeToExit".Translate()); } num3 = (float)(num3 + 20.0); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; } }, true, false, 1f); } } }
public override void WindowUpdate() { if (Input.GetKeyDown(KeyCode.Mouse0)) { if (setEdgeRiver) { if (edgeTiles.Count == 0) { return; } if (selectedRiver == null) { return; } int tile = GenWorld.MouseTile(); if (edgeTiles.Contains(tile)) { Find.WorldGrid.OverlayRiver(edgeTile, tile, selectedRiver); } edgeTiles.Clear(); setEdgeRiver = false; worldUpdater.UpdateLayer(WorldEditor.Editor.Layers["WorldLayer_Rivers"]); } } if (PaintMode) { if (GenWorld.MouseTile() < 0) { return; } if (selectedRiver != null) { if (Input.GetKeyDown(KeyCode.Mouse0)) { riverId1 = GenWorld.MouseTile().ToString(); Messages.Message($"Start river: {riverId1}, select second point", MessageTypeDefOf.NeutralEvent, false); } if (Input.GetKeyDown(KeyCode.Mouse1)) { riverId2 = GenWorld.MouseTile().ToString(); Messages.Message($"End river: {riverId2}", MessageTypeDefOf.NeutralEvent, false); TryPrintRiver(); } } if (selectedRoad != null) { if (Input.GetKeyDown(KeyCode.Mouse0)) { roadId1 = GenWorld.MouseTile().ToString(); Messages.Message($"Start road: {roadId1}, select second point", MessageTypeDefOf.NeutralEvent, false); } if (Input.GetKeyDown(KeyCode.Mouse1)) { roadId2 = GenWorld.MouseTile().ToString(); Messages.Message($"End road: {roadId2}", MessageTypeDefOf.NeutralEvent, false); TryPrintRoad(); } } } }