private void FloodUnfogAdjacent(IntVec3 c) { this.Unfog(c); bool flag = false; FloodUnfogResult floodUnfogResult = default(FloodUnfogResult); for (int i = 0; i < 4; i++) { IntVec3 intVec = c + GenAdj.CardinalDirections[i]; if (intVec.InBounds(this.map) && intVec.Fogged(this.map)) { Building edifice = intVec.GetEdifice(this.map); if (edifice == null || !edifice.def.MakeFog) { flag = true; floodUnfogResult = FloodFillerFog.FloodUnfog(intVec, this.map); } else { this.Unfog(intVec); } } } for (int j = 0; j < 8; j++) { IntVec3 c2 = c + GenAdj.AdjacentCells[j]; if (c2.InBounds(this.map)) { Building edifice2 = c2.GetEdifice(this.map); if (edifice2 != null && edifice2.def.MakeFog) { this.Unfog(c2); } } } if (flag) { if (floodUnfogResult.mechanoidFound) { Find.LetterStack.ReceiveLetter("LetterLabelAreaRevealed".Translate(), "AreaRevealedWithMechanoids".Translate(), LetterDefOf.ThreatBig, new TargetInfo(c, this.map, false), null); } else { if (floodUnfogResult.allOnScreen && floodUnfogResult.cellsUnfogged < 600) { return; } Find.LetterStack.ReceiveLetter("LetterLabelAreaRevealed".Translate(), "AreaRevealed".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(c, this.map, false), null); } } }
public static FloodUnfogResult FloodUnfog(IntVec3 root, Map map) { FloodFillerFog.cellsToUnfog.Clear(); FloodUnfogResult result = default(FloodUnfogResult); bool[] fogGridDirect = map.fogGrid.fogGrid; FogGrid fogGrid = map.fogGrid; List <IntVec3> newlyUnfoggedCells = new List <IntVec3>(); int numUnfogged = 0; bool expanding = false; CellRect viewRect = CellRect.ViewRect(map); result.allOnScreen = true; Predicate <IntVec3> predicate = delegate(IntVec3 c) { bool result; if (!fogGridDirect[map.cellIndices.CellToIndex(c)]) { result = false; } else { Thing edifice = c.GetEdifice(map); result = ((edifice == null || !edifice.def.MakeFog) && (!FloodFillerFog.testMode || expanding || numUnfogged <= 500)); } return(result); }; Action <IntVec3> processor = delegate(IntVec3 c) { fogGrid.Unfog(c); newlyUnfoggedCells.Add(c); List <Thing> thingList = c.GetThingList(map); for (int l = 0; l < thingList.Count; l++) { Pawn pawn = thingList[l] as Pawn; if (pawn != null) { pawn.mindState.Active = true; if (pawn.def.race.IsMechanoid) { result.mechanoidFound = true; } } } if (!viewRect.Contains(c)) { result.allOnScreen = false; } result.cellsUnfogged++; if (FloodFillerFog.testMode) { numUnfogged++; map.debugDrawer.FlashCell(c, (float)numUnfogged / 200f, numUnfogged.ToStringCached(), 50); } }; map.floodFiller.FloodFill(root, predicate, processor, int.MaxValue, false, null); expanding = true; for (int i = 0; i < newlyUnfoggedCells.Count; i++) { IntVec3 a = newlyUnfoggedCells[i]; for (int j = 0; j < 8; j++) { IntVec3 intVec = a + GenAdj.AdjacentCells[j]; if (intVec.InBounds(map) && fogGrid.IsFogged(intVec)) { if (!predicate(intVec)) { FloodFillerFog.cellsToUnfog.Add(intVec); } } } } for (int k = 0; k < FloodFillerFog.cellsToUnfog.Count; k++) { fogGrid.Unfog(FloodFillerFog.cellsToUnfog[k]); if (FloodFillerFog.testMode) { map.debugDrawer.FlashCell(FloodFillerFog.cellsToUnfog[k], 0.3f, "x", 50); } } FloodFillerFog.cellsToUnfog.Clear(); return(result); }