Beispiel #1
0
        public static void PlayImpactSound(Thing hitThing, ImpactSoundTypeDef ist, Map map)
        {
            if (ist == null)
            {
                return;
            }
            if (ist.playOnlyIfHitPawn && !(hitThing is Pawn))
            {
                return;
            }
            if (map == null)
            {
                Log.Warning("Can't play impact sound because map is null.", false);
                return;
            }
            SoundDef soundDef;

            if (hitThing.Stuff != null)
            {
                soundDef = hitThing.Stuff.stuffProps.soundImpactStuff;
            }
            else
            {
                soundDef = hitThing.def.soundImpactDefault;
            }
            if (soundDef.NullOrUndefined())
            {
                soundDef = SoundDefOf.BulletImpact_Ground;
            }
            soundDef.PlayOneShot(new TargetInfo(hitThing.PositionHeld, map, false));
        }
Beispiel #2
0
 public static void PlayImpactSound(Thing hitThing, ImpactSoundTypeDef ist, Map map)
 {
     if (ist != null && (!ist.playOnlyIfHitPawn || hitThing is Pawn))
     {
         if (map == null)
         {
             Log.Warning("Can't play impact sound because map is null.");
         }
         else
         {
             SoundDef soundDef = null;
             soundDef = ((hitThing.Stuff == null) ? hitThing.def.soundImpactDefault : hitThing.Stuff.stuffProps.soundImpactStuff);
             if (soundDef.NullOrUndefined())
             {
                 soundDef = SoundDefOf.BulletImpact_Ground;
             }
             soundDef.PlayOneShot(new TargetInfo(hitThing.PositionHeld, map));
         }
     }
 }