|  |  | 1 |  | // Copyright (c) 2020-2024 dotBunny Inc. | 
|  |  | 2 |  | // dotBunny licenses this file to you under the BSL-1.0 license. | 
|  |  | 3 |  | // See the LICENSE file in the project root for more information. | 
|  |  | 4 |  |  | 
|  |  | 5 |  | #if !UNITY_DOTSRUNTIME | 
|  |  | 6 |  |  | 
|  |  | 7 |  | using UnityEngine; | 
|  |  | 8 |  |  | 
|  |  | 9 |  | namespace GDX | 
|  |  | 10 |  | { | 
|  |  | 11 |  |     /// <summary> | 
|  |  | 12 |  |     ///     <see cref="UnityEngine.BoxCollider" /> Based Extension Methods | 
|  |  | 13 |  |     /// </summary> | 
|  |  | 14 |  |     /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception> | 
|  |  | 15 |  |     [VisualScriptingCompatible(2)] | 
|  |  | 16 |  |     public static class BoxColliderExtensions | 
|  |  | 17 |  |     { | 
|  |  | 18 |  |         /// <summary> | 
|  |  | 19 |  |         ///     Is the <paramref name="worldPosition" /> inside of the <paramref name="targetBoxCollider" />? | 
|  |  | 20 |  |         /// </summary> | 
|  |  | 21 |  |         /// <param name="targetBoxCollider">The <see cref="BoxCollider" /> to use for evaluation.</param> | 
|  |  | 22 |  |         /// <param name="worldPosition">A <see cref="Vector3" /> point in world space.</param> | 
|  |  | 23 |  |         /// <returns>true/false if the world position is contained within the <paramref name="targetBoxCollider" />.</re | 
|  |  | 24 |  |         public static bool ContainsPosition(this BoxCollider targetBoxCollider, Vector3 worldPosition) | 
|  | 0 | 25 |  |         { | 
|  | 0 | 26 |  |             worldPosition = targetBoxCollider.transform.InverseTransformPoint(worldPosition) - targetBoxCollider.center; | 
|  |  | 27 |  |  | 
|  | 0 | 28 |  |             Vector3 cachedSize = targetBoxCollider.size; | 
|  |  | 29 |  |  | 
|  | 0 | 30 |  |             float halfX = cachedSize.x * 0.5f; | 
|  | 0 | 31 |  |             float halfY = cachedSize.y * 0.5f; | 
|  | 0 | 32 |  |             float halfZ = cachedSize.z * 0.5f; | 
|  |  | 33 |  |  | 
|  | 0 | 34 |  |             return worldPosition.x < halfX && worldPosition.x > -halfX && | 
|  |  | 35 |  |                    worldPosition.y < halfY && worldPosition.y > -halfY && | 
|  |  | 36 |  |                    worldPosition.z < halfZ && worldPosition.z > -halfZ; | 
|  | 0 | 37 |  |         } | 
|  |  | 38 |  |     } | 
|  |  | 39 |  | } | 
|  |  | 40 |  | #endif // !UNITY_DOTSRUNTIME |