public static bool DrawDynamicThings(DynamicDrawManager __instance) { if (!DebugViewSettings.drawThingsDynamic || null == map(__instance)) { return(false); } drawingNow(__instance) = true; try { bool[] fogGrid = map(__instance).fogGrid.fogGrid; CellRect cellRect = Find.CameraDriver.CurrentViewRect; cellRect.ClipInsideMap(map(__instance)); cellRect = cellRect.ExpandedBy(1); CellIndices cellIndices = map(__instance).cellIndices; SnowGrid snowGrid = map(__instance).snowGrid; /* * RimThreaded.fogGrid = map(__instance).fogGrid.fogGrid; * RimThreaded.cellRect = Find.CameraDriver.CurrentViewRect; * RimThreaded.cellRect.ClipInsideMap(map(__instance)); * RimThreaded.cellRect = RimThreaded.cellRect.ExpandedBy(1); * RimThreaded.cellIndices = map(__instance).cellIndices; * RimThreaded.snowGrid = map(__instance).snowGrid; * RimThreaded.drawQueue = new ConcurrentQueue<Thing>(drawThings(__instance)); * RimThreaded.startWorkerThreads(); */ //Thing drawThing; //Thing[] drawThingsArray; //for (int index = 0; index < drawThingsArray.Length; index++) foreach (Thing drawThing in drawThings(__instance).ToList()) { //drawThing = drawThingsArray[index]; IntVec3 position = drawThing.Position; if ((cellRect.Contains(position) || drawThing.def.drawOffscreen) && (!fogGrid[cellIndices.CellToIndex(position)] || drawThing.def.seeThroughFog) && ((double)drawThing.def.hideAtSnowDepth >= 1.0 || (double)snowGrid.GetDepth(position) <= (double)drawThing.def.hideAtSnowDepth)) { try { drawThing.Draw(); } catch (Exception ex) { Log.Error("Exception drawing " + (object)drawThing + ": " + ex.ToString(), false); } } } } catch (Exception ex) { Log.Error("Exception drawing dynamic things: " + (object)ex, false); } drawingNow(__instance) = false; return(false); }
public static void CanHaveSnow_PostFix(SnowGrid __instance, int ind, ref bool __result) { var map = Traverse.Create(__instance).Field("map").GetValue <Map>(); if (map == null) { return; } var building = map.edificeGrid[ind]; if (building is EarthenWall w) { __result = true; if (Find.TickManager.TicksGame % 250 == 0) { w.DirtyMapMesh(w.MapHeld); } } }
public static void RemoveSnow(Map map, bool homearea) { if (map == null || map.snowGrid == null || map.mapDrawer == null) { return; } if (homearea) { SnowGrid grid = map.snowGrid; foreach (IntVec3 c in map.areaManager.Home.ActiveCells) { grid.SetDepth(c, 0f); } } else { map.snowGrid = new SnowGrid(map); map.mapDrawer.WholeMapChanged(MapMeshFlag.Snow); map.mapDrawer.WholeMapChanged(MapMeshFlag.Things); //Patch: Pathfinding cost update map.pathGrid.RecalculateAllPerceivedPathCosts(); } }