| | 1 | | using DCL.Configuration; |
| | 2 | |
|
| | 3 | | namespace DCL.ECSComponents.Utils |
| | 4 | | { |
| | 5 | | public static class LayerMaskUtils |
| | 6 | | { |
| | 7 | | private const int nonCustomLayers = (int)ColliderLayer.ClPhysics |
| | 8 | | | (int)ColliderLayer.ClPointer |
| | 9 | | | (int)ColliderLayer.ClNone |
| | 10 | | | (int)ColliderLayer.ClReserved1 |
| | 11 | | | (int)ColliderLayer.ClReserved2 |
| | 12 | | | (int)ColliderLayer.ClReserved3 |
| | 13 | | | (int)ColliderLayer.ClReserved4 |
| | 14 | | | (int)ColliderLayer.ClReserved5 |
| | 15 | | | (int)ColliderLayer.ClReserved6; |
| | 16 | |
|
| | 17 | | public static bool IsInLayerMask(uint layerMask, int layer) => |
| 56 | 18 | | (layer & layerMask) != 0; |
| | 19 | |
|
| | 20 | | public static bool LayerMaskHasAnySDKCustomLayer(uint layerMask) => |
| 157 | 21 | | (layerMask & ~nonCustomLayers) != 0; |
| | 22 | |
|
| | 23 | | public static int? SdkLayerMaskToUnityLayer(uint mask) |
| | 24 | | { |
| | 25 | | const int LAYER_PHYSICS = (int)ColliderLayer.ClPhysics; |
| | 26 | | const int LAYER_POINTER = (int)ColliderLayer.ClPointer; |
| | 27 | | const int LAYER_PHYSICS_POINTER = LAYER_PHYSICS | LAYER_POINTER; |
| | 28 | |
|
| 80 | 29 | | if ((mask & LAYER_PHYSICS_POINTER) == LAYER_PHYSICS_POINTER) |
| 51 | 30 | | return PhysicsLayers.defaultLayer; |
| | 31 | |
|
| 29 | 32 | | if ((mask & LAYER_PHYSICS) == LAYER_PHYSICS) |
| 10 | 33 | | return PhysicsLayers.characterOnlyLayer; |
| | 34 | |
|
| 19 | 35 | | if ((mask & LAYER_POINTER) == LAYER_POINTER) |
| 10 | 36 | | return PhysicsLayers.onPointerEventLayer; |
| | 37 | |
|
| 9 | 38 | | if (LayerMaskHasAnySDKCustomLayer(mask)) |
| 8 | 39 | | return PhysicsLayers.sdkCustomLayer; |
| | 40 | |
|
| 1 | 41 | | return null; |
| | 42 | | } |
| | 43 | | } |
| | 44 | | } |