private void InitCollections()
 {
     if ((UnityEngine.Object)collections != (UnityEngine.Object)null)
     {
         return;
     }
     Log("### InitCollections ###");
     try
     {
         collections = gameObject.AddComponent <AudioMateCollectionManager>();
         collections.OnActiveCollectionSelected.RemoveAllListeners();
         collections.OnActiveCollectionSelected.AddListener(OnActiveCollectionSelected);
         collections.OnActiveCollectionNameChanged.RemoveAllListeners();
         collections.OnActiveCollectionNameChanged.AddListener(OnActiveCollectionNameChanged);
         _playRandomClipActionJSON = new JSONStorableAction(Storables.PlayRandomClipAction,
                                                            () => collections.PlayRandomClipAction());
         RegisterAction(_playRandomClipActionJSON);
         _queueRandomClipActionJSON = new JSONStorableAction(Storables.QueueRandomClipAction,
                                                             () => collections.QueueRandomClipAction());
         RegisterAction(_queueRandomClipActionJSON);
         collections.Init(this);
     }
     catch (Exception e)
     {
         SuperController.LogError($"AudioMate.{nameof(AudioMateController)}.{nameof(InitCollections)}: {e}");
     }
 }
        private void UpdateTriggerActionNamesOnCollectionRename(string oldCollectionName, string newCollectionName)
        {
            if (string.IsNullOrEmpty(Tools.TrimAll(oldCollectionName)) || string.IsNullOrEmpty(Tools.TrimAll(newCollectionName)))
            {
                return;
            }

            foreach (var triggerCollider in TriggerColliderChooserJSON.choices)
            {
                var oldTriggerActionName         = GetPlayRandomClipTriggerName(triggerCollider, oldCollectionName);
                var newTriggerActionName         = GetPlayRandomClipTriggerName(triggerCollider, newCollectionName);
                var newTriggerActionReceiverName = AudioMateCollectionManager.GetPlayRandomClipActionName(newCollectionName);

                _triggers.UpdateTriggerAction(oldTriggerActionName, newTriggerActionName, newTriggerActionReceiverName, TriggerManager.StartTriggerAction);
                _triggers.UpdateTriggerAction(oldTriggerActionName, newTriggerActionName, newTriggerActionReceiverName, TriggerManager.EndTriggerAction);
            }
        }
        public void OnAddTriggerButtonClicked(string triggerType = TriggerManager.StartTriggerAction)
        {
            if ((UnityEngine.Object)collections == (UnityEngine.Object)null)
            {
                return;
            }
            if (collections.ActiveCollection == null)
            {
                return;
            }
            var triggerName = GetPlayRandomClipTriggerName(TriggerColliderChooserJSON.val, collections.ActiveCollection.Name);

            if (string.IsNullOrEmpty(triggerName))
            {
                return;
            }
            var receiverTargetName = AudioMateCollectionManager.GetPlayRandomClipActionName(collections.ActiveCollection.Name);
            var newTrigger         = _triggers.AddTriggerAction(TriggerColliderChooserJSON.val, triggerName, storeId, receiverTargetName, triggerType);
            //Log($"Added new {triggerType} action {triggerName} for collider trigger {TriggerColliderChooserJSON.val}");
        }
 private string GetQueueRandomClipTriggerName(string triggerCollider, string collectionName)
 {
     return(Tools.TrimAll($"{triggerCollider}:{AudioMateCollectionManager.GetQueueRandomClipActionName(collectionName)}"));
 }