예제 #1
0
        public ResolvedGrain RandomizedResolvedGrain()
        {
            ResolvedGrain chosenGrain = null;

            for (;;)
            {
                chosenGrain = this.resolvedGrains.RandomElement <ResolvedGrain>();
                if (this.distinctResolvedGrainsCount <= 1)
                {
                    break;
                }
                if (this.repeatMode == RepeatSelectMode.NeverLastHalf)
                {
                    if (!(from g in this.recentlyPlayedResolvedGrains
                          where g.Equals(chosenGrain)
                          select g).Any <ResolvedGrain>())
                    {
                        break;
                    }
                }
                else if (this.repeatMode != RepeatSelectMode.NeverTwice || !chosenGrain.Equals(this.lastPlayedResolvedGrain))
                {
                    break;
                }
            }
            return(chosenGrain);
        }
예제 #2
0
        private void StartSample()
        {
            ResolvedGrain resolvedGrain = subDef.RandomizedResolvedGrain();

            if (resolvedGrain == null)
            {
                Log.Error(string.Concat("SubSustainer for ", subDef, " of ", parent.def, " could not resolve any grains."));
                parent.End();
                return;
            }
            float num  = ((!subDef.sustainLoop) ? resolvedGrain.duration : subDef.sustainLoopDurationRange.RandomInRange);
            float num2 = Time.realtimeSinceStartup + num;

            nextSampleStartTime = num2 + subDef.sustainIntervalRange.RandomInRange;
            if (nextSampleStartTime < Time.realtimeSinceStartup + 0.01f)
            {
                nextSampleStartTime = Time.realtimeSinceStartup + 0.01f;
            }
            if (resolvedGrain is ResolvedGrain_Silence)
            {
                return;
            }
            SampleSustainer sampleSustainer = SampleSustainer.TryMakeAndPlay(this, ((ResolvedGrain_Clip)resolvedGrain).clip, num2);

            if (sampleSustainer != null)
            {
                if (subDef.sustainSkipFirstAttack && Time.frameCount == creationFrame)
                {
                    sampleSustainer.resolvedSkipAttack = true;
                }
                samples.Add(sampleSustainer);
            }
        }
예제 #3
0
        private void StartSample()
        {
            ResolvedGrain resolvedGrain = this.subDef.RandomizedResolvedGrain();

            if (resolvedGrain == null)
            {
                Log.Error("SubSustainer for " + this.subDef + " of " + this.parent.def + " could not resolve any grains.");
                this.parent.End();
            }
            else
            {
                float num  = (!this.subDef.sustainLoop) ? resolvedGrain.duration : this.subDef.sustainLoopDurationRange.RandomInRange;
                float num2 = Time.realtimeSinceStartup + num;
                this.nextSampleStartTime = num2 + this.subDef.sustainIntervalRange.RandomInRange;
                if (this.nextSampleStartTime < Time.realtimeSinceStartup + 0.0099999997764825821)
                {
                    this.nextSampleStartTime = (float)(Time.realtimeSinceStartup + 0.0099999997764825821);
                }
                if (!(resolvedGrain is ResolvedGrain_Silence))
                {
                    SampleSustainer sampleSustainer = SampleSustainer.TryMakeAndPlay(this, ((ResolvedGrain_Clip)resolvedGrain).clip, num2);
                    if (sampleSustainer != null)
                    {
                        if (this.subDef.sustainSkipFirstAttack && Time.frameCount == this.creationFrame)
                        {
                            sampleSustainer.resolvedSkipAttack = true;
                        }
                        this.samples.Add(sampleSustainer);
                    }
                }
            }
        }
예제 #4
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    clip = ContentFinder <AudioClip> .Get(this.clipPath, true);

                    if (clip != null)
                    {
                        this.$current = new ResolvedGrain_Clip(clip);
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        return(true);
                    }
                    Log.Error("Grain couldn't resolve: Clip not found at " + this.clipPath, false);
                    break;

                case 1u:
                    break;

                default:
                    return(false);
                }
                this.$PC = -1;
                return(false);
            }
예제 #5
0
        public ResolvedGrain RandomizedResolvedGrain()
        {
            ResolvedGrain chosenGrain = null;

            while (true)
            {
                chosenGrain = resolvedGrains.RandomElement();
                if (distinctResolvedGrainsCount <= 1)
                {
                    break;
                }
                if (repeatMode == RepeatSelectMode.NeverLastHalf)
                {
                    if (!recentlyPlayedResolvedGrains.Where((ResolvedGrain g) => g.Equals(chosenGrain)).Any())
                    {
                        break;
                    }
                }
                else if (repeatMode != RepeatSelectMode.NeverTwice || !chosenGrain.Equals(lastPlayedResolvedGrain))
                {
                    break;
                }
            }
            return(chosenGrain);
        }
예제 #6
0
        public ResolvedGrain RandomizedResolvedGrain()
        {
            ResolvedGrain chosenGrain = null;

            goto IL_000d;
IL_000d:
            while (true)
            {
                chosenGrain = resolvedGrains.RandomElement();
                if (distinctResolvedGrainsCount <= 1)
                {
                    break;
                }
                if (repeatMode == RepeatSelectMode.NeverLastHalf)
                {
                    if (!(from g in recentlyPlayedResolvedGrains
                          where g.Equals(chosenGrain)
                          select g).Any())
                    {
                        break;
                    }
                }
                else if (repeatMode != RepeatSelectMode.NeverTwice || !chosenGrain.Equals(lastPlayedResolvedGrain))
                {
                    break;
                }
            }
            return(chosenGrain);

IL_008f:
            goto IL_000d;
        }
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                bool flag = false;

                switch (num)
                {
                case 0u:
                    enumerator = ContentFinder <AudioClip> .GetAllInFolder(this.clipFolderPath).GetEnumerator();

                    num = 4294967293u;
                    break;

                case 1u:
                    break;

                default:
                    return(false);
                }
                try
                {
                    switch (num)
                    {
                    }
                    if (enumerator.MoveNext())
                    {
                        folderClip    = enumerator.Current;
                        this.$current = new ResolvedGrain_Clip(folderClip);
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        flag = true;
                        return(true);
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        if (enumerator != null)
                        {
                            enumerator.Dispose();
                        }
                    }
                }
                this.$PC = -1;
                return(false);
            }
예제 #8
0
        private void StartSample()
        {
            ResolvedGrain resolvedGrain = this.subDef.RandomizedResolvedGrain();

            if (resolvedGrain == null)
            {
                Log.Error(string.Concat(new object[]
                {
                    "SubSustainer for ",
                    this.subDef,
                    " of ",
                    this.parent.def,
                    " could not resolve any grains."
                }));
                this.parent.End();
                return;
            }
            float num;

            if (this.subDef.sustainLoop)
            {
                num = this.subDef.sustainLoopDurationRange.RandomInRange;
            }
            else
            {
                num = resolvedGrain.duration;
            }
            float num2 = Time.realtimeSinceStartup + num;

            this.nextSampleStartTime = num2 + this.subDef.sustainIntervalRange.RandomInRange;
            if (this.nextSampleStartTime < Time.realtimeSinceStartup + 0.01f)
            {
                this.nextSampleStartTime = Time.realtimeSinceStartup + 0.01f;
            }
            if (resolvedGrain is ResolvedGrain_Silence)
            {
                return;
            }
            SampleSustainer sampleSustainer = SampleSustainer.TryMakeAndPlay(this, ((ResolvedGrain_Clip)resolvedGrain).clip, num2);

            if (sampleSustainer == null)
            {
                return;
            }
            if (this.subDef.sustainSkipFirstAttack && Time.frameCount == this.creationFrame)
            {
                sampleSustainer.resolvedSkipAttack = true;
            }
            this.samples.Add(sampleSustainer);
        }
예제 #9
0
        public virtual void TryPlay(SoundInfo info)
        {
            if (this.resolvedGrains.Count == 0)
            {
                Log.Error(string.Concat(new object[]
                {
                    "Cannot play ",
                    this.parentDef,
                    " (subSound ",
                    this,
                    "_: No resolved grains."
                }), false);
                return;
            }
            if (!Find.SoundRoot.oneShotManager.CanAddPlayingOneShot(this.parentDef, info))
            {
                return;
            }
            ResolvedGrain      resolvedGrain      = this.RandomizedResolvedGrain();
            ResolvedGrain_Clip resolvedGrain_Clip = resolvedGrain as ResolvedGrain_Clip;

            if (resolvedGrain_Clip != null)
            {
                if (SampleOneShot.TryMakeAndPlay(this, resolvedGrain_Clip.clip, info) == null)
                {
                    return;
                }
                SoundSlotManager.Notify_Played(this.parentDef.slot, resolvedGrain_Clip.clip.length);
            }
            if (this.distinctResolvedGrainsCount > 1)
            {
                if (this.repeatMode == RepeatSelectMode.NeverLastHalf)
                {
                    while (this.recentlyPlayedResolvedGrains.Count >= this.numToAvoid)
                    {
                        this.recentlyPlayedResolvedGrains.Dequeue();
                    }
                    if (this.recentlyPlayedResolvedGrains.Count < this.numToAvoid)
                    {
                        this.recentlyPlayedResolvedGrains.Enqueue(resolvedGrain);
                    }
                }
                else if (this.repeatMode == RepeatSelectMode.NeverTwice)
                {
                    this.lastPlayedResolvedGrain = resolvedGrain;
                }
            }
        }
예제 #10
0
        public virtual void TryPlay(SoundInfo info)
        {
            ResolvedGrain resolvedGrain;

            if (this.resolvedGrains.Count == 0)
            {
                Log.Error("Cannot play " + this.parentDef + " (subSound " + this + "_: No resolved grains.");
            }
            else if (Find.SoundRoot.oneShotManager.CanAddPlayingOneShot(this.parentDef, info))
            {
                resolvedGrain = this.RandomizedResolvedGrain();
                ResolvedGrain_Clip resolvedGrain_Clip = resolvedGrain as ResolvedGrain_Clip;
                if (resolvedGrain_Clip != null)
                {
                    SampleOneShot sampleOneShot = SampleOneShot.TryMakeAndPlay(this, resolvedGrain_Clip.clip, info);
                    if (sampleOneShot != null)
                    {
                        SoundSlotManager.Notify_Played(this.parentDef.slot, resolvedGrain_Clip.clip.length);
                        goto IL_00a6;
                    }
                    return;
                }
                goto IL_00a6;
            }
            return;

IL_00a6:
            if (this.distinctResolvedGrainsCount > 1)
            {
                if (this.repeatMode == RepeatSelectMode.NeverLastHalf)
                {
                    while (this.recentlyPlayedResolvedGrains.Count >= this.numToAvoid)
                    {
                        this.recentlyPlayedResolvedGrains.Dequeue();
                    }
                    if (this.recentlyPlayedResolvedGrains.Count < this.numToAvoid)
                    {
                        this.recentlyPlayedResolvedGrains.Enqueue(resolvedGrain);
                    }
                }
                else if (this.repeatMode == RepeatSelectMode.NeverTwice)
                {
                    this.lastPlayedResolvedGrain = resolvedGrain;
                }
            }
        }
예제 #11
0
 public virtual void TryPlay(SoundInfo info)
 {
     if (resolvedGrains.Count == 0)
     {
         //Log.Error("Cannot play " + parentDef + " (subSound " + this + "_: No resolved grains.");
         //Log.Message("Cannot play " + parentDef + " (subSound " + this + "_: No resolved grains.");
     }
     else
     {
         if (!Find.SoundRoot.oneShotManager.CanAddPlayingOneShot(parentDef, info) || (Current.Game != null && !gameSpeedRange.Includes((int)Find.TickManager.CurTimeSpeed)))
         {
             return;
         }
         ResolvedGrain      resolvedGrain      = RandomizedResolvedGrain();
         ResolvedGrain_Clip resolvedGrain_Clip = resolvedGrain as ResolvedGrain_Clip;
         if (resolvedGrain_Clip != null)
         {
             if (SampleOneShot.TryMakeAndPlay(this, resolvedGrain_Clip.clip, info) == null)
             {
                 return;
             }
             SoundSlotManager.Notify_Played(parentDef.slot, resolvedGrain_Clip.clip.length);
         }
         if (distinctResolvedGrainsCount <= 1)
         {
             return;
         }
         if (repeatMode == RepeatSelectMode.NeverLastHalf)
         {
             while (recentlyPlayedResolvedGrains.Count >= numToAvoid)
             {
                 recentlyPlayedResolvedGrains.Dequeue();
             }
             if (recentlyPlayedResolvedGrains.Count < numToAvoid)
             {
                 recentlyPlayedResolvedGrains.Enqueue(resolvedGrain);
             }
         }
         else if (repeatMode == RepeatSelectMode.NeverTwice)
         {
             lastPlayedResolvedGrain = resolvedGrain;
         }
     }
 }
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.$current = new ResolvedGrain_Silence(this);
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    this.$PC = -1;
                    break;
                }
                return(false);
            }
예제 #13
0
 internal bool <> m__0(ResolvedGrain g)
 {
     return(g.Equals(this.chosenGrain));
 }