package studio.junk.jam.coloritum.entities.systems;

import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IntervalIteratingSystem;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;

import studio.junk.jam.coloritum.GameState;
import studio.junk.jam.coloritum.entities.Families;
import studio.junk.jam.coloritum.entities.components.Collision;

public class LightBulbAligner extends IntervalIteratingSystem {

	public static final Family family = Families.lightBulb;

	public LightBulbAligner(int priority) {
		//super(family, GameState.PULSE_INTERVAL, priority);
		super(family, 1 / GameState.LIGHT_BULB_VEL, priority);
	}

	public LightBulbAligner() {
		//	super(family, GameState.PULSE_INTERVAL);
		super(family, 1 / GameState.LIGHT_BULB_VEL);
	}

	@Override
	protected void processEntity(Entity entity) {

		Collision collision = Collision.mapper.get(entity);

		Vector2 pos = collision.body.getPosition();

		collision.body.setTransform(MathUtils.floor(pos.x) + 0.5f, MathUtils.floor(pos.y) + 0.5f, 0);

	}
}
