summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/PhysicsHelpers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/PhysicsHelpers.cs')
-rw-r--r--Client/Assembly-CSharp/PhysicsHelpers.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/PhysicsHelpers.cs b/Client/Assembly-CSharp/PhysicsHelpers.cs
new file mode 100644
index 0000000..706073f
--- /dev/null
+++ b/Client/Assembly-CSharp/PhysicsHelpers.cs
@@ -0,0 +1,38 @@
+using System;
+using UnityEngine;
+
+public static class PhysicsHelpers
+{
+ private static RaycastHit2D[] castHits = new RaycastHit2D[20];
+
+ private static Vector2 temp = default(Vector2);
+
+ private static ContactFilter2D filter = new ContactFilter2D
+ {
+ useLayerMask = true
+ };
+
+ public static bool AnythingBetween(Vector2 source, Vector2 target, int layerMask, bool useTriggers)
+ {
+ PhysicsHelpers.filter.layerMask = layerMask;
+ PhysicsHelpers.filter.useTriggers = useTriggers;
+ PhysicsHelpers.temp.x = target.x - source.x;
+ PhysicsHelpers.temp.y = target.y - source.y;
+ return Physics2D.Raycast(source, PhysicsHelpers.temp, PhysicsHelpers.filter, PhysicsHelpers.castHits, PhysicsHelpers.temp.magnitude) > 0;
+ }
+
+ public static bool AnyNonTriggersBetween(Vector2 source, Vector2 dirNorm, float mag, int layerMask)
+ {
+ int num = Physics2D.RaycastNonAlloc(source, dirNorm, PhysicsHelpers.castHits, mag, layerMask);
+ bool result = false;
+ for (int i = 0; i < num; i++)
+ {
+ if (!PhysicsHelpers.castHits[i].collider.isTrigger)
+ {
+ result = true;
+ break;
+ }
+ }
+ return result;
+ }
+}