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

import java.util.Objects;

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