2023-03-28 19:52:26 +03:00
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace DotRecast.Core
|
|
|
|
{
|
|
|
|
public struct Vector2f
|
|
|
|
{
|
|
|
|
public float x;
|
|
|
|
public float y;
|
2023-04-15 03:31:51 +03:00
|
|
|
|
2023-04-16 11:34:04 +03:00
|
|
|
public static Vector2f Zero { get; } = new Vector2f { x = 0, y = 0 };
|
2023-04-16 06:19:41 +03:00
|
|
|
|
2023-04-15 03:31:51 +03:00
|
|
|
public float Get(int idx)
|
|
|
|
{
|
|
|
|
if (0 == idx)
|
|
|
|
return x;
|
|
|
|
|
|
|
|
if (1 == idx)
|
|
|
|
return y;
|
|
|
|
|
|
|
|
throw new IndexOutOfRangeException("vector2f index out of range");
|
|
|
|
}
|
2023-05-08 17:12:11 +03:00
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
{
|
|
|
|
if (!(obj is Vector2f))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return Equals((Vector2f)obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool Equals(Vector2f other)
|
|
|
|
{
|
|
|
|
return x.Equals(other.x) &&
|
|
|
|
y.Equals(other.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
{
|
|
|
|
int hash = x.GetHashCode();
|
|
|
|
hash = RcHashCodes.CombineHashCodes(hash, y.GetHashCode());
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool operator ==(Vector2f left, Vector2f right)
|
|
|
|
{
|
|
|
|
return left.Equals(right);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool operator !=(Vector2f left, Vector2f right)
|
|
|
|
{
|
|
|
|
return !left.Equals(right);
|
|
|
|
}
|
2023-03-28 19:52:26 +03:00
|
|
|
}
|
|
|
|
}
|