mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 16:57:16 +01:00
413 lines
13 KiB
C++
413 lines
13 KiB
C++
#ifndef _BASE_VECTOR2I_HPP_
|
|
#define _BASE_VECTOR2I_HPP_
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
#include "SqBase.hpp"
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
namespace SqMod {
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
*
|
|
*/
|
|
struct Vector2i
|
|
{
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
typedef int Value;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
static const Vector2i NIL;
|
|
static const Vector2i MIN;
|
|
static const Vector2i MAX;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
static SQChar Delim;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Value x, y;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
*
|
|
*/
|
|
Vector2i();
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i(Value sv);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i(Value xv, Value yv);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
*
|
|
*/
|
|
Vector2i(const Vector2i & o);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
*
|
|
*/
|
|
~Vector2i();
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
*
|
|
*/
|
|
Vector2i & operator = (const Vector2i & o);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator = (Value s);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator = (CSStr values);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator = (const Vector2 & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator += (const Vector2i & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator -= (const Vector2i & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator *= (const Vector2i & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator /= (const Vector2i & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator %= (const Vector2i & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator &= (const Vector2i & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator |= (const Vector2i & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator ^= (const Vector2i & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator <<= (const Vector2i & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator >>= (const Vector2i & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator += (Value s);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator -= (Value s);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator *= (Value s);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator /= (Value s);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator %= (Value s);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator &= (Value s);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator |= (Value s);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator ^= (Value s);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator <<= (Value s);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator >>= (Value s);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator ++ ();
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i & operator -- ();
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator ++ (int);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator -- (int);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator + (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator - (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator * (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator / (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator % (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator & (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator | (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator ^ (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator << (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator >> (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator + (Value s) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator - (Value s) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator * (Value s) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator / (Value s) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator % (Value s) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator & (Value s) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator | (Value s) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator ^ (Value s) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator << (Value s) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator >> (Value s) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator + () const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator - () const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i operator ~ () const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
bool operator == (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
bool operator != (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
bool operator < (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
bool operator > (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
bool operator <= (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
bool operator >= (const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Int32 Cmp(const Vector2i & v) const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
CSStr ToString() const;
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
void Set(Value ns);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
void Set(Value nx, Value ny);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
void Set(const Vector2i & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
void Set(const Vector2 & v);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
void Set(CSStr values, SQChar delim);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
void Generate();
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
void Generate(Value min, Value max);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
void Generate(Value xmin, Value xmax, Value ymin, Value ymax);
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
void Clear()
|
|
{
|
|
x = 0, y = 0;
|
|
}
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
* ...
|
|
*/
|
|
Vector2i Abs() const;
|
|
};
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
#endif // _BASE_VECTOR2I_HPP_
|