internal bool <> m__0(IntVec3 c) { int num = this.cellIndices.CellToIndex(c); if (this.traverseParams.mode == TraverseMode.PassAllDestroyableThingsNotWater || this.traverseParams.mode == TraverseMode.NoPassClosedDoorsOrWater) { if (c.GetTerrain(this.$this.map).IsWater) { return(false); } } if (this.traverseParams.mode == TraverseMode.PassAllDestroyableThings || this.traverseParams.mode == TraverseMode.PassAllDestroyableThingsNotWater) { if (!this.pathGrid.WalkableFast(num)) { Building edifice = c.GetEdifice(this.$this.map); if (edifice == null || !PathFinder.IsDestroyable(edifice)) { return(false); } } } else if (this.traverseParams.mode != TraverseMode.NoPassClosedDoorsOrWater) { Log.ErrorOnce("Do not use this method for non-cell based modes!", 938476762, false); if (!this.pathGrid.WalkableFast(num)) { return(false); } } Region region = this.directRegionGrid[num]; return(region == null || region.Allows(this.traverseParams, false)); }
private bool CheckRegionBasedReachability(TraverseParms traverseParams) { while (this.openQueue.Count > 0) { Region region = this.openQueue.Dequeue(); for (int i = 0; i < region.links.Count; i++) { RegionLink regionLink = region.links[i]; int j = 0; while (j < 2) { Region region2 = regionLink.regions[j]; if (region2 != null && region2.reachedIndex != this.reachedIndex && region2.type.Passable()) { if (region2.Allows(traverseParams, false)) { if (this.destRegions.Contains(region2)) { for (int k = 0; k < this.startingRegions.Count; k++) { this.cache.AddCachedResult(this.startingRegions[k].Room, region2.Room, traverseParams, true); } return(true); } this.QueueNewOpenRegion(region2); } } IL_E5: j++; continue; goto IL_E5; } } } for (int l = 0; l < this.startingRegions.Count; l++) { for (int m = 0; m < this.destRegions.Count; m++) { this.cache.AddCachedResult(this.startingRegions[l].Room, this.destRegions[m].Room, traverseParams, false); } } return(false); }
public bool CanReach(IntVec3 start, LocalTargetInfo dest, PathEndMode peMode, TraverseParms traverseParams) { if (this.working) { Log.ErrorOnce("Called CanReach() while working. This should never happen. Suppressing further errors.", 7312233, false); return(false); } if (traverseParams.pawn != null) { if (!traverseParams.pawn.Spawned) { return(false); } if (traverseParams.pawn.Map != this.map) { Log.Error(string.Concat(new object[] { "Called CanReach() with a pawn spawned not on this map. This means that we can't check his reachability here. Pawn's current map should have been used instead of this one. pawn=", traverseParams.pawn, " pawn.Map=", traverseParams.pawn.Map, " map=", this.map }), false); return(false); } } if (ReachabilityImmediate.CanReachImmediate(start, dest, this.map, peMode, traverseParams.pawn)) { return(true); } if (!dest.IsValid) { return(false); } if (dest.HasThing && dest.Thing.Map != this.map) { return(false); } if (!start.InBounds(this.map) || !dest.Cell.InBounds(this.map)) { return(false); } if ((peMode == PathEndMode.OnCell || peMode == PathEndMode.Touch || peMode == PathEndMode.ClosestTouch) && traverseParams.mode != TraverseMode.NoPassClosedDoorsOrWater && traverseParams.mode != TraverseMode.PassAllDestroyableThingsNotWater) { Room room = RegionAndRoomQuery.RoomAtFast(start, this.map, RegionType.Set_Passable); if (room != null && room == RegionAndRoomQuery.RoomAtFast(dest.Cell, this.map, RegionType.Set_Passable)) { return(true); } } if (traverseParams.mode == TraverseMode.PassAllDestroyableThings) { TraverseParms traverseParams2 = traverseParams; traverseParams2.mode = TraverseMode.PassDoors; if (this.CanReach(start, dest, peMode, traverseParams2)) { return(true); } } dest = (LocalTargetInfo)GenPath.ResolvePathMode(traverseParams.pawn, dest.ToTargetInfo(this.map), ref peMode); this.working = true; bool result; try { this.pathGrid = this.map.pathGrid; this.regionGrid = this.map.regionGrid; this.reachedIndex += 1u; this.destRegions.Clear(); if (peMode == PathEndMode.OnCell) { Region region = dest.Cell.GetRegion(this.map, RegionType.Set_Passable); if (region != null && region.Allows(traverseParams, true)) { this.destRegions.Add(region); } } else if (peMode == PathEndMode.Touch) { TouchPathEndModeUtility.AddAllowedAdjacentRegions(dest, traverseParams, this.map, this.destRegions); } if (this.destRegions.Count == 0 && traverseParams.mode != TraverseMode.PassAllDestroyableThings && traverseParams.mode != TraverseMode.PassAllDestroyableThingsNotWater) { this.FinalizeCheck(); result = false; } else { this.destRegions.RemoveDuplicates <Region>(); this.openQueue.Clear(); this.numRegionsOpened = 0; this.DetermineStartRegions(start); if (this.openQueue.Count == 0 && traverseParams.mode != TraverseMode.PassAllDestroyableThings && traverseParams.mode != TraverseMode.PassAllDestroyableThingsNotWater) { this.FinalizeCheck(); result = false; } else { if (this.startingRegions.Any <Region>() && this.destRegions.Any <Region>() && this.CanUseCache(traverseParams.mode)) { BoolUnknown cachedResult = this.GetCachedResult(traverseParams); if (cachedResult == BoolUnknown.True) { this.FinalizeCheck(); result = true; return(result); } if (cachedResult == BoolUnknown.False) { this.FinalizeCheck(); result = false; return(result); } if (cachedResult != BoolUnknown.Unknown) { } } if (traverseParams.mode == TraverseMode.PassAllDestroyableThings || traverseParams.mode == TraverseMode.PassAllDestroyableThingsNotWater || traverseParams.mode == TraverseMode.NoPassClosedDoorsOrWater) { bool flag = this.CheckCellBasedReachability(start, dest, peMode, traverseParams); this.FinalizeCheck(); result = flag; } else { bool flag2 = this.CheckRegionBasedReachability(traverseParams); this.FinalizeCheck(); result = flag2; } } } } finally { this.working = false; } return(result); }
private bool CheckCellBasedReachability(IntVec3 start, LocalTargetInfo dest, PathEndMode peMode, TraverseParms traverseParams) { IntVec3 foundCell = IntVec3.Invalid; Region[] directRegionGrid = this.regionGrid.DirectGrid; PathGrid pathGrid = this.map.pathGrid; CellIndices cellIndices = this.map.cellIndices; this.map.floodFiller.FloodFill(start, delegate(IntVec3 c) { int num = cellIndices.CellToIndex(c); if ((traverseParams.mode == TraverseMode.PassAllDestroyableThingsNotWater || traverseParams.mode == TraverseMode.NoPassClosedDoorsOrWater) && c.GetTerrain(this.map).IsWater) { return(false); } if (traverseParams.mode == TraverseMode.PassAllDestroyableThings || traverseParams.mode == TraverseMode.PassAllDestroyableThingsNotWater) { if (!pathGrid.WalkableFast(num)) { Building edifice = c.GetEdifice(this.map); if (edifice == null || !PathFinder.IsDestroyable(edifice)) { return(false); } } } else if (traverseParams.mode != TraverseMode.NoPassClosedDoorsOrWater) { Log.ErrorOnce("Do not use this method for non-cell based modes!", 938476762, false); if (!pathGrid.WalkableFast(num)) { return(false); } } Region region = directRegionGrid[num]; return(region == null || region.Allows(traverseParams, false)); }, delegate(IntVec3 c) { if (ReachabilityImmediate.CanReachImmediate(c, dest, this.map, peMode, traverseParams.pawn)) { foundCell = c; return(true); } return(false); }, 2147483647, false, null); if (foundCell.IsValid) { if (this.CanUseCache(traverseParams.mode)) { Region validRegionAt = this.regionGrid.GetValidRegionAt(foundCell); if (validRegionAt != null) { for (int i = 0; i < this.startingRegions.Count; i++) { this.cache.AddCachedResult(this.startingRegions[i].Room, validRegionAt.Room, traverseParams, true); } } } return(true); } if (this.CanUseCache(traverseParams.mode)) { for (int j = 0; j < this.startingRegions.Count; j++) { for (int k = 0; k < this.destRegions.Count; k++) { this.cache.AddCachedResult(this.startingRegions[j].Room, this.destRegions[k].Room, traverseParams, false); } } } return(false); }
internal bool <> m__0(Region from, Region reg) { return(reg.Allows(this.traverseParms, false)); }
private bool CheckRegionBasedReachability(TraverseParms traverseParams) { while (openQueue.Count > 0) { Region region = openQueue.Dequeue(); for (int i = 0; i < region.links.Count; i++) { RegionLink regionLink = region.links[i]; for (int j = 0; j < 2; j++) { Region region2 = regionLink.regions[j]; if (region2 == null || region2.reachedIndex == reachedIndex || !region2.type.Passable() || !region2.Allows(traverseParams, isDestination: false)) { continue; } if (destRegions.Contains(region2)) { for (int k = 0; k < startingRegions.Count; k++) { cache.AddCachedResult(startingRegions[k].Room, region2.Room, traverseParams, reachable: true); } return(true); } QueueNewOpenRegion(region2); } } } for (int l = 0; l < startingRegions.Count; l++) { for (int m = 0; m < destRegions.Count; m++) { cache.AddCachedResult(startingRegions[l].Room, destRegions[m].Room, traverseParams, reachable: false); } } return(false); }
public bool CanReach(IntVec3 start, LocalTargetInfo dest, PathEndMode peMode, TraverseParms traverseParams) { if (working) { Log.ErrorOnce("Called CanReach() while working. This should never happen. Suppressing further errors.", 7312233); return(false); } if (traverseParams.pawn != null) { if (!traverseParams.pawn.Spawned) { return(false); } if (traverseParams.pawn.Map != map) { Log.Error(string.Concat("Called CanReach() with a pawn spawned not on this map. This means that we can't check his reachability here. Pawn's current map should have been used instead of this one. pawn=", traverseParams.pawn, " pawn.Map=", traverseParams.pawn.Map, " map=", map)); return(false); } } if (ReachabilityImmediate.CanReachImmediate(start, dest, map, peMode, traverseParams.pawn)) { return(true); } if (!dest.IsValid) { return(false); } if (dest.HasThing && dest.Thing.Map != map) { return(false); } if (!start.InBounds(map) || !dest.Cell.InBounds(map)) { return(false); } if ((peMode == PathEndMode.OnCell || peMode == PathEndMode.Touch || peMode == PathEndMode.ClosestTouch) && traverseParams.mode != TraverseMode.NoPassClosedDoorsOrWater && traverseParams.mode != TraverseMode.PassAllDestroyableThingsNotWater) { Room room = RegionAndRoomQuery.RoomAtFast(start, map); if (room != null && room == RegionAndRoomQuery.RoomAtFast(dest.Cell, map)) { return(true); } } if (traverseParams.mode == TraverseMode.PassAllDestroyableThings) { TraverseParms traverseParams2 = traverseParams; traverseParams2.mode = TraverseMode.PassDoors; if (CanReach(start, dest, peMode, traverseParams2)) { return(true); } } dest = (LocalTargetInfo)GenPath.ResolvePathMode(traverseParams.pawn, dest.ToTargetInfo(map), ref peMode); working = true; try { pathGrid = map.pathGrid; regionGrid = map.regionGrid; reachedIndex++; destRegions.Clear(); switch (peMode) { case PathEndMode.OnCell: { Region region = dest.Cell.GetRegion(map); if (region != null && region.Allows(traverseParams, isDestination: true)) { destRegions.Add(region); } break; } case PathEndMode.Touch: TouchPathEndModeUtility.AddAllowedAdjacentRegions(dest, traverseParams, map, destRegions); break; } if (destRegions.Count == 0 && traverseParams.mode != TraverseMode.PassAllDestroyableThings && traverseParams.mode != TraverseMode.PassAllDestroyableThingsNotWater) { FinalizeCheck(); return(false); } destRegions.RemoveDuplicates(); openQueue.Clear(); numRegionsOpened = 0; DetermineStartRegions(start); if (openQueue.Count == 0 && traverseParams.mode != TraverseMode.PassAllDestroyableThings && traverseParams.mode != TraverseMode.PassAllDestroyableThingsNotWater) { FinalizeCheck(); return(false); } if (startingRegions.Any() && destRegions.Any() && CanUseCache(traverseParams.mode)) { switch (GetCachedResult(traverseParams)) { case BoolUnknown.True: FinalizeCheck(); return(true); case BoolUnknown.False: FinalizeCheck(); return(false); } } if (traverseParams.mode == TraverseMode.PassAllDestroyableThings || traverseParams.mode == TraverseMode.PassAllDestroyableThingsNotWater || traverseParams.mode == TraverseMode.NoPassClosedDoorsOrWater) { bool result = CheckCellBasedReachability(start, dest, peMode, traverseParams); FinalizeCheck(); return(result); } bool result2 = CheckRegionBasedReachability(traverseParams); FinalizeCheck(); return(result2); } finally { working = false; } }
internal bool <> m__0(Region from, Region r) { return(r.Allows(this.traverseParms, true)); }