65 lines
1.0 KiB
Java
65 lines
1.0 KiB
Java
package speiger.src.coreengine.math.vector.ints;
|
|
|
|
import java.util.Objects;
|
|
|
|
public class Vec2iMutable implements Vec2i {
|
|
int x;
|
|
int y;
|
|
|
|
public Vec2iMutable() {}
|
|
|
|
public Vec2iMutable(int value) {
|
|
x = value;
|
|
y = value;
|
|
}
|
|
|
|
public Vec2iMutable(int x, int y) {
|
|
this.x = x;
|
|
this.y = y;
|
|
}
|
|
|
|
@Override
|
|
public boolean isMutable() { return true; }
|
|
@Override
|
|
public int getX() { return x; }
|
|
@Override
|
|
public int getY() { return y; }
|
|
|
|
@Override
|
|
public Vec2i setX(int x) {
|
|
this.x = x;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public Vec2i setY(int y) {
|
|
this.y = y;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public Vec2i copy() { return Vec2i.mutable(this); }
|
|
|
|
@Override
|
|
public Vec2i set(int x, int y) {
|
|
this.x = x;
|
|
this.y = y;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() { return Objects.hash(x, y); }
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if(obj instanceof Vec2i) {
|
|
Vec2i vec = (Vec2i)obj;
|
|
return vec.getX() == x && vec.getY() == y;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public String toString() { return "Vec2i[x="+x+", y="+y+"]"; }
|
|
}
|