Chatterer.chatterer.set_beep_clip C# (CSharp) Method

set_beep_clip() private method

private set_beep_clip ( BeepSource beepsource ) : void
beepsource BeepSource
return void
        private void set_beep_clip(BeepSource beepsource)
        {
            if (beepsource.current_clip == "First")
            {
                //"First" is used when creating a new beepsource
                //if (debugging) Debug.Log("[CHATR] beep AudioClip is \"First\"");
                //pick any AudioClip (when adding a new beepsource)

                //dump all values into a List
                //get a random index for that list
                //assign
                List<AudioClip> val_list = new List<AudioClip>();
                foreach (AudioClip val in dict_probe_samples.Values)
                {
                    val_list.Add(val);
                }
                beepsource.audiosource.clip = val_list[0];
                string s = "";
                if (dict_probe_samples2.TryGetValue(beepsource.audiosource.clip, out s))
                {
                    beepsource.current_clip = s;
                    if (debugging) Debug.Log("[CHATR] \"First\" AudioClip set :: current_clip = " + s);
                }
            }
            else if (beepsource.current_clip == "Random")
            {
                if (debugging) Debug.Log("[CHATR] setting random AudioClip...");
                List<AudioClip> clip_list = new List<AudioClip>();
                foreach (AudioClip clip in dict_probe_samples.Values)
                {
                    clip_list.Add(clip);
                }
                beepsource.audiosource.clip = clip_list[rand.Next(0, clip_list.Count)];
                string s = "";
                if (dict_probe_samples2.TryGetValue(beepsource.audiosource.clip, out s))
                {
                    beepsource.current_clip = s;
                    if (debugging) Debug.Log("[CHATR] beep AudioClip randomized :: current_clip = " + s);
                }
            }
            else
            {
                AudioClip temp_clip = new AudioClip();

                //broken here current_clip == null

                if (dict_probe_samples.TryGetValue(beepsource.current_clip, out temp_clip))
                {
                    beepsource.audiosource.clip = temp_clip;
                    string s = "";
                    if (dict_probe_samples2.TryGetValue(beepsource.audiosource.clip, out s))
                    {
                        beepsource.current_clip = s;
                        if (debugging) Debug.Log("[CHATR] beep AudioClip set :: current_clip = " + s);
                    }
                }
                else
                {
                    if (debugging) Debug.LogError("[CHATR] Could not find AudioClip for key " + beepsource.current_clip + " :: setting AudioClip to \"First\"");
                    beepsource.current_clip = "First";
                    set_beep_clip(beepsource);
                }
            }
        }
chatterer