Private
Public Access
1
0
Files
2026-03-11 02:01:27 +01:00

33 lines
1008 B
C#

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;
}
}