private static Region ClosestRegionWithinTemperatureRange(IntVec3 root, Map map, TraverseParms traverseParms, RegionType traversableRegionTypes = RegionType.Set_Passable)
        {
            Region        region  = root.GetRegion(map, traversableRegionTypes);
            MapComp_Noise mapComp = map.GetComponent <MapComp_Noise>();

            if (region == null || mapComp == null)
            {
                return(null);
            }
            RegionEntryPredicate entryCondition = (Region from, Region r) => r.Allows(traverseParms, false);
            Region          foundReg            = null;
            RegionProcessor regionProcessor     = delegate(Region r)
            {
                if (r.IsDoorway)
                {
                    return(false);
                }
                if (NoiseUtility.IsSilentEnough(region))
                {
                    foundReg = r;
                    return(true);
                }
                return(false);
            };

            RegionTraverser.BreadthFirstTraverse(region, entryCondition, regionProcessor, 9999, traversableRegionTypes);
            return(foundReg);
        }
 public static void Postfix(ThingWithComps __instance, Map map)
 {
     if (__instance is Plant)
     {
         MapComp_Noise noiseMap = map.GetComponent <MapComp_Noise>();
         if (noiseMap != null)
         {
             noiseMap.AddSoother(__instance, __instance.Position, -3);
         }
     }
 }
Example #3
0
        public static bool IsSilentEnough(Region region, int admitted = 0)
        {
            MapComp_Noise mapComp = region.Map.GetComponent <MapComp_Noise>();

            if (mapComp != null)
            {
                IntVec3             badCell;
                Predicate <IntVec3> badCellFinder = (IntVec3 c) => mapComp.noiseGrid[region.Map.cellIndices.CellToIndex(c)] > admitted && !c.GetTerrain(region.Map).avoidWander;
                return(!region.TryFindRandomCellInRegion(badCellFinder, out badCell));
            }
            return(false);
        }
Example #4
0
 public static void Postfix(WidgetRow row, bool worldView)
 {
     if (worldView)
     {
         return;
     }
     if (row == null || MapComp_Noise.Icon() == null)
     {
         return;
     }
     row.ToggleableIcon(ref MapComp_Noise.toggleShow, MapComp_Noise.Icon(), MapComp_Noise.IconTip(), null, null);
 }
        public static void Prefix(Pawn ___pawn)
        {
            if (KeepQuietSettings.selfAnnoy || !___pawn.RaceProps.Humanlike)
            {
                return;
            }
            MapComp_Noise noiseMap = ___pawn.Map.GetComponent <MapComp_Noise>();

            if (noiseMap != null && noiseMap.currentJobNoise.ContainsKey(___pawn))
            {
                noiseMap.currentJobNoise.Remove(___pawn);
            }
        }
        public static void Prefix(ThingWithComps __instance)
        {
            CompSoother comp = __instance.TryGetComp <CompSoother>();

            if (comp != null)
            {
                MapComp_Noise noiseMap = __instance.Map.GetComponent <MapComp_Noise>();
                if (noiseMap != null)
                {
                    noiseMap.ClearSoother(__instance);
                }
            }
        }
Example #7
0
        public void UpdateSoother()
        {
            MapComp_Noise noiseMap = parent.Map?.GetComponent <MapComp_Noise>();

            if (noiseMap == null)
            {
                return;
            }
            bool shouldBeLitNow = ShouldBeOnNow;

            if (effectOn == shouldBeLitNow)
            {
                return;
            }
            effectOn = shouldBeLitNow;
            if (!effectOn)
            {
                noiseMap.ClearSoother(parent);
                return;
            }
            noiseMap.AddSoother(parent, parent.Position, Props.power, Props.maxLevel);
        }