reinit branch
This commit is contained in:
32
OrekiWoofsBees.Common/Overlaps.cs
Normal file
32
OrekiWoofsBees.Common/Overlaps.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Vintagestory.API.MathTools;
|
||||
|
||||
namespace OrekiWoofsBees.Common;
|
||||
|
||||
public static class Overlaps
|
||||
{
|
||||
public static bool IsWithinSphericalRadius(BlockPos center, StructVec3i pos, int radius)
|
||||
{
|
||||
return IsWithinSphericalRadiusSq(center, pos, radius * radius);
|
||||
}
|
||||
|
||||
public static bool IsWithinSphericalRadiusSq(BlockPos center, StructVec3i pos, int radiusSq)
|
||||
{
|
||||
int dx = pos.X - center.X;
|
||||
int dy = pos.Y - center.Y;
|
||||
int dz = pos.Z - center.Z;
|
||||
return dx * dx + dy * dy + dz * dz <= radiusSq;
|
||||
}
|
||||
|
||||
public static bool IsWithinSphericalRadius(StructVec3i center, StructVec3i pos, int radius)
|
||||
{
|
||||
return IsWithinSphericalRadiusSq(center, pos, radius * radius);
|
||||
}
|
||||
|
||||
public static bool IsWithinSphericalRadiusSq(StructVec3i center, StructVec3i pos, int radiusSq)
|
||||
{
|
||||
int dx = pos.X - center.X;
|
||||
int dy = pos.Y - center.Y;
|
||||
int dz = pos.Z - center.Z;
|
||||
return dx * dx + dy * dy + dz * dz <= radiusSq;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user