| | 1 | | using System.Collections.Generic; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace DCL.ECSComponents.Utils |
| | 5 | | { |
| | 6 | | public static class ECSAvatarUtils |
| | 7 | | { |
| | 8 | | private const string AVATAR_TRIGGER_LAYER = "AvatarTriggerDetection"; |
| | 9 | | private const int MAX_AVATARS = 100; |
| | 10 | |
|
| 1 | 11 | | private static int mask = LayerMask.GetMask(AVATAR_TRIGGER_LAYER); |
| 1 | 12 | | private static Collider[] resultColliders = new Collider[MAX_AVATARS]; // max 100 avatars |
| | 13 | |
|
| | 14 | | public static HashSet<GameObject> DetectAvatars(in Vector3 box, in Vector3 center, in Quaternion rotation, in Ha |
| | 15 | | { |
| 8 | 16 | | HashSet<GameObject> result = new HashSet<GameObject>(); |
| | 17 | |
|
| 8 | 18 | | int collidersFoundAmount = Physics.OverlapBoxNonAlloc(center, box * 0.5f, resultColliders, rotation, mask, Q |
| 8 | 19 | | if (collidersFoundAmount == 0) |
| 3 | 20 | | return result; |
| | 21 | |
|
| 5 | 22 | | bool hasExcludeList = excludeColliders != null; |
| | 23 | |
|
| 22 | 24 | | for (var i = 0; i < collidersFoundAmount; i++) |
| | 25 | | { |
| 6 | 26 | | var collider = resultColliders[i]; |
| 6 | 27 | | if (hasExcludeList && excludeColliders.Contains(collider)) |
| | 28 | | continue; |
| | 29 | |
|
| 5 | 30 | | result.Add(collider.transform.parent.gameObject); |
| | 31 | | } |
| 5 | 32 | | return result; |
| | 33 | | } |
| | 34 | | } |
| | 35 | | } |