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

            case TraverseMode.PassDoors:
                return(true);

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

            case TraverseMode.PassAllDestroyableThings:
                return(true);

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

            case TraverseMode.PassAllDestroyableThingsNotWater:
                return(true);

            default:
                throw new NotImplementedException();
            }
        }
            internal bool <> m__1(Region reg)
            {
                Danger danger = reg.DangerFor(this.pawn);
                Map    map    = this.pawn.Map;

                foreach (IntVec3 intVec in reg.Cells)
                {
                    if (intVec.Standable(map))
                    {
                        if (!reg.IsDoorway)
                        {
                            Thing thing = null;
                            float num   = 0f;
                            for (int i = 0; i < this.threats.Count; i++)
                            {
                                float num2 = (float)intVec.DistanceToSquared(this.threats[i].Position);
                                if (thing == null || num2 < num)
                                {
                                    thing = this.threats[i];
                                    num   = num2;
                                }
                            }
                            float num3 = Mathf.Sqrt(num);
                            float f    = Mathf.Min(num3, this.distance);
                            float num4 = Mathf.Pow(f, 1.2f);
                            num4 *= Mathf.InverseLerp(50f, 0f, (intVec - this.pawn.Position).LengthHorizontal);
                            if (intVec.GetRoom(map, RegionType.Set_Passable) != thing.GetRoom(RegionType.Set_Passable))
                            {
                                num4 *= 4.2f;
                            }
                            else if (num3 < 8f)
                            {
                                num4 *= 0.05f;
                            }
                            if (!map.pawnDestinationReservationManager.CanReserve(intVec, this.pawn, false))
                            {
                                num4 *= 0.5f;
                            }
                            if (danger == Danger.Deadly)
                            {
                                num4 *= 0.8f;
                            }
                            if (num4 > this.bestScore)
                            {
                                this.bestPos   = intVec;
                                this.bestScore = num4;
                            }
                        }
                    }
                }
                return(false);
            }
        public static Danger GetDangerFor(this IntVec3 c, Pawn p, Map map)
        {
            Map mapHeld = p.MapHeld;

            if (mapHeld != null && mapHeld == map)
            {
                Region region = c.GetRegion(mapHeld, RegionType.Set_All);
                if (region == null)
                {
                    return(Danger.None);
                }
                return(region.DangerFor(p));
            }
            return(Danger.None);
        }
예제 #4
0
        public static Danger GetDangerFor(this IntVec3 c, Pawn p, Map map)
        {
            Map    mapHeld = p.MapHeld;
            Danger result;

            if (mapHeld == null || mapHeld != map)
            {
                result = Danger.None;
            }
            else
            {
                Region region = c.GetRegion(mapHeld, RegionType.Set_All);
                if (region == null)
                {
                    result = Danger.None;
                }
                else
                {
                    result = region.DangerFor(p);
                }
            }
            return(result);
        }