private void Cleanup()
 {
     if (this.def.subSounds.Count > 0)
     {
         Find.SoundRoot.sustainerManager.DeregisterSustainer(this);
         for (int i = 0; i < this.subSustainers.Count; i++)
         {
             this.subSustainers[i].Cleanup();
         }
     }
     if (this.def.sustainStopSound != null)
     {
         if (this.worldRootObject != null)
         {
             Map map = this.info.Maker.Map;
             if (map != null)
             {
                 SoundInfo soundInfo = SoundInfo.InMap(new TargetInfo(this.worldRootObject.transform.position.ToIntVec3(), map, false), MaintenanceType.None);
                 this.def.sustainStopSound.PlayOneShot(soundInfo);
             }
         }
         else
         {
             this.def.sustainStopSound.PlayOneShot(SoundInfo.OnCamera(MaintenanceType.None));
         }
     }
     if (this.worldRootObject != null)
     {
         UnityEngine.Object.Destroy(this.worldRootObject);
     }
     DebugSoundEventsLog.Notify_SustainerEnded(this, this.info);
 }
Example #2
0
 public static void PlayOneShotOnCamera(this SoundDef soundDef, Map onlyThisMap = null)
 {
     if (!UnityData.IsInMainThread)
     {
         return;
     }
     if (onlyThisMap != null && (Find.VisibleMap != onlyThisMap || WorldRendererUtility.WorldRenderedNow))
     {
         return;
     }
     if (soundDef == null)
     {
         return;
     }
     if (soundDef.subSounds.Count > 0)
     {
         bool flag = false;
         for (int i = 0; i < soundDef.subSounds.Count; i++)
         {
             if (soundDef.subSounds[i].onCamera)
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             Log.Error("Tried to play " + soundDef + " on camera but it has no on-camera subSounds.");
         }
     }
     soundDef.PlayOneShot(SoundInfo.OnCamera(MaintenanceType.None));
 }
Example #3
0
 private void Cleanup()
 {
     if (def.subSounds.Count > 0)
     {
         Find.SoundRoot.sustainerManager.DeregisterSustainer(this);
         for (int i = 0; i < subSustainers.Count; i++)
         {
             subSustainers[i].Cleanup();
         }
     }
     if (def.sustainStopSound != null)
     {
         if (worldRootObject != null)
         {
             Map map = info.Maker.Map;
             if (map != null)
             {
                 SoundInfo soundInfo = SoundInfo.InMap(new TargetInfo(worldRootObject.transform.position.ToIntVec3(), map));
                 def.sustainStopSound.PlayOneShot(soundInfo);
             }
         }
         else
         {
             def.sustainStopSound.PlayOneShot(SoundInfo.OnCamera());
         }
     }
     if (worldRootObject != null)
     {
         Object.Destroy(worldRootObject);
     }
     DebugSoundEventsLog.Notify_SustainerEnded(this, info);
 }
Example #4
0
 public static void PlayOneShotOnCamera(this SoundDef soundDef, Map onlyThisMap = null)
 {
     if (UnityData.IsInMainThread)
     {
         if (onlyThisMap != null)
         {
             if (Find.VisibleMap != onlyThisMap)
             {
                 return;
             }
             if (WorldRendererUtility.WorldRenderedNow)
             {
                 return;
             }
         }
         if (soundDef != null)
         {
             if (soundDef.subSounds.Count > 0)
             {
                 bool flag = false;
                 int  num  = 0;
                 while (num < soundDef.subSounds.Count)
                 {
                     if (!soundDef.subSounds[num].onCamera)
                     {
                         num++;
                         continue;
                     }
                     flag = true;
                     break;
                 }
                 if (!flag)
                 {
                     Log.Error("Tried to play " + soundDef + " on camera but it has no on-camera subSounds.");
                 }
             }
             soundDef.PlayOneShot(SoundInfo.OnCamera(MaintenanceType.None));
         }
     }
 }
 public Sustainer(SoundDef def, SoundInfo info)
 {
     this.def  = def;
     this.info = info;
     if (def.subSounds.Count > 0)
     {
         foreach (KeyValuePair <string, float> keyValuePair in info.DefinedParameters)
         {
             this.externalParams[keyValuePair.Key] = keyValuePair.Value;
         }
         if (def.HasSubSoundsInWorld)
         {
             if (info.IsOnCamera)
             {
                 Log.Error("Playing sound " + def.ToString() + " on camera, but it has sub-sounds in the world.", false);
             }
             this.worldRootObject = new GameObject("SustainerRootObject_" + def.defName);
             this.UpdateRootObjectPosition();
         }
         else if (!info.IsOnCamera)
         {
             info = SoundInfo.OnCamera(info.Maintenance);
         }
         Find.SoundRoot.sustainerManager.RegisterSustainer(this);
         if (!info.IsOnCamera)
         {
             Find.SoundRoot.sustainerManager.UpdateAllSustainerScopes();
         }
         for (int i = 0; i < def.subSounds.Count; i++)
         {
             this.subSustainers.Add(new SubSustainer(this, def.subSounds[i]));
         }
     }
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         this.lastMaintainTick  = Find.TickManager.TicksGame;
         this.lastMaintainFrame = Time.frameCount;
     });
 }
Example #6
0
 public static void PlayOneShotOnCamera(this SoundDef soundDef, Map onlyThisMap = null)
 {
     if (UnityData.IsInMainThread && (onlyThisMap == null || (Find.CurrentMap == onlyThisMap && !WorldRendererUtility.WorldRenderedNow)) && soundDef != null)
     {
         if (soundDef.subSounds.Count > 0)
         {
             bool flag = false;
             for (int i = 0; i < soundDef.subSounds.Count; i++)
             {
                 if (soundDef.subSounds[i].onCamera)
                 {
                     flag = true;
                     break;
                 }
             }
             if (!flag)
             {
                 Log.Error("Tried to play " + soundDef + " on camera but it has no on-camera subSounds.");
             }
         }
         soundDef.PlayOneShot(SoundInfo.OnCamera());
     }
 }
 public static void PlayOneShotOnCamera(this SoundDef soundDef, Map onlyThisMap = null)
 {
     if (!UnityData.IsInMainThread || (onlyThisMap != null && (Find.CurrentMap != onlyThisMap || WorldRendererUtility.WorldRenderedNow)) || soundDef == null)
     {
         return;
     }
     if (soundDef.subSounds.Count > 0)
     {
         bool flag = false;
         for (int i = 0; i < soundDef.subSounds.Count; i++)
         {
             if (soundDef.subSounds[i].onCamera)
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             Log.Error(string.Concat("Tried to play ", soundDef, " on camera but it has no on-camera subSounds."));
         }
     }
     soundDef.PlayOneShot(SoundInfo.OnCamera());
 }