private static void SpawnWorldObject() { int tile = GenWorld.MouseTile(); if (tile < 0 || Find.World.Impassable(tile)) { Messages.Message("Impassable", MessageTypeDefOf.RejectInput, historical: false); return; } List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (WorldObjectDef allDef in DefDatabase <WorldObjectDef> .AllDefs) { WorldObjectDef localDef = allDef; Action action = null; action = delegate { WorldObject worldObject = WorldObjectMaker.MakeWorldObject(localDef); worldObject.Tile = tile; Find.WorldObjects.Add(worldObject); }; list.Add(new DebugMenuOption(localDef.defName, DebugMenuOptionMode.Action, action)); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
private static void Add1000RWP() { 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 && s.Faction != Faction.OfPlayer) { RimWarSettlementComp rwsc = WorldUtility.GetRimWarSettlementAtTile(tile); if (rwsc != null && rwsc.parent.Faction != Faction.OfPlayer) { rwsc.RimWarPoints += 1000; } } WarObject rwo = Find.WorldObjects.WorldObjectAt(tile, RimWarDefOf.RW_WarObject) as WarObject; if (rwo != null) { rwo.RimWarPoints += 1000; } } }
private void DoTileTooltips() { if (Mouse.IsInputBlockedNow) { return; } int num = GenWorld.MouseTile(snapToExpandableWorldObjects: true); if (num == -1) { return; } for (int i = 0; i < paths.Count; i++) { if (paths[i].NodesReversed.Contains(num)) { string str = GetTileTip(num, i); 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; Widgets.Label(rect.AtZero().ContractedBy(10f), str); }); break; } } }
public static void SendCmd(DebugSource source, int hash, Map map) { var writer = new ByteWriter(); 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); } var mapId = map?.uniqueID ?? ScheduledCommand.Global; Multiplayer.Client.SendCommand(CommandType.DebugTools, mapId, writer.ToArray()); }
private void HandleWorldClicks() { if (Event.current.type == EventType.MouseDown) { if (Event.current.button == 0) { if (Event.current.clickCount == 1) { dragBox.active = true; dragBox.start = UI.MousePositionOnUIInverted; } if (Event.current.clickCount == 2) { SelectAllMatchingObjectUnderMouseOnScreen(); } Event.current.Use(); } if (Event.current.button == 1 && selected.Count > 0) { if (selected.Count == 1 && selected[0] is Caravan) { Caravan caravan = (Caravan)selected[0]; if (caravan.IsPlayerControlled && !FloatMenuMakerWorld.TryMakeFloatMenu(caravan)) { AutoOrderToTile(caravan, GenWorld.MouseTile()); } } else { for (int i = 0; i < selected.Count; i++) { Caravan caravan2 = selected[i] as Caravan; if (caravan2 != null && caravan2.IsPlayerControlled) { AutoOrderToTile(caravan2, GenWorld.MouseTile()); } } } Event.current.Use(); } } if (Event.current.rawType != EventType.MouseUp) { return; } if (Event.current.button == 0 && dragBox.active) { dragBox.active = false; if (!dragBox.IsValid) { SelectUnderMouse(); } else { SelectInsideDragBox(); } } Event.current.Use(); }
private static void DestroySite() { int tileID = GenWorld.MouseTile(); foreach (WorldObject item in Find.WorldObjects.ObjectsAt(tileID).ToList()) { item.Destroy(); } }
private static void SpawnSiteWithPoints() { int tile = GenWorld.MouseTile(); if (tile < 0 || Find.World.Impassable(tile)) { Messages.Message("Impassable", MessageTypeDefOf.RejectInput, historical: false); return; } List <SitePartDef> parts = new List <SitePartDef>(); Action addPart = null; float localPoints = default(float); SitePartDef localPart = default(SitePartDef); addPart = delegate { List <DebugMenuOption> list = new List <DebugMenuOption> { new DebugMenuOption("-Done (" + parts.Count + " parts)-", DebugMenuOptionMode.Action, delegate { List <DebugMenuOption> list2 = new List <DebugMenuOption>(); foreach (float item in DebugActionsUtility.PointsOptions(extended: true)) { localPoints = item; list2.Add(new DebugMenuOption(item.ToString("F0"), DebugMenuOptionMode.Action, delegate { Site site = SiteMaker.TryMakeSite(parts, tile, disallowNonHostileFactions: true, null, ifHostileThenMustRemainHostile: true, localPoints); if (site == null) { Messages.Message("Could not find any valid faction for this site.", MessageTypeDefOf.RejectInput, historical: false); } else { Find.WorldObjects.Add(site); } })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list2)); }) }; foreach (SitePartDef allDef in DefDatabase <SitePartDef> .AllDefs) { localPart = allDef; list.Add(new DebugMenuOption(allDef.defName, DebugMenuOptionMode.Action, delegate { parts.Add(localPart); addPart(); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }; addPart(); }
private static void SpawnRandomFactionBase() { if (Find.FactionManager.AllFactions.Where((Faction x) => !x.IsPlayer && !x.def.hidden).TryRandomElement(out Faction result)) { int num = GenWorld.MouseTile(); if (!Find.WorldGrid[num].biome.impassable) { Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); settlement.SetFaction(result); settlement.Tile = num; settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement); Find.WorldObjects.Add(settlement); } } }
private int FindTileByScreenPos(Vector3 coords) { Find.WorldCameraDriver.JumpTo(coords); var uiPos = GenWorldUI.WorldToUIPosition(coords); var tileId = GenWorld.TileAt(uiPos); if (tileId == Tile.Invalid) { return(Tile.Invalid); } // just check that the tile isn't very far from the given coordinates var foundTileCoords = Find.WorldGrid.GetTileCenter(tileId); var dist = Vector3.Distance(foundTileCoords, coords); return(dist < _deltaVectorBig.magnitude ? tileId : Tile.Invalid); }
protected override void DoListingItems() { base.DoListingItems(); #if DEBUG if (!WorldRendererUtility.WorldRenderedNow) { return; } DoGap(); DoLabel("Tools - MFI"); DebugToolWorld_NewTmp("Spawn pirate base", () => { var tile = GenWorld.MouseTile(); if (tile < 0 || Find.World.Impassable(tile)) { Messages.Message("Impassable", MessageTypeDefOf.RejectInput, false); } else { var faction = (from x in Find.FactionManager.AllFactions where !x.def.hidden && !x.defeated && !x.IsPlayer && x.HostileTo(Faction.OfPlayer) && x.def.permanentEnemy select x).First(); var factionBase = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); factionBase.SetFaction(faction); factionBase.Tile = tile; factionBase.Name = SettlementNameGenerator.GenerateSettlementName(factionBase); Find.WorldObjects.Add(factionBase); } }, false ); DebugToolWorld_NewTmp("Test annual Expo", new AnnualExpoDialogue(null, null, null, Find.FactionManager.RandomAlliedFaction()) .DebugLogChances, false); #endif }
private static void SpawnSite() { int tile = GenWorld.MouseTile(); if (tile < 0 || Find.World.Impassable(tile)) { Messages.Message("Impassable", MessageTypeDefOf.RejectInput, historical: false); return; } List <SitePartDef> parts = new List <SitePartDef>(); Action addPart = null; SitePartDef localPart = default(SitePartDef); addPart = delegate { List <DebugMenuOption> list = new List <DebugMenuOption> { new DebugMenuOption("-Done (" + parts.Count + " parts)-", DebugMenuOptionMode.Action, delegate { Site site = SiteMaker.TryMakeSite(parts, tile); if (site == null) { Messages.Message("Could not find any valid faction for this site.", MessageTypeDefOf.RejectInput, historical: false); } else { Find.WorldObjects.Add(site); } }) }; foreach (SitePartDef allDef in DefDatabase <SitePartDef> .AllDefs) { localPart = allDef; list.Add(new DebugMenuOption(allDef.defName, DebugMenuOptionMode.Action, delegate { parts.Add(localPart); addPart(); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }; addPart(); }
private static void SpawnRandomCaravan() { int num = GenWorld.MouseTile(); if (Find.WorldGrid[num].biome.impassable) { return; } List <Pawn> list = new List <Pawn>(); int num2 = Rand.RangeInclusive(1, 10); for (int i = 0; i < num2; i++) { Pawn pawn = PawnGenerator.GeneratePawn(Faction.OfPlayer.def.basicMemberKind, Faction.OfPlayer); list.Add(pawn); if (!pawn.WorkTagIsDisabled(WorkTags.Violent) && Rand.Value < 0.9f) { ThingDef thingDef = DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => def.IsWeapon && def.PlayerAcquirable).RandomElementWithFallback(); pawn.equipment.AddEquipment((ThingWithComps)ThingMaker.MakeThing(thingDef, GenStuff.RandomStuffFor(thingDef))); } } int num3 = Rand.RangeInclusive(-4, 10); for (int j = 0; j < num3; j++) { Pawn item = PawnGenerator.GeneratePawn(DefDatabase <PawnKindDef> .AllDefs.Where((PawnKindDef d) => d.RaceProps.Animal && d.RaceProps.wildness < 1f).RandomElement(), Faction.OfPlayer); list.Add(item); } Caravan caravan = CaravanMaker.MakeCaravan(list, Faction.OfPlayer, num, addToWorldPawnsIfNotAlready: true); List <Thing> list2 = ThingSetMakerDefOf.DebugCaravanInventory.root.Generate(); for (int k = 0; k < list2.Count; k++) { Thing thing = list2[k]; if (!(thing.GetStatValue(StatDefOf.Mass) * (float)thing.stackCount > caravan.MassCapacity - caravan.MassUsage)) { CaravanInventoryUtility.GiveThing(caravan, thing); continue; } break; } }
public static void UpdateVisibility() { if (WorldRendererUtility.WorldRenderedNow) { int tile = GenWorld.TileAt(Verse.UI.MousePositionOnUI); if (tile >= 0) { Log.Message($"TILE: {tile} COST: {worldPathTexts[tile].Text}"); } } foreach (var textMesh in worldPathTexts) { bool visibleOnWorld = !WorldRendererUtility.HiddenBehindTerrainNow(textMesh.Position); if (visibleOnWorld != textMesh.Active) { textMesh.SetActive(visibleOnWorld); textMesh.WrapAroundPlanetSurface(); } } }
// 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."); }); }) }); }
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); }
protected override void DoListingItems() { base.DoListingItems(); if (WorldRendererUtility.WorldRenderedNow) { DoGap(); DoLabel("Tools - MFI"); base.DebugToolWorld("Spawn pirate base", delegate { 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); } } ); } }
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(); } } } }
public static List <WorldObject> WorldObjectsUnderMouse(Vector2 mousePos) { List <WorldObject> list = new List <WorldObject>(); ExpandableWorldObjectsUtility.GetExpandedWorldObjectUnderMouse(mousePos, list); float caravanDirectClickRadius = GenWorldUI.CaravanDirectClickRadius; GenWorldUI.clickedCaravans.Clear(); List <Caravan> caravans = Find.WorldObjects.Caravans; for (int i = 0; i < caravans.Count; i++) { Caravan caravan = caravans[i]; if (caravan.DistanceToMouse(mousePos) < caravanDirectClickRadius) { GenWorldUI.clickedCaravans.Add(caravan); } } GenWorldUI.clickedCaravans.SortBy((Caravan x) => x.DistanceToMouse(mousePos)); for (int j = 0; j < GenWorldUI.clickedCaravans.Count; j++) { if (!list.Contains(GenWorldUI.clickedCaravans[j])) { list.Add(GenWorldUI.clickedCaravans[j]); } } float dynamicallyDrawnObjectDirectClickRadius = GenWorldUI.DynamicallyDrawnObjectDirectClickRadius; GenWorldUI.clickedDynamicallyDrawnObjects.Clear(); List <WorldObject> allWorldObjects = Find.WorldObjects.AllWorldObjects; for (int k = 0; k < allWorldObjects.Count; k++) { WorldObject worldObject = allWorldObjects[k]; if (worldObject.def.useDynamicDrawer && worldObject.DistanceToMouse(mousePos) < dynamicallyDrawnObjectDirectClickRadius) { GenWorldUI.clickedDynamicallyDrawnObjects.Add(worldObject); } } GenWorldUI.clickedDynamicallyDrawnObjects.SortBy((WorldObject x) => x.DistanceToMouse(mousePos)); for (int l = 0; l < GenWorldUI.clickedDynamicallyDrawnObjects.Count; l++) { if (!list.Contains(GenWorldUI.clickedDynamicallyDrawnObjects[l])) { list.Add(GenWorldUI.clickedDynamicallyDrawnObjects[l]); } } int num = GenWorld.TileAt(mousePos, false); List <WorldObject> allWorldObjects2 = Find.WorldObjects.AllWorldObjects; for (int m = 0; m < allWorldObjects2.Count; m++) { if (allWorldObjects2[m].Tile == num && !list.Contains(allWorldObjects2[m])) { list.Add(allWorldObjects2[m]); } } float caravanWideClickRadius = GenWorldUI.CaravanWideClickRadius; GenWorldUI.clickedCaravans.Clear(); List <Caravan> caravans2 = Find.WorldObjects.Caravans; for (int n = 0; n < caravans2.Count; n++) { Caravan caravan2 = caravans2[n]; if (caravan2.DistanceToMouse(mousePos) < caravanWideClickRadius) { GenWorldUI.clickedCaravans.Add(caravan2); } } GenWorldUI.clickedCaravans.SortBy((Caravan x) => x.DistanceToMouse(mousePos)); for (int num2 = 0; num2 < GenWorldUI.clickedCaravans.Count; num2++) { if (!list.Contains(GenWorldUI.clickedCaravans[num2])) { list.Add(GenWorldUI.clickedCaravans[num2]); } } GenWorldUI.clickedCaravans.Clear(); return(list); }
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 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(); } } } }
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); } } }
public TerrainTile(Vector2 coord, int size, float scale, int seed, GameObject water, GameObject sand, GameObject forest, GameObject solidRock, GameObject rock, GameObject grass, GameObject tree, GameObject lilipad, GameObject driftwood) { pos = coord * size; bounds = new Bounds(pos, Vector2.one * size); Vector3 posV3 = new Vector3(pos.x, pos.y, 0); float biome = GenWorld.GenBiomeMap(scale, seed, coord); //set type of the tile if (biome < 0.2) { sprite = GameObject.Instantiate(water); } if (biome < 0.3 && biome > 0.2) { sprite = GameObject.Instantiate(sand); } if (biome < 0.7 && biome > 0.3) { sprite = GameObject.Instantiate(forest); } if (biome > 0.7) { sprite = GameObject.Instantiate(solidRock); } sprite.transform.position = posV3; sprite.transform.localScale = Vector3.one * size; float rand = Random.Range(0, 3); Mathf.RoundToInt(rand); if (rand == 1) { sprite.transform.Rotate(0, 0, 90); } else if (rand == 2) { sprite.transform.Rotate(0, 0, 180); } else if (rand == 3) { sprite.transform.Rotate(0, 0, 270); } //tile object generating and loading if (!TileObjectStor.ObjDict.ContainsKey(coord)) { rand = Random.Range(0, 10); Mathf.RoundToInt(rand); if (rand <= 1) { posV3 = new Vector3(pos.x, pos.y, -1); if (biome < 0.2) { rand = Random.Range(0, 1); if (rand < 0.8) { TileObject = GameObject.Instantiate(lilipad); BoxCollider boxCol = sprite.GetComponent <BoxCollider>(); boxCol.enabled = false; TileObjectStor.ObjDict.Add(coord, TileObj.lilipad); } else { TileObject = GameObject.Instantiate(driftwood); TileObjectStor.ObjDict.Add(coord, TileObj.driftwood); } } if (biome < 0.3 && biome > 0.2) { TileObject = GameObject.Instantiate(rock); TileObjectStor.ObjDict.Add(coord, TileObj.rock); } if (biome < 0.7 && biome > 0.3) { rand = Random.Range(0, 3); Mathf.RoundToInt(rand); if (rand == 0) { TileObject = GameObject.Instantiate(rock); TileObjectStor.ObjDict.Add(coord, TileObj.rock); } else if (rand == 1) { posV3 = new Vector3(pos.x, pos.y, -15); TileObject = GameObject.Instantiate(tree); TileObjectStor.ObjDict.Add(coord, TileObj.tree); } else { TileObject = GameObject.Instantiate(grass); TileObjectStor.ObjDict.Add(coord, TileObj.grass); } } if (biome < 0.7) { TileObject.transform.position = posV3; TileObject.transform.localScale = Vector3.one * size; } } else { TileObjectStor.ObjDict.Add(coord, TileObj.none); } } else { posV3 = new Vector3(pos.x, pos.y, -1); //load saved tileobj switch (TileObjectStor.ObjDict[coord]) { case TileObj.driftwood: TileObject = GameObject.Instantiate(driftwood); break; case TileObj.grass: TileObject = GameObject.Instantiate(grass); break; case TileObj.lilipad: TileObject = GameObject.Instantiate(lilipad); BoxCollider boxCol = sprite.GetComponent <BoxCollider>(); boxCol.enabled = false; break; case TileObj.none: break; case TileObj.rock: TileObject = GameObject.Instantiate(rock); break; case TileObj.tree: TileObject = GameObject.Instantiate(tree); posV3 = new Vector3(pos.x, pos.y, -15); break; default: break; } if (TileObject != null) { TileObject.transform.position = posV3; TileObject.transform.localScale = Vector3.one * size; } } SetVis(false); }
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); } } }