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

import java.util.Objects;

public class Vec3fMutable implements Vec3f {
	float x;
	float y;
	float z;
	
	public Vec3fMutable() {}
	
	public Vec3fMutable(float value) {
		x = value;
		y = value;
		z = value;
	}
	
	public Vec3fMutable(float x, float y, float z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}
	
	@Override
	public boolean isMutable() { return true; }
	@Override
	public float x() { return x; }
	@Override
	public float y() { return y; }
	@Override
	public float z() { return z; }
	
	@Override
	public Vec3f x(float x) {
		this.x = x;
		return this;
	}
	
	@Override
	public Vec3f y(float y) {
		this.y = y;
		return this;
	}
	
	@Override
	public Vec3f z(float z) {
		this.z = z;
		return this;
	}
	
	@Override
	public Vec3f copy() { return Vec3f.mutable(this); }
	
	@Override
	public Vec3f set(float x, float y, float z) {
		this.x = x;
		this.y = y;
		this.z = z;
		return this;
	}
	
	@Override
	public int hashCode() { return Objects.hash(x, y, z); }
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Vec3f) {
			Vec3f vec = (Vec3f)obj;
			return vec.x() == x && vec.y() == y && vec.z() == z;
		}
		return false;
	}
	
	@Override
	public String toString() { return "Vec3f[x="+x+", y="+y+", z="+z+"]"; }
}
