| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | [Serializable] |
| | 6 | | public abstract class TriggerArea |
| | 7 | | { |
| | 8 | | public abstract HashSet<GameObject> DetectAvatars(in Vector3 center, in Quaternion rotation, in HashSet<Collider> ex |
| | 9 | |
|
| | 10 | | } |
| | 11 | |
|
| | 12 | | [Serializable] |
| | 13 | | public class BoxTriggerArea : TriggerArea |
| | 14 | | { |
| | 15 | | internal const string AVATAR_TRIGGER_LAYER = "AvatarTriggerDetection"; |
| | 16 | | public Vector3 box; |
| | 17 | |
|
| | 18 | | public override HashSet<GameObject> DetectAvatars(in Vector3 center, in Quaternion rotation, in HashSet<Collider> ex |
| | 19 | | { |
| 64 | 20 | | Collider[] colliders = Physics.OverlapBox(center, box * 0.5f, rotation, |
| | 21 | | LayerMask.GetMask(AVATAR_TRIGGER_LAYER), QueryTriggerInteraction.Collide); |
| | 22 | |
|
| 64 | 23 | | if (colliders.Length == 0) |
| | 24 | | { |
| 46 | 25 | | return null; |
| | 26 | | } |
| | 27 | |
|
| 18 | 28 | | bool hasExcludeList = excludeColliders != null; |
| 18 | 29 | | HashSet<GameObject> result = new HashSet<GameObject>(); |
| 132 | 30 | | foreach (Collider collider in colliders) |
| | 31 | | { |
| 48 | 32 | | if (hasExcludeList && excludeColliders.Contains(collider)) |
| | 33 | | { |
| | 34 | | continue; |
| | 35 | | } |
| 36 | 36 | | result.Add(collider.transform.parent.gameObject); |
| | 37 | | } |
| 18 | 38 | | return result; |
| | 39 | | } |
| | 40 | | } |