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