private void init()
        {
            // Reveal the starting position if home map and no pawns (landing).
            if (map.IsPlayerHome && map.mapPawns.ColonistsSpawnedCount == 0)
            {
                IntVec3 playerStartSpot = MapGenerator.PlayerStartSpot;
                ShadowCaster.computeFieldOfViewWithShadowCasting(playerStartSpot.x, playerStartSpot.z, Mathf.RoundToInt(CompFieldOfViewWatcher.NON_MECH_DEFAULT_RANGE),
                                                                 viewBlockerCells, map.Size.x, map.Size.z,
                                                                 false, null, null, null, // Directly updating known cells. No need to call incrementSeen.
                                                                 knownCells, 0, 0, mapSizeX,
                                                                 null, 0, 0, 0, 0, 0);

                for (int i = 0; i < mapCellLength; i++)
                {
                    if (knownCells[i])
                    {
                        IntVec3 cell = CellIndicesUtility.IndexToCell(i, mapSizeX);
                        foreach (Thing t in map.thingGrid.ThingsListAtFast(cell))
                        {
                            CompMainComponent compMain = (CompMainComponent)t.TryGetComp(CompMainComponent.COMP_DEF);
                            if (compMain != null && compMain.compHideFromPlayer != null)
                            {
                                compMain.compHideFromPlayer.forceSeen();
                            }
                        }
                    }
                }
            }

            // Update all thing FoV and visibility.
            foreach (Thing thing in map.listerThings.AllThings)
            {
                if (thing.Spawned)
                {
                    CompMainComponent compMain = (CompMainComponent)thing.TryGetComp(CompMainComponent.COMP_DEF);
                    if (compMain != null)
                    {
                        if (compMain.compComponentsPositionTracker != null)
                        {
                            compMain.compComponentsPositionTracker.updatePosition();
                        }
                        if (compMain.compFieldOfViewWatcher != null)
                        {
                            compMain.compFieldOfViewWatcher.updateFoV();
                        }
                        if (compMain.compHideFromPlayer != null)
                        {
                            compMain.compHideFromPlayer.updateVisibility(true);
                        }
                    }
                }
            }

            // Redraw everything.
            mapDrawer.RegenerateEverythingNow();
        }
        private void init()
        {
            // Retrieve map sections and store in a linear array.
            Section[,] mapDrawerSections = (Section[, ])Traverse.Create(mapDrawer).Field("sections").GetValue();
            sectionsSizeX = mapDrawerSections.GetLength(0);
            sectionsSizeY = mapDrawerSections.GetLength(1);

            sections = new Section[sectionsSizeX * sectionsSizeY];
            for (int y = 0; y < sectionsSizeY; y++)
            {
                for (int x = 0; x < sectionsSizeX; x++)
                {
                    sections[y * sectionsSizeX + x] = mapDrawerSections[x, y];
                }
            }

            // Initialize mining designators (add notifications intercepted by detours aren't fired on load).
            List <Designation> designations = map.designationManager.allDesignations;

            for (int i = 0; i < designations.Count; i++)
            {
                Designation des = designations[i];
                if (des.def == DesignationDefOf.Mine && !des.target.HasThing)
                {
                    registerMineDesignation(des);
                }
            }

            // Reveal the starting position if home map and no pawns (landing).
            if (map.IsPlayerHome && map.mapPawns.ColonistsSpawnedCount == 0)
            {
                IntVec3 playerStartSpot = MapGenerator.PlayerStartSpot;
                ShadowCaster.computeFieldOfViewWithShadowCasting(playerStartSpot.x, playerStartSpot.z, Mathf.RoundToInt(CompFieldOfViewWatcher.NON_MECH_DEFAULT_RANGE),
                                                                 viewBlockerCells, map.Size.x, map.Size.z,
                                                                 false, null, null, null, // Directly updating known cells. No need to call incrementSeen.
                                                                 knownCells, 0, 0, mapSizeX,
                                                                 null, 0, 0, 0, 0, 0);

                for (int i = 0; i < mapCellLength; i++)
                {
                    if (knownCells[i])
                    {
                        IntVec3 cell = CellIndicesUtility.IndexToCell(i, mapSizeX);
                        foreach (Thing t in map.thingGrid.ThingsListAtFast(cell))
                        {
                            CompMainComponent compMain = (CompMainComponent)t.TryGetComp(CompMainComponent.COMP_DEF);
                            if (compMain != null && compMain.compHideFromPlayer != null)
                            {
                                compMain.compHideFromPlayer.forceSeen();
                            }
                        }
                    }
                }
            }

            // Update all thing FoV and visibility.
            foreach (Thing thing in map.listerThings.AllThings)
            {
                if (thing.Spawned)
                {
                    CompMainComponent compMain = (CompMainComponent)thing.TryGetComp(CompMainComponent.COMP_DEF);
                    if (compMain != null)
                    {
                        if (compMain.compComponentsPositionTracker != null)
                        {
                            compMain.compComponentsPositionTracker.updatePosition();
                        }
                        if (compMain.compFieldOfViewWatcher != null)
                        {
                            compMain.compFieldOfViewWatcher.updateFoV();
                        }
                        if (compMain.compHideFromPlayer != null)
                        {
                            compMain.compHideFromPlayer.updateVisibility(true);
                        }
                    }
                }
            }

            // Redraw everything.
            mapDrawer.RegenerateEverythingNow();
        }