package speiger.src.coreengine.math.vector.bytes;

import java.util.Objects;

public class Vec2bMutable implements Vec2b {
	byte x;
	byte y;
	
	public Vec2bMutable() {}
	
	public Vec2bMutable(byte value) {
		x = value;
		y = value;
	}
	
	public Vec2bMutable(byte x, byte y) {
		this.x = x;
		this.y = y;
	}
	
	@Override
	public boolean isMutable() { return true; }
	@Override
	public byte x() { return x; }
	@Override
	public byte y() { return y; }
	
	@Override
	public Vec2b x(byte x) {
		this.x = x;
		return this;
	}
	
	@Override
	public Vec2b y(byte y) {
		this.y = y;
		return this;
	}
	
	@Override
	public Vec2b copy() { return Vec2b.mutable(this); }
	
	@Override
	public Vec2b set(byte x, byte 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 Vec2b) {
			Vec2b vec = (Vec2b)obj;
			return vec.x() == x && vec.y() == y;
		}
		return false;
	}
	
	@Override
	public String toString() { return "Vec2b[x="+x+", y="+y+"]"; }
}
