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);
        }
示例#2
0
        public static void Postfix(SoundDef soundDef, SoundInfo info)
        {
            TargetInfo maker = info.Maker;

            if (maker != null)
            {
                StackTrace st = new StackTrace();
                maker.Map.GetComponent <MapComp_Noise>().AddBang(maker.Cell, NoiseUtility.GetSoundLevel(soundDef));
            }
        }
示例#3
0
        public static void Postfix(SoundDef soundDef, SoundInfo info, Sustainer __result)
        {
            TargetInfo maker = info.Maker;

            if (maker != null && soundDef.sustain)
            {
                int  level = (int)NoiseUtility.GetSoundLevel(soundDef);
                Pawn actor = null;
                if (!KeepQuietSettings.selfAnnoy && maker.Thing != null && maker.Thing is Pawn pawn && pawn.RaceProps.Humanlike)
                {
                    actor = pawn;
                }
                maker.Map.GetComponent <MapComp_Noise>().AddPolluter(__result, maker.Cell, level, actor);
            }
        }