Esempio n. 1
0
        public bool Allows(TraverseParms tp, bool isDestination)
        {
            if (tp.mode != TraverseMode.PassAllDestroyableThings && tp.mode != TraverseMode.PassAllDestroyableThingsNotWater && !type.Passable())
            {
                return(false);
            }
            if (tp.maxDanger < Danger.Deadly && tp.pawn != null)
            {
                Danger danger = DangerFor(tp.pawn);
                if (isDestination || danger == Danger.Deadly)
                {
                    VehicleRegion region = VehicleRegionAndRoomQuery.GetRegion(tp.pawn, RegionType.Set_All);
                    if ((region == null || danger > region.DangerFor(tp.pawn)) && danger > tp.maxDanger)
                    {
                        return(false);
                    }
                }
            }
            switch (tp.mode)
            {
            case TraverseMode.ByPawn:
            {
                if (door == null)
                {
                    return(true);
                }
                ByteGrid avoidGrid = tp.pawn.GetAvoidGrid(true);
                if (avoidGrid != null && avoidGrid[door.Position] == 255)
                {
                    return(false);
                }
                if (tp.pawn.HostileTo(door))
                {
                    return(door.CanPhysicallyPass(tp.pawn) || tp.canBash);
                }
                return(door.CanPhysicallyPass(tp.pawn) && !door.IsForbiddenToPass(tp.pawn));
            }

            case TraverseMode.PassDoors:
                return(true);

            case TraverseMode.NoPassClosedDoors:
                return(door == null || door.FreePassage);

            case TraverseMode.PassAllDestroyableThings:
                return(true);

            case TraverseMode.NoPassClosedDoorsOrWater:
                return(door == null || door.FreePassage);

            case TraverseMode.PassAllDestroyableThingsNotWater:
                return(true);

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 2
0
 public static VehicleRegion GetRegion(this IntVec3 loc, Map map, RegionType allowedRegionTypes = RegionType.Set_Passable)
 {
     return(VehicleRegionAndRoomQuery.RegionAt(loc, map, allowedRegionTypes));
 }