2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Base/Vector2i.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Base/Vector2.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Base/Shared.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Library/Random.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const Vector2i Vector2i::NIL = Vector2i(0);
|
2016-02-20 23:25:00 +01:00
|
|
|
const Vector2i Vector2i::MIN = Vector2i(NumLimit< Vector2i::Value >::Min);
|
|
|
|
const Vector2i Vector2i::MAX = Vector2i(NumLimit< Vector2i::Value >::Max);
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQChar Vector2i::Delim = ',';
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger Vector2i::Typename(HSQUIRRELVM vm)
|
|
|
|
{
|
|
|
|
static SQChar name[] = _SC("Vector2i");
|
|
|
|
sq_pushstring(vm, name, sizeof(name));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i::Vector2i()
|
2015-09-30 02:56:11 +02:00
|
|
|
: x(0), y(0)
|
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Vector2i::Vector2i(Value sv)
|
|
|
|
: x(sv), y(sv)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Vector2i::Vector2i(Value xv, Value yv)
|
|
|
|
: x(xv), y(yv)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator = (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x = s;
|
|
|
|
y = s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
Vector2i & Vector2i::operator = (CSStr values)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
Set(GetVector2i(values, Delim));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
Vector2i & Vector2i::operator = (const Vector2 & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
x = Value(v.x);
|
|
|
|
y = Value(v.y);
|
2015-09-30 02:56:11 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator += (const Vector2i & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x += v.x;
|
|
|
|
y += v.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator -= (const Vector2i & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x -= v.x;
|
|
|
|
y -= v.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator *= (const Vector2i & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x *= v.x;
|
|
|
|
y *= v.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator /= (const Vector2i & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x /= v.x;
|
|
|
|
y /= v.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator %= (const Vector2i & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x %= v.x;
|
|
|
|
y %= v.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator &= (const Vector2i & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x &= v.x;
|
|
|
|
y &= v.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator |= (const Vector2i & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x |= v.x;
|
|
|
|
y |= v.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator ^= (const Vector2i & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x ^= v.x;
|
|
|
|
y ^= v.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator <<= (const Vector2i & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x <<= v.x;
|
|
|
|
y <<= v.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator >>= (const Vector2i & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x >>= v.x;
|
|
|
|
y >>= v.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator += (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x += s;
|
|
|
|
y += s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator -= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x -= s;
|
|
|
|
y -= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator *= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x *= s;
|
|
|
|
y *= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator /= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x /= s;
|
|
|
|
y /= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator %= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x %= s;
|
|
|
|
y %= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator &= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x &= s;
|
|
|
|
y &= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator |= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x |= s;
|
|
|
|
y |= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator ^= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x += s;
|
|
|
|
y += s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator <<= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x <<= s;
|
|
|
|
y <<= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator >>= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x >>= s;
|
|
|
|
y >>= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator ++ ()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
++x;
|
|
|
|
++y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i & Vector2i::operator -- ()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
--x;
|
|
|
|
--y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator ++ (int)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
Vector2i state(*this);
|
|
|
|
++x;
|
|
|
|
++y;
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator -- (int)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
Vector2i state(*this);
|
|
|
|
--x;
|
|
|
|
--y;
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator + (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x + v.x, y + v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator - (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x - v.x, y - v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator * (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x * v.x, y * v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator / (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x / v.x, y / v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator % (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x % v.x, y % v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator & (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x & v.x, y & v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator | (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x | v.x, y | v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator ^ (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x ^ v.x, y ^ v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator << (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x << v.x, y << v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator >> (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x >> v.x, y >> v.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator + (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x + s, y + s);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator - (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x - s, y - s);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator * (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x * s, y * s);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator / (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x / s, y / s);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator % (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x % s, y % s);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator & (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x & s, y & s);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator | (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x | s, y | s);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator ^ (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x ^ s, y ^ s);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator << (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x < s, y < s);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator >> (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(x >> s, y >> s);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator + () const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return Vector2i(abs(x), abs(y));
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator - () const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(-x, -y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::operator ~ () const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return Vector2i(~x, ~y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector2i::operator == (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return (x == v.x) && (y == v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector2i::operator != (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return (x != v.x) && (y != v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector2i::operator < (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return (x < v.x) && (y < v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector2i::operator > (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return (x > v.x) && (y > v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector2i::operator <= (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return (x <= v.x) && (y <= v.y);
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Vector2i::operator >= (const Vector2i & v) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return (x >= v.x) && (y >= v.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 Vector2i::Cmp(const Vector2i & o) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
if (*this == o)
|
|
|
|
return 0;
|
|
|
|
else if (*this > o)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return -1;
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr Vector2i::ToString() const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return ToStrF("%d,%d", x, y);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Vector2i::Set(Value ns)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x = ns;
|
|
|
|
y = ns;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
void Vector2i::Set(Value nx, Value ny)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x = nx;
|
|
|
|
y = ny;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Vector2i::Set(const Vector2i & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
x = v.x;
|
|
|
|
y = v.y;
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
void Vector2i::Set(const Vector2 & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
x = Value(v.x);
|
|
|
|
y = Value(v.y);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void Vector2i::Set(CSStr values, SQChar delim)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
Set(GetVector2i(values, delim));
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Vector2i::Generate()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
x = GetRandomInt32();
|
|
|
|
y = GetRandomInt32();
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
void Vector2i::Generate(Value min, Value max)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
if (max < min)
|
2016-03-10 04:57:13 +01:00
|
|
|
SqThrowF("max value is lower than min value");
|
|
|
|
|
|
|
|
x = GetRandomInt32(min, max);
|
|
|
|
y = GetRandomInt32(min, max);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-01 04:48:01 +01:00
|
|
|
void Vector2i::Generate(Value xmin, Value xmax, Value ymin, Value ymax)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
if (xmax < xmin || ymax < ymin)
|
2016-03-10 04:57:13 +01:00
|
|
|
SqThrowF("max value is lower than min value");
|
|
|
|
|
|
|
|
x = GetRandomInt32(ymin, ymax);
|
|
|
|
y = GetRandomInt32(xmin, xmax);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Vector2i Vector2i::Abs() const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return Vector2i(abs(x), abs(y));
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ================================================================================================
|
2016-02-20 23:25:00 +01:00
|
|
|
void Register_Vector2i(HSQUIRRELVM vm)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
typedef Vector2i::Value Val;
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
RootTable(vm).Bind(_SC("Vector2i"), Class< Vector2i >(vm, _SC("Vector2i"))
|
|
|
|
/* Constructors */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Ctor()
|
2016-02-20 23:25:00 +01:00
|
|
|
.Ctor< Val >()
|
|
|
|
.Ctor< Val, Val >()
|
|
|
|
/* Static Members */
|
|
|
|
.SetStaticValue(_SC("Delim"), &Vector2i::Delim)
|
|
|
|
/* Member Variables */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Var(_SC("x"), &Vector2i::x)
|
|
|
|
.Var(_SC("y"), &Vector2i::y)
|
2016-02-20 23:25:00 +01:00
|
|
|
/* Properties */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Prop(_SC("abs"), &Vector2i::Abs)
|
2016-02-20 23:25:00 +01:00
|
|
|
/* Core Metamethods */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Func(_SC("_tostring"), &Vector2i::ToString)
|
2016-03-10 04:57:13 +01:00
|
|
|
.SquirrelFunc(_SC("_typename"), &Vector2i::Typename)
|
2015-09-30 02:56:11 +02:00
|
|
|
.Func(_SC("_cmp"), &Vector2i::Cmp)
|
2016-02-20 23:25:00 +01:00
|
|
|
/* Metamethods */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("_add"), &Vector2i::operator +)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("_sub"), &Vector2i::operator -)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("_mul"), &Vector2i::operator *)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("_div"), &Vector2i::operator /)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("_modulo"), &Vector2i::operator %)
|
|
|
|
.Func<Vector2i (Vector2i::*)(void) const>(_SC("_unm"), &Vector2i::operator -)
|
2016-02-20 23:25:00 +01:00
|
|
|
/* Setters */
|
|
|
|
.Overload<void (Vector2i::*)(Val)>(_SC("Set"), &Vector2i::Set)
|
|
|
|
.Overload<void (Vector2i::*)(Val, Val)>(_SC("Set"), &Vector2i::Set)
|
|
|
|
.Overload<void (Vector2i::*)(const Vector2i &)>(_SC("SetVec2i"), &Vector2i::Set)
|
|
|
|
.Overload<void (Vector2i::*)(const Vector2 &)>(_SC("SetVec2"), &Vector2i::Set)
|
|
|
|
.Overload<void (Vector2i::*)(CSStr, SQChar)>(_SC("SetStr"), &Vector2i::Set)
|
|
|
|
/* Random Generators */
|
|
|
|
.Overload<void (Vector2i::*)(void)>(_SC("Generate"), &Vector2i::Generate)
|
|
|
|
.Overload<void (Vector2i::*)(Val, Val)>(_SC("Generate"), &Vector2i::Generate)
|
|
|
|
.Overload<void (Vector2i::*)(Val, Val, Val, Val)>(_SC("Generate"), &Vector2i::Generate)
|
|
|
|
/* Utility Methods */
|
|
|
|
.Func(_SC("Clear"), &Vector2i::Clear)
|
|
|
|
/* Operator Exposure */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opAddAssign"), &Vector2i::operator +=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opSubAssign"), &Vector2i::operator -=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opMulAssign"), &Vector2i::operator *=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opDivAssign"), &Vector2i::operator /=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opModAssign"), &Vector2i::operator %=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opAndAssign"), &Vector2i::operator &=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opOrAssign"), &Vector2i::operator |=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opXorAssign"), &Vector2i::operator ^=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opShlAssign"), &Vector2i::operator <<=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(const Vector2i &)>(_SC("opShrAssign"), &Vector2i::operator >>=)
|
|
|
|
|
|
|
|
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opAddAssignS"), &Vector2i::operator +=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opSubAssignS"), &Vector2i::operator -=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opMulAssignS"), &Vector2i::operator *=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opDivAssignS"), &Vector2i::operator /=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opModAssignS"), &Vector2i::operator %=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opAndAssignS"), &Vector2i::operator &=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opOrAssignS"), &Vector2i::operator |=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opXorAssignS"), &Vector2i::operator ^=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opShlAssignS"), &Vector2i::operator <<=)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(Vector2i::Value)>(_SC("opShrAssignS"), &Vector2i::operator >>=)
|
|
|
|
|
|
|
|
.Func<Vector2i & (Vector2i::*)(void)>(_SC("opPreInc"), &Vector2i::operator ++)
|
|
|
|
.Func<Vector2i & (Vector2i::*)(void)>(_SC("opPreDec"), &Vector2i::operator --)
|
|
|
|
.Func<Vector2i (Vector2i::*)(int)>(_SC("opPostInc"), &Vector2i::operator ++)
|
|
|
|
.Func<Vector2i (Vector2i::*)(int)>(_SC("opPostDec"), &Vector2i::operator --)
|
|
|
|
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opAdd"), &Vector2i::operator +)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opSub"), &Vector2i::operator -)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opMul"), &Vector2i::operator *)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opDiv"), &Vector2i::operator /)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opMod"), &Vector2i::operator %)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opAnd"), &Vector2i::operator &)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opOr"), &Vector2i::operator |)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opShl"), &Vector2i::operator ^)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opShl"), &Vector2i::operator <<)
|
|
|
|
.Func<Vector2i (Vector2i::*)(const Vector2i &) const>(_SC("opShr"), &Vector2i::operator >>)
|
|
|
|
|
|
|
|
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opAddS"), &Vector2i::operator +)
|
|
|
|
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opSubS"), &Vector2i::operator -)
|
|
|
|
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opMulS"), &Vector2i::operator *)
|
|
|
|
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opDivS"), &Vector2i::operator /)
|
|
|
|
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opModS"), &Vector2i::operator %)
|
|
|
|
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opAndS"), &Vector2i::operator &)
|
|
|
|
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opOrS"), &Vector2i::operator |)
|
|
|
|
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opShlS"), &Vector2i::operator ^)
|
|
|
|
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opShlS"), &Vector2i::operator <<)
|
|
|
|
.Func<Vector2i (Vector2i::*)(Vector2i::Value) const>(_SC("opShrS"), &Vector2i::operator >>)
|
|
|
|
|
|
|
|
.Func<Vector2i (Vector2i::*)(void) const>(_SC("opUnPlus"), &Vector2i::operator +)
|
|
|
|
.Func<Vector2i (Vector2i::*)(void) const>(_SC("opUnMinus"), &Vector2i::operator -)
|
|
|
|
.Func<Vector2i (Vector2i::*)(void) const>(_SC("opCom"), &Vector2i::operator ~)
|
|
|
|
|
|
|
|
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opEqual"), &Vector2i::operator ==)
|
|
|
|
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opNotEqual"), &Vector2i::operator !=)
|
|
|
|
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opLessThan"), &Vector2i::operator <)
|
|
|
|
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opGreaterThan"), &Vector2i::operator >)
|
|
|
|
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opLessEqual"), &Vector2i::operator <=)
|
|
|
|
.Func<bool (Vector2i::*)(const Vector2i &) const>(_SC("opGreaterEqual"), &Vector2i::operator >=)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|