示例#1
0
 public static IEnumerable <Thing> GetMeditationFociAffectedByBuilding(Map map, ThingDef def, Faction faction, IntVec3 pos, Rot4 rotation)
 {
     if (CountsAsArtificialBuilding(def, faction))
     {
         foreach (Thing item in map.listerThings.ThingsMatching(ThingRequest.ForGroup(ThingRequestGroup.MeditationFocus)))
         {
             CompMeditationFocus compMeditationFocus = item.TryGetComp <CompMeditationFocus>();
             if (compMeditationFocus != null && compMeditationFocus.WillBeAffectedBy(def, faction, pos, rotation))
             {
                 yield return(item);
             }
         }
     }
 }
 public static IEnumerable <LocalTargetInfo> FocusSpotsInTheRoom(Pawn pawn, Room r)
 {
     foreach (Thing containedAndAdjacentThing in r.ContainedAndAdjacentThings)
     {
         CompMeditationFocus compMeditationFocus = containedAndAdjacentThing.TryGetComp <CompMeditationFocus>();
         if (compMeditationFocus != null && compMeditationFocus.CanPawnUse(pawn) && !(containedAndAdjacentThing is Building_Throne) && containedAndAdjacentThing.GetStatValueForPawn(StatDefOf.MeditationFocusStrength, pawn) > 0f)
         {
             LocalTargetInfo localTargetInfo = MeditationSpotForFocus(containedAndAdjacentThing, pawn, r.ContainsCell);
             if (localTargetInfo.IsValid)
             {
                 yield return(localTargetInfo);
             }
         }
     }
 }
示例#3
0
        public static LocalTargetInfo BestFocusAt(LocalTargetInfo spot, Pawn pawn)
        {
            float           num    = 0f;
            LocalTargetInfo result = LocalTargetInfo.Invalid;

            foreach (Thing item in GenRadial.RadialDistinctThingsAround(spot.Cell, pawn.MapHeld, FocusObjectSearchRadius, useCenter: false))
            {
                if (GenSight.LineOfSightToThing(spot.Cell, item, pawn.Map) && !(item is Building_Throne))
                {
                    CompMeditationFocus compMeditationFocus = item.TryGetComp <CompMeditationFocus>();
                    if (compMeditationFocus != null && compMeditationFocus.CanPawnUse(pawn))
                    {
                        float statValueForPawn = item.GetStatValueForPawn(StatDefOf.MeditationFocusStrength, pawn);
                        if (statValueForPawn > num)
                        {
                            result = item;
                            num    = statValueForPawn;
                        }
                    }
                }
            }
            return(result);
        }