using System; using SUISSEngine; using UnityEngine; [RequireComponent(typeof(BoxCollider2D), typeof(Rigidbody2D), typeof(AudioSource))] [RequireComponent(typeof(Clickable))] public class CIGPlayOnClick : MonoBehaviour { private void Awake() { this._audioSource = base.GetComponent(); } private void Start() { base.GetComponent().isKinematic = true; base.GetComponent().isTrigger = true; if (this.clickable != null) { this.clickable.OnClickEvent += this.OnClickEvent; } } private void OnDestroy() { if (this.clickable != null) { this.clickable.OnClickEvent -= this.OnClickEvent; } } private void OnClickEvent(GameObject target) { if (Singleton.Instance.SoundEffectsEnabled && this.SoundFx != null) { this._audioSource.PlayOneShot(this.SoundFx); } } [SerializeField] private AudioClip SoundFx; [SerializeField] [SelfReference] private Clickable clickable; private AudioSource _audioSource; }