using System.Collections.Generic; using UnityAtoms.BaseAtoms; using UnityEngine; using UnityEngine.Events; using UnityAtoms.Tags; namespace MAVRIC.GEEKCup { [RequireComponent(typeof(Collider))] public class OnColliderTrigger : MonoBehaviour { public bool invertResult = false; // TODO: Update this to use a UnityAtoms BoolReference [SerializeField] private UnityEvent onTrigger; [SerializeField] private LayerMask layerMask = 1 >> 0; [SerializeField] private List tagsMask = new (); private void OnTriggerEnter(Collider other) { // if ((1 << other.gameObject.layer & layerMask) == 0) return; var hasValidTags = other.gameObject.HasAnyTag(tagsMask); Debug.Log($"HasValidTags: {hasValidTags}"); if (hasValidTags) { var result = invertResult ? false : true; Debug.Log(result); onTrigger?.Invoke(result); } } private void OnTriggerExit(Collider other) { var hasValidTags = other.gameObject.HasAnyTag(tagsMask); Debug.Log($"HasValidTags: {hasValidTags}"); if (hasValidTags) { var result = invertResult ? true : false; Debug.Log($"Result: {result}"); onTrigger?.Invoke(result); } } } }