39 lines
904 B
C#
39 lines
904 B
C#
using System;
|
|
using Godot;
|
|
|
|
public static class Helpers
|
|
{
|
|
public static bool IsBetweenInclusive(int value, int min, int max)
|
|
{
|
|
return value >= min && value <= max;
|
|
}
|
|
|
|
public static bool IsBetween(double value, double min, int max)
|
|
{
|
|
return value >= min && value < max;
|
|
}
|
|
|
|
public static bool IsInsideArea(Vector3 area, Vector3 coordinates)
|
|
{
|
|
if (coordinates.X >= area.X || coordinates.Y >= area.Y || coordinates.Z >= area.Z)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (coordinates.X < -area.X || coordinates.Y < -area.Y || coordinates.Z < -area.Z)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public static double GetDistance(Vector3 position1, Vector3 position2)
|
|
{
|
|
double diffX = Math.Abs(position1.X - position2.X);
|
|
double diffY = Math.Abs(position1.Y - position2.Y);
|
|
double diffZ = Math.Abs(position1.Z - position2.Z);
|
|
|
|
return Math.Sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ);
|
|
}
|
|
}
|