|
@@ -78,6 +78,14 @@ namespace KairoEngine.Utility
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static Collider GetMouseWorldPositionCollider(int mouseColliderLayerMask)
|
|
|
+ {
|
|
|
+ if(Camera.main == null) return null;
|
|
|
+ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
|
+ if(Physics.Raycast(ray, out RaycastHit raycastHit, 999f, mouseColliderLayerMask)) return raycastHit.collider;
|
|
|
+ else return null;
|
|
|
+ }
|
|
|
+
|
|
|
// Create a Text Popup in the World, no parent
|
|
|
public static void CreateWorldTextPopup(string text, Vector3 localPosition) {
|
|
|
CreateWorldTextPopup(null, text, localPosition, 40, Color.white, localPosition + new Vector3(0, 20), 1f, true);
|
|
@@ -115,6 +123,30 @@ namespace KairoEngine.Utility
|
|
|
public static Vector3 ApplyRotationToVector(Vector3 vec, float angle) {
|
|
|
return Quaternion.Euler(0,0,angle) * vec;
|
|
|
}
|
|
|
+
|
|
|
+ public static List<Vector2Int> GetPointsInRadius(int radius, bool includeOrigin = true)
|
|
|
+ {
|
|
|
+ List<Vector2Int> points = new List<Vector2Int>();
|
|
|
+ if(includeOrigin) points.Add(new Vector2Int(0, 0));
|
|
|
+ for (int i = 1; i < radius; i++)
|
|
|
+ {
|
|
|
+ for (int j = 1; j < radius; j++)
|
|
|
+ {
|
|
|
+ if (i * i + j * j < (radius * radius))
|
|
|
+ {
|
|
|
+ points.Add(new Vector2Int(i,j));
|
|
|
+ points.Add(new Vector2Int(-i,j));
|
|
|
+ points.Add(new Vector2Int(i,-j));
|
|
|
+ points.Add(new Vector2Int(-i,-j));
|
|
|
+ points.Add(new Vector2Int(i, 0));
|
|
|
+ points.Add(new Vector2Int(-i, 0));
|
|
|
+ points.Add(new Vector2Int(0, j));
|
|
|
+ points.Add(new Vector2Int(0, -j));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return points;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|