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, false); this.selectedDesignator.Finalize(false); } } else { this.dragger.StartDrag(); } Event.current.Use(); } if ((Event.current.type == EventType.MouseDown && Event.current.button == 1) || KeyBindingDefOf.Cancel.KeyDownEvent) { SoundDefOf.CancelMode.PlayOneShotOnCamera(null); this.Deselect(); this.dragger.EndDrag(); Event.current.Use(); TutorSystem.Notify_Event("ClearDesignatorSelection"); } if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { if (this.dragger.Dragging) { this.selectedDesignator.DesignateMultiCell(this.dragger.DragCells); this.dragger.EndDrag(); Event.current.Use(); } } } }
public static Vector3 MouseMapPosition() { return(UI.UIToMapPosition(UI.MousePositionOnUI)); }
public static IntVec3 MouseCell() { return(UI.UIToMapPosition(UI.MousePositionOnUI).ToIntVec3()); }
private static bool ShouldShow() { return(Find.PlaySettings.showBeauty && !Mouse.IsInputBlockedNow && UI.MouseCell().InBounds(Find.CurrentMap) && !UI.MouseCell().Fogged(Find.CurrentMap)); }
public static Vector3 UIToMapPosition(float x, float y) { return(UI.UIToMapPosition(new Vector2(x, y))); }
public void MouseoverReadoutOnGUI() { if (Event.current.type == EventType.Repaint) { if (Find.MainTabsRoot.OpenTab == null) { GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f)); Text.Font = GameFont.Small; GUI.color = new Color(1f, 1f, 1f, 0.8f); IntVec3 c = UI.MouseCell(); if (c.InBounds(Find.CurrentMap)) { float num = 0f; Profiler.BeginSample("fog"); if (c.Fogged(Find.CurrentMap)) { Rect rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); Widgets.Label(rect, "Undiscovered".Translate()); GUI.color = Color.white; Profiler.EndSample(); } else { Profiler.EndSample(); Profiler.BeginSample("light"); Rect rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); int num2 = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c, false) * 100f); Widgets.Label(rect, this.glowStrings[num2]); num += 19f; Profiler.EndSample(); Profiler.BeginSample("terrain"); rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); TerrainDef terrain = c.GetTerrain(Find.CurrentMap); if (terrain != this.cachedTerrain) { string str = ((double)terrain.fertility <= 0.0001) ? "" : (" " + "FertShort".Translate() + " " + terrain.fertility.ToStringPercent()); this.cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable) ? null : (" (" + "WalkSpeed".Translate(new object[] { this.SpeedPercentString((float)terrain.pathCost) }) + str + ")")); this.cachedTerrain = terrain; } Widgets.Label(rect, this.cachedTerrainString); num += 19f; Profiler.EndSample(); Profiler.BeginSample("zone"); Zone zone = c.GetZone(Find.CurrentMap); if (zone != null) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); string label = zone.label; Widgets.Label(rect, label); num += 19f; } Profiler.EndSample(); float depth = Find.CurrentMap.snowGrid.GetDepth(c); if (depth > 0.03f) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth); string label2 = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(new object[] { this.SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory)) }) + ")"; Widgets.Label(rect, label2); num += 19f; } Profiler.BeginSample("things"); List <Thing> thingList = c.GetThingList(Find.CurrentMap); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category != ThingCategory.Mote) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); string labelMouseover = thing.LabelMouseover; Widgets.Label(rect, labelMouseover); num += 19f; } } Profiler.EndSample(); Profiler.BeginSample("roof"); RoofDef roof = c.GetRoof(Find.CurrentMap); if (roof != null) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); Widgets.Label(rect, roof.LabelCap); num += 19f; } Profiler.EndSample(); GUI.color = Color.white; } } } } }
private static void SpawnDropship() { List <DebugMenuOption> list = new List <DebugMenuOption>(); list.Add(new DebugMenuOption("Incoming", DebugMenuOptionMode.Tool, delegate() { GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(ThingDefOf.ShuttleIncoming, ThingMaker.MakeThing(ThingDefOf.Shuttle, null)), UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near, null, null, default(Rot4)); })); list.Add(new DebugMenuOption("Stationary", DebugMenuOptionMode.Tool, delegate() { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Shuttle, null), UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near, null, null, default(Rot4)); })); List <DebugMenuOption> options = list; Find.WindowStack.Add(new Dialog_DebugOptionListLister(options)); }
private void UpdateDragCellsIfNeeded() { if (Time.frameCount != this.lastUpdateFrame) { this.lastUpdateFrame = Time.frameCount; this.dragCells.Clear(); this.failureReasonInt = null; IntVec3 intVec = this.startDragCell; IntVec3 intVec2 = UI.MouseCell(); if (this.SelDes.DraggableDimensions == 1) { bool flag = true; if (Mathf.Abs(intVec.x - intVec2.x) < Mathf.Abs(intVec.z - intVec2.z)) { flag = false; } if (flag) { int z = intVec.z; if (intVec.x > intVec2.x) { IntVec3 intVec3 = intVec; intVec = intVec2; intVec2 = intVec3; } for (int i = intVec.x; i <= intVec2.x; i++) { this.TryAddDragCell(new IntVec3(i, intVec.y, z)); } } else { int x = intVec.x; if (intVec.z > intVec2.z) { IntVec3 intVec4 = intVec; intVec = intVec2; intVec2 = intVec4; } for (int j = intVec.z; j <= intVec2.z; j++) { this.TryAddDragCell(new IntVec3(x, intVec.y, j)); } } } if (this.SelDes.DraggableDimensions == 2) { IntVec3 intVec5 = intVec; IntVec3 intVec6 = intVec2; if (intVec6.x > intVec5.x + 50) { intVec6.x = intVec5.x + 50; } if (intVec6.z > intVec5.z + 50) { intVec6.z = intVec5.z + 50; } if (intVec6.x < intVec5.x) { if (intVec6.x < intVec5.x - 50) { intVec6.x = intVec5.x - 50; } int x2 = intVec5.x; intVec5 = new IntVec3(intVec6.x, intVec5.y, intVec5.z); intVec6 = new IntVec3(x2, intVec6.y, intVec6.z); } if (intVec6.z < intVec5.z) { if (intVec6.z < intVec5.z - 50) { intVec6.z = intVec5.z - 50; } int z2 = intVec5.z; intVec5 = new IntVec3(intVec5.x, intVec5.y, intVec6.z); intVec6 = new IntVec3(intVec6.x, intVec6.y, z2); } for (int k = intVec5.x; k <= intVec6.x; k++) { for (int l = intVec5.z; l <= intVec6.z; l++) { this.TryAddDragCell(new IntVec3(k, intVec5.y, l)); } } } } }
public void StartDrag() { this.dragging = true; this.startDragCell = UI.MouseCell(); }
private string CurrentDebugString() { StringBuilder stringBuilder = new StringBuilder(); if (DebugViewSettings.writeGame) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine((Current.Game != null) ? Current.Game.DebugString() : "Current.Game = null"); } if (DebugViewSettings.writeMusicManagerPlay) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.MusicManagerPlay.DebugString()); } if (DebugViewSettings.writePlayingSounds) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Sustainers:"); foreach (Sustainer current in Find.SoundRoot.sustainerManager.AllSustainers) { stringBuilder.AppendLine(current.DebugString()); } stringBuilder.AppendLine(); stringBuilder.AppendLine("OneShots:"); foreach (SampleOneShot current2 in Find.SoundRoot.oneShotManager.PlayingOneShots) { stringBuilder.AppendLine(current2.ToString()); } } if (DebugViewSettings.writeSoundEventsRecord) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Recent sound events:\n ..."); stringBuilder.AppendLine(DebugSoundEventsLog.EventsListingDebugString); } if (DebugViewSettings.writeSteamItems) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(WorkshopItems.DebugOutput()); } if (DebugViewSettings.writeConcepts) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(LessonAutoActivator.DebugString()); } if (DebugViewSettings.writeMemoryUsage) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Total allocated: " + Profiler.GetTotalAllocatedMemoryLong().ToStringBytes("F2")); stringBuilder.AppendLine("Total reserved: " + Profiler.GetTotalReservedMemoryLong().ToStringBytes("F2")); stringBuilder.AppendLine("Total reserved unused: " + Profiler.GetTotalUnusedReservedMemoryLong().ToStringBytes("F2")); stringBuilder.AppendLine("Mono heap size: " + Profiler.GetMonoHeapSizeLong().ToStringBytes("F2")); stringBuilder.AppendLine("Mono used size: " + Profiler.GetMonoUsedSizeLong().ToStringBytes("F2")); } if (Current.ProgramState == ProgramState.Playing) { stringBuilder.AppendLine("Tick " + Find.TickManager.TicksGame); if (DebugViewSettings.writeStoryteller) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.Storyteller.DebugString()); } } if (Current.ProgramState == ProgramState.Playing && Find.CurrentMap != null) { if (DebugViewSettings.writeMapGameConditions) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.gameConditionManager.DebugString()); } if (DebugViewSettings.drawPawnDebug) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.reservationManager.DebugString()); } if (DebugViewSettings.writeMoteSaturation) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Mote count: " + Find.CurrentMap.moteCounter.MoteCount); stringBuilder.AppendLine("Mote saturation: " + Find.CurrentMap.moteCounter.Saturation); } if (DebugViewSettings.writeEcosystem) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.wildAnimalSpawner.DebugString()); } if (DebugViewSettings.writeTotalSnowDepth) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Total snow depth: " + Find.CurrentMap.snowGrid.TotalDepth); } if (DebugViewSettings.writeWind) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.windManager.DebugString()); } if (DebugViewSettings.writeRecentStrikes) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.mineStrikeManager.DebugStrikeRecords()); } if (DebugViewSettings.writeListRepairableBldgs) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.listerBuildingsRepairable.DebugString()); } if (DebugViewSettings.writeListFilthInHomeArea) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.listerFilthInHomeArea.DebugString()); } if (DebugViewSettings.writeListHaulables) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.listerHaulables.DebugString()); } if (DebugViewSettings.writeListMergeables) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.listerMergeables.DebugString()); } if (DebugViewSettings.drawLords) { foreach (Lord current3 in Find.CurrentMap.lordManager.lords) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(current3.DebugString()); } } IntVec3 intVec = UI.MouseCell(); if (intVec.InBounds(Find.CurrentMap)) { stringBuilder.AppendLine("Inspecting " + intVec.ToString()); if (DebugViewSettings.writeTerrain) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.terrainGrid.DebugStringAt(intVec)); } if (DebugViewSettings.writeAttackTargets) { foreach (Pawn current4 in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Pawn>()) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Potential attack targets for " + current4.LabelShort + ":"); List <IAttackTarget> potentialTargetsFor = Find.CurrentMap.attackTargetsCache.GetPotentialTargetsFor(current4); for (int i = 0; i < potentialTargetsFor.Count; i++) { Thing thing = (Thing)potentialTargetsFor[i]; stringBuilder.AppendLine(string.Concat(new object[] { thing.LabelShort, ", ", thing.Faction, (!potentialTargetsFor[i].ThreatDisabled(null)) ? string.Empty : " (threat disabled)" })); } } } if (DebugViewSettings.writeSnowDepth) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Snow depth: " + Find.CurrentMap.snowGrid.GetDepth(intVec)); } if (DebugViewSettings.drawDeepResources) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Deep resource def: " + Find.CurrentMap.deepResourceGrid.ThingDefAt(intVec)); stringBuilder.AppendLine("Deep resource count: " + Find.CurrentMap.deepResourceGrid.CountAt(intVec)); } if (DebugViewSettings.writeCanReachColony) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("CanReachColony: " + Find.CurrentMap.reachability.CanReachColony(UI.MouseCell())); } if (DebugViewSettings.writeMentalStateCalcs) { stringBuilder.AppendLine("---"); foreach (Pawn current5 in (from t in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()) where t is Pawn select t).Cast <Pawn>()) { stringBuilder.AppendLine(current5.mindState.mentalBreaker.DebugString()); } } if (DebugViewSettings.writeWorkSettings) { foreach (Pawn current6 in (from t in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()) where t is Pawn select t).Cast <Pawn>()) { if (current6.workSettings != null) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(current6.workSettings.DebugString()); } } } if (DebugViewSettings.writeApparelScore) { stringBuilder.AppendLine("---"); if (intVec.InBounds(Find.CurrentMap)) { foreach (Thing current7 in intVec.GetThingList(Find.CurrentMap)) { Apparel apparel = current7 as Apparel; if (apparel != null) { stringBuilder.AppendLine(apparel.Label + ": " + JobGiver_OptimizeApparel.ApparelScoreRaw(null, apparel).ToString("F2")); } } } } if (DebugViewSettings.writeCellContents || this.fullMode) { stringBuilder.AppendLine("---"); if (intVec.InBounds(Find.CurrentMap)) { foreach (Designation current8 in Find.CurrentMap.designationManager.AllDesignationsAt(intVec)) { stringBuilder.AppendLine(current8.ToString()); } foreach (Thing current9 in Find.CurrentMap.thingGrid.ThingsAt(intVec)) { if (!this.fullMode) { stringBuilder.AppendLine(current9.LabelCap + " - " + current9.ToString()); } else { stringBuilder.AppendLine(Scribe.saver.DebugOutputFor(current9)); stringBuilder.AppendLine(); } } } } if (DebugViewSettings.debugApparelOptimize) { stringBuilder.AppendLine("---"); foreach (Thing current10 in Find.CurrentMap.thingGrid.ThingsAt(intVec)) { Apparel apparel2 = current10 as Apparel; if (apparel2 != null) { stringBuilder.AppendLine(apparel2.LabelCap); stringBuilder.AppendLine(" raw: " + JobGiver_OptimizeApparel.ApparelScoreRaw(null, apparel2).ToString("F2")); Pawn pawn = Find.Selector.SingleSelectedThing as Pawn; if (pawn != null) { stringBuilder.AppendLine(" Pawn: " + pawn); stringBuilder.AppendLine(" gain: " + JobGiver_OptimizeApparel.ApparelScoreGain(pawn, apparel2).ToString("F2")); } } } } if (DebugViewSettings.drawRegions) { stringBuilder.AppendLine("---"); Region regionAt_NoRebuild_InvalidAllowed = Find.CurrentMap.regionGrid.GetRegionAt_NoRebuild_InvalidAllowed(intVec); stringBuilder.AppendLine("Region:\n" + ((regionAt_NoRebuild_InvalidAllowed == null) ? "null" : regionAt_NoRebuild_InvalidAllowed.DebugString)); } if (DebugViewSettings.drawRooms) { stringBuilder.AppendLine("---"); Room room = intVec.GetRoom(Find.CurrentMap, RegionType.Set_All); if (room != null) { stringBuilder.AppendLine(room.DebugString()); } else { stringBuilder.AppendLine("(no room)"); } } if (DebugViewSettings.drawRoomGroups) { stringBuilder.AppendLine("---"); RoomGroup roomGroup = intVec.GetRoomGroup(Find.CurrentMap); if (roomGroup != null) { stringBuilder.AppendLine(roomGroup.DebugString()); } else { stringBuilder.AppendLine("(no room group)"); } } if (DebugViewSettings.drawGlow) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Game glow: " + Find.CurrentMap.glowGrid.GameGlowAt(intVec, false)); stringBuilder.AppendLine("Psych glow: " + Find.CurrentMap.glowGrid.PsychGlowAt(intVec)); stringBuilder.AppendLine("Visual Glow: " + Find.CurrentMap.glowGrid.VisualGlowAt(intVec)); stringBuilder.AppendLine("GlowReport:\n" + ((SectionLayer_LightingOverlay)Find.CurrentMap.mapDrawer.SectionAt(intVec).GetLayer(typeof(SectionLayer_LightingOverlay))).GlowReportAt(intVec)); stringBuilder.AppendLine("SkyManager.CurSkyGlow: " + Find.CurrentMap.skyManager.CurSkyGlow); } if (DebugViewSettings.writePathCosts) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Perceived path cost: " + Find.CurrentMap.pathGrid.PerceivedPathCostAt(intVec)); stringBuilder.AppendLine("Real path cost: " + Find.CurrentMap.pathGrid.CalculatedCostAt(intVec, false, IntVec3.Invalid)); } if (DebugViewSettings.writeFertility) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("\nFertility: " + Find.CurrentMap.fertilityGrid.FertilityAt(intVec).ToString("##0.00")); } if (DebugViewSettings.writeLinkFlags) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("\nLinkFlags: "); foreach (object current11 in Enum.GetValues(typeof(LinkFlags))) { if ((Find.CurrentMap.linkGrid.LinkFlagsAt(intVec) & (LinkFlags)current11) != LinkFlags.None) { stringBuilder.Append(" " + current11); } } } if (DebugViewSettings.writeSkyManager) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.skyManager.DebugString()); } if (DebugViewSettings.writeCover) { stringBuilder.AppendLine("---"); stringBuilder.Append("Cover: "); Thing thing2 = Find.CurrentMap.coverGrid[intVec]; if (thing2 == null) { stringBuilder.AppendLine("null"); } else { stringBuilder.AppendLine(thing2.ToString()); } } if (DebugViewSettings.drawPower) { stringBuilder.AppendLine("---"); foreach (Thing current12 in Find.CurrentMap.thingGrid.ThingsAt(intVec)) { ThingWithComps thingWithComps = current12 as ThingWithComps; if (thingWithComps != null && thingWithComps.GetComp <CompPowerTrader>() != null) { stringBuilder.AppendLine(" " + thingWithComps.GetComp <CompPowerTrader>().DebugString); } } PowerNet powerNet = Find.CurrentMap.powerNetGrid.TransmittedPowerNetAt(intVec); if (powerNet != null) { stringBuilder.AppendLine(string.Empty + powerNet.DebugString()); } else { stringBuilder.AppendLine("(no PowerNet here)"); } } if (DebugViewSettings.drawPreyInfo) { Pawn pawn2 = Find.Selector.SingleSelectedThing as Pawn; if (pawn2 != null) { List <Thing> thingList = intVec.GetThingList(Find.CurrentMap); for (int j = 0; j < thingList.Count; j++) { Pawn pawn3 = thingList[j] as Pawn; if (pawn3 != null) { stringBuilder.AppendLine("---"); if (FoodUtility.IsAcceptablePreyFor(pawn2, pawn3)) { stringBuilder.AppendLine("Prey score: " + FoodUtility.GetPreyScoreFor(pawn2, pawn3)); } else { stringBuilder.AppendLine("Prey score: None"); } break; } } } } } } return(stringBuilder.ToString()); }
public override void PostClose() { base.PostClose(); UI.UnfocusCurrentControl(); }
public static IEnumerable <LocalTargetInfo> TargetsAtMouse(TargetingParameters clickParams, bool thingsOnly = false) { return(GenUI.TargetsAt(UI.MouseMapPosition(), clickParams, thingsOnly)); }
public static void RenderMouseoverBracket() { Vector3 position = UI.MouseCell().ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays); Graphics.DrawMesh(MeshPool.plane10, position, Quaternion.identity, GenUI.MouseoverBracketMaterial, 0); }
private static bool ShouldShowBeauty() { return(Find.PlaySettings.showBeauty && UI.MouseCell().InBounds(Find.CurrentMap) && !UI.MouseCell().Fogged(Find.CurrentMap) && UI.MouseCell().GetRoom(Find.CurrentMap, RegionType.Set_Passable) != null); }