Exemplo n.º 1
0
        public bool CanAddPlayingOneShot(SoundDef def, SoundInfo info)
        {
            if (!SoundDefHelper.CorrectContextNow(def, info.Maker.Map))
            {
                return(false);
            }
            if ((from s in this.samples
                 where s.subDef.parentDef == def && s.AgeRealTime < 0.05f
                 select s).Count <SampleOneShot>() >= def.MaxSimultaneousSamples)
            {
                return(false);
            }
            SampleOneShot sampleOneShot = this.LeastImportantOf(def);

            return(sampleOneShot == null || this.ImportanceOf(def, info, 0f) >= this.ImportanceOf(sampleOneShot));
        }
Exemplo n.º 2
0
        public bool CanAddPlayingOneShot(SoundDef def, SoundInfo info)
        {
            if (!SoundDefHelper.CorrectContextNow(def, info.Maker.Map))
            {
                return(false);
            }
            if (samples.Where((SampleOneShot s) => s.subDef.parentDef == def && s.AgeRealTime < 0.05f).Count() >= def.MaxSimultaneousSamples)
            {
                return(false);
            }
            SampleOneShot sampleOneShot = LeastImportantOf(def);

            if (sampleOneShot != null && ImportanceOf(def, info, 0f) < ImportanceOf(sampleOneShot))
            {
                return(false);
            }
            return(true);
        }
 public void SampleOneShotManagerUpdate()
 {
     for (int i = 0; i < this.samples.Count; i++)
     {
         this.samples[i].Update();
     }
     this.cleanupList.Clear();
     for (int j = 0; j < this.samples.Count; j++)
     {
         SampleOneShot sampleOneShot = this.samples[j];
         if (sampleOneShot.source == null || !sampleOneShot.source.isPlaying || !SoundDefHelper.CorrectContextNow(sampleOneShot.subDef.parentDef, sampleOneShot.Map))
         {
             if (sampleOneShot.source != null && sampleOneShot.source.isPlaying)
             {
                 sampleOneShot.source.Stop();
             }
             sampleOneShot.SampleCleanup();
             this.cleanupList.Add(sampleOneShot);
         }
     }
     if (this.cleanupList.Count > 0)
     {
         this.samples.RemoveAll((SampleOneShot s) => this.cleanupList.Contains(s));
     }
 }
 public void SampleOneShotManagerUpdate()
 {
     for (int i = 0; i < samples.Count; i++)
     {
         samples[i].Update();
     }
     cleanupList.Clear();
     for (int j = 0; j < samples.Count; j++)
     {
         SampleOneShot sampleOneShot = samples[j];
         if (sampleOneShot.source == null || (!sampleOneShot.source.isPlaying && (!sampleOneShot.subDef.tempoAffectedByGameSpeed || !Find.TickManager.Paused)) || !SoundDefHelper.CorrectContextNow(sampleOneShot.subDef.parentDef, sampleOneShot.Map))
         {
             if (sampleOneShot.source != null && sampleOneShot.source.isPlaying)
             {
                 sampleOneShot.source.Stop();
             }
             sampleOneShot.SampleCleanup();
             cleanupList.Add(sampleOneShot);
         }
     }
     if (cleanupList.Count > 0)
     {
         samples.RemoveAll((SampleOneShot s) => cleanupList.Contains(s));
     }
 }