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 x() { return x; }
	@Override
	public int y() { return y; }
	
	@Override
	public Vec2i x(int x) {
		this.x = x;
		return this;
	}
	
	@Override
	public Vec2i y(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.x() == x && vec.y() == y;
		}
		return false;
	}
	
	@Override
	public String toString() { return "Vec2i[x="+x+", y="+y+"]"; }
}
