public void DebugDrawMouseover() { int num = Mathf.RoundToInt(Time.realtimeSinceStartup * 2f) % 2; if (RimShipMod.mod.settings.debugDrawRegions) { Color color; if (!this.valid) { color = Color.red; } else if (this.DebugIsNew) { color = Color.yellow; } else { color = Color.green; } GenDraw.DrawFieldEdges(this.Cells.ToList <IntVec3>(), color); foreach (WaterRegion region in this.Neighbors) { GenDraw.DrawFieldEdges(region.Cells.ToList <IntVec3>(), Color.grey); } if (RimShipMod.mod.settings.debugDrawRegionLinks) { foreach (WaterRegionLink regionLink in this.links) { if (num == 1) { foreach (IntVec3 c in regionLink.span.Cells) { CellRenderer.RenderCell(c, DebugSolidColorMats.MaterialOf(Color.magenta)); } } } } if (RimShipMod.mod.settings.debugDrawRegionThings) { foreach (Thing thing in this.listerThings.AllThings) { CellRenderer.RenderSpot(thing.TrueCenter(), (float)(thing.thingIDNumber % 256) / 256f); } } } }
public static void DebugDraw() { if (!Prefs.DevMode || !DebugViewSettings.drawDamageRects || Find.CurrentMap == null) { return; } Thing Thing = Find.Selector.FirstSelectedObject as Thing; if (Thing == null) { return; } Material material = DebugSolidColorMats.MaterialOf(Color.red); Rect damageRect = ThingsToxicDamageSectionLayerUtility.GetDamageRect(Thing); float y = 14.99f; Vector3 pos = new Vector3(damageRect.x + damageRect.width / 2f, y, damageRect.y + damageRect.height / 2f); Vector3 s = new Vector3(damageRect.width, 1f, damageRect.height); Graphics.DrawMesh(MeshPool.plane10, Matrix4x4.TRS(pos, Quaternion.identity, s), material, 0); }
// largely copypasta from RoofCollapseUtility.WithinRangeOfRoofHolder // TODO: PERFORMANCE; maintain a cellgrid of 'safe' supported areas. private static bool WouldCollapseIfSupportDestroyed(IntVec3 position, IntVec3 support, Map map) { if (!position.InBounds(map) || !position.Roofed(map)) { return(false); } // cell indexes and buildings on map indexed by cellIndex var cellIndices = map.cellIndices; var innerArray = map.edificeGrid.InnerArray; for (var i = 0; i < RoofCollapseUtility.RoofSupportRadialCellsCount; i++) { Logger.Debug(i.ToString()); var candidate = position + GenRadial.RadialPattern[i]; if (candidate != support && candidate.InBounds(map)) { var building = innerArray[cellIndices.CellToIndex(candidate)]; #if DEBUG map.debugDrawer.FlashCell( candidate, DebugSolidColorMats.MaterialOf(new Color(0f, 0f, 1f, .1f)), ".", 500); #endif if (building != null && building.def.holdsRoof && !IsDesignatedForRemoval(building, map)) { #if DEBUG map.debugDrawer.FlashCell( candidate, DebugSolidColorMats.MaterialOf(new Color(0f, 1f, 0f, .1f)), "!", 500); map.debugDrawer.FlashCell( position, DebugSolidColorMats.MaterialOf(new Color(0f, 1f, 0f, .1f)), "V", 500); #endif return(false); } } } #if DEBUG map.debugDrawer.FlashCell(position, DebugSolidColorMats.MaterialOf(Color.red), "X"); #endif return(true); }
protected override void DoListingItems() { DebugToolMap("IsValidMiningTarget", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Mineable>()) { Messages.Message((job.IsValidMiningTarget(thing)).ToString(), MessageTypeDefOf.SilentInput); } }); DebugToolMap("IsValidDeconstructionTarget", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Building>()) { Messages.Message((job.IsValidDeconstructionTarget(thing)).ToString(), MessageTypeDefOf.SilentInput); } }); DebugToolMap("Faction", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Building>()) { Messages.Message(thing.Faction.ToStringSafe(), MessageTypeDefOf.SilentInput); } }); DebugToolMap("AllowedBuilding", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Building>()) { Messages.Message(job.AllowedBuilding(thing.def).ToString(), MessageTypeDefOf.SilentInput); } }); DebugToolMap("AllowedMineral", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Mineable>()) { Messages.Message(job.AllowedMineral(thing.def).ToString(), MessageTypeDefOf.SilentInput); } }); DebugToolMap("IsRelevantDeconstructionTarget", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Building>()) { Messages.Message(job.IsRelevantDeconstructionTarget(thing).ToString(), MessageTypeDefOf.SilentInput); } }); DebugToolMap("IsRelevantMiningTarget", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Mineable>()) { Messages.Message(job.IsRelevantMiningTarget(thing).ToString(), MessageTypeDefOf.SilentInput); } }); DebugToolMap("IsInAllowedArea", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Building>()) { Messages.Message(job.IsInAllowedArea(thing).ToString(), MessageTypeDefOf.SilentInput); } }); DebugToolMap("IsReachable", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Building>()) { Messages.Message((job.IsReachable(thing)).ToString(), MessageTypeDefOf.SilentInput); } }); DebugToolMap("IsRoomDivider", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Building>()) { Messages.Message((job.IsARoomDivider(thing)).ToString(), MessageTypeDefOf.SilentInput); } }); DebugToolMap("IsRoofSupport: basic", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Building>()) { Messages.Message((job.IsARoofSupport_Basic(thing)).ToString(), MessageTypeDefOf.SilentInput); } }); DebugToolMap("IsRoofSupport: advanced", delegate { foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Building>()) { Messages.Message((job.IsARoofSupport_Advanced(thing)).ToString(), MessageTypeDefOf.SilentInput); } }); DebugAction("DrawSupportGrid", delegate { foreach (var cell in job.manager.map.AllCells) { if (job.IsARoofSupport_Basic(cell)) { job.manager.map.debugDrawer.FlashCell(cell, DebugSolidColorMats.MaterialOf(Color.green)); } } }); DebugAction("GetBaseCenter", delegate { var cell = Utilities.GetBaseCenter(job.manager); job.manager.map.debugDrawer.FlashCell(cell, DebugSolidColorMats.MaterialOf(Color.blue)); }); DebugToolMap("DrawPath", delegate { var source = Utilities.GetBaseCenter(job.manager); var target = UI.MouseCell(); var path = job.manager.map.pathFinder.FindPath(source, target, TraverseParms.For(TraverseMode.PassDoors, Danger.Some)); path.DrawPath(null); path.ReleaseToPool(); } ); }