| | 1 | | using System.Collections.Generic; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace ECSSystems.PointerInputSystem |
| | 5 | | { |
| | 6 | | internal static class PointerInputHelper |
| | 7 | | { |
| | 8 | | public static bool IsInputForEntity(Collider pointerEventCollider, IList<Collider> colliders) |
| | 9 | | { |
| 0 | 10 | | return colliders.Contains(pointerEventCollider); |
| | 11 | | } |
| | 12 | |
|
| | 13 | | public static bool IsValidFistanceForEntity(float pointerEventDistance, float maxDistance) |
| | 14 | | { |
| 0 | 15 | | return pointerEventDistance <= maxDistance; |
| | 16 | | } |
| | 17 | |
|
| | 18 | | public static bool IsValidInputForEntity(int pointerEventButton, float pointerEventDistance, float maxDistance, |
| | 19 | | { |
| 10 | 20 | | if (!IsValidFistanceForEntity(pointerEventDistance, maxDistance)) |
| 2 | 21 | | return false; |
| | 22 | |
|
| 8 | 23 | | if (button == ActionButton.Any || (int)button == pointerEventButton) |
| | 24 | | { |
| 7 | 25 | | return true; |
| | 26 | | } |
| 1 | 27 | | return false; |
| | 28 | | } |
| | 29 | |
|
| | 30 | | public static string GetName(this ActionButton button) |
| | 31 | | { |
| | 32 | | const string ACTION_BUTTON_POINTER = "POINTER"; |
| | 33 | | const string ACTION_BUTTON_PRIMARY = "PRIMARY"; |
| | 34 | | const string ACTION_BUTTON_SECONDARY = "SECONDARY"; |
| | 35 | |
|
| | 36 | | switch (button) |
| | 37 | | { |
| | 38 | | case ActionButton.Primary: |
| 0 | 39 | | return ACTION_BUTTON_PRIMARY; |
| | 40 | | case ActionButton.Secondary: |
| 0 | 41 | | return ACTION_BUTTON_SECONDARY; |
| | 42 | | default: |
| 0 | 43 | | return ACTION_BUTTON_POINTER; |
| | 44 | | } |
| | 45 | | } |
| | 46 | | } |
| | 47 | | } |