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

import java.util.Objects;

public class Vec4fMutable implements Vec4f {
	float x;
	float y;
	float z;
	float w;
	
	public Vec4fMutable() {
		x = 0;
		y = 0;
		z = 0;
		w = 0;
	}
	
	public Vec4fMutable(float value) {
		x = value;
		y = value;
		z = value;
		w = value;
	}
	
	public Vec4fMutable(float x, float y, float z, float w) {
		this.x = x;
		this.y = y;
		this.z = z;
		this.w = w;
	}
	
	@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 float w() { return w; }
	
	@Override
	public Vec4f x(float x) {
		this.x = x;
		return this;
	}
	
	@Override
	public Vec4f y(float y) {
		this.y = y;
		return this;
	}
	
	@Override
	public Vec4f z(float z) {
		this.z = z;
		return this;
	}
	
	@Override
	public Vec4f w(float w) {
		this.w = w;
		return this;
	}
	
	@Override
	public Vec4f copy() { return Vec4f.mutable(this); }
	
	@Override
	public Vec4f set(float x, float y, float z, float w) {
		this.x = x;
		this.y = y;
		this.z = z;
		this.w = w;
		return this;
	}
	
	@Override
	public int hashCode() { return Objects.hash(x, y, z, w); }
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Vec4f) {
			Vec4f vec = (Vec4f)obj;
			return vec.x() == x && vec.y() == y && vec.z() == z && vec.w() == w;
		}
		return false;
	}
	
	@Override
	public String toString() { return "Vec4f[x="+x+", y="+y+", z="+z+", w="+w+"]"; }
}
