<commit_before>﻿using UnityEngine;
using UDBase.Utils;
using UDBase.Controllers.SoundSystem;

namespace UDBase.Controllers.MusicSystem {
	public class MusicUtility : MonoBehaviour {
		SoundSource _currentSource;

		public void StopTrack() {
			if ( _currentSource ) {
				_currentSource.Stop();
				_currentSource = null;
				Destroy(_currentSource);
			}
		}

		SoundSource SelectSource(MusicHolder holder) {
			if ( holder.Sources.Count > 0 ) {
				return RandomUtils.GetItem(holder.Sources);
			}
			return null;
		}

		public void SetupTrack() {
			var holder = GameObject.FindObjectOfType<MusicHolder>();
			if ( holder ) {
				_currentSource = SelectSource(holder);
				DontDestroyOnLoad(_currentSource.gameObject);
			}
		}

		public void Pause() {
			if ( _currentSource ) {
				_currentSource.Pause();
			}
		}

		public void UnPause() {
			if ( _currentSource ) {
				_currentSource.UnPause();
			}
		}
	}
}<commit_msg>Music: Proper way to use fades in on scene music and correclly MusicHolder find;<commit_after>﻿using UnityEngine;
using UDBase.Utils;
using UDBase.Controllers.SoundSystem;

namespace UDBase.Controllers.MusicSystem {
	public class MusicUtility : MonoBehaviour {
		SoundSource _currentSource;

		public void StopTrack() {
			if ( _currentSource ) {
				_currentSource.DestroyOnStop = true;
				_currentSource.Stop();
				_currentSource = null;
			}
		}

		SoundSource SelectSource(MusicHolder holder) {
			if ( holder.Sources.Count > 0 ) {
				return RandomUtils.GetItem(holder.Sources);
			}
			return null;
		}

		public void SetupTrack() {
			var holder = GameObject.FindObjectOfType<MusicHolder>();
			if ( holder ) {
				Destroy(holder);
				_currentSource = SelectSource(holder);
				DontDestroyOnLoad(_currentSource.gameObject);
			}
		}

		public void Pause() {
			if ( _currentSource ) {
				_currentSource.Pause();
			}
		}

		public void UnPause() {
			if ( _currentSource ) {
				_currentSource.UnPause();
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.10367722165474974, 'fraction_numerical': 0.0010214504596527069, 'mean_word_length': 3.513824884792627, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6591746', 'n_tokens_mistral': 751, 'n_tokens_neox': 621, 'n_words': 127}