
@BaseScript(EntityTypeScript)

/**
 * 
 */
package scripts.types

import groovy.transform.BaseScript
import studio.junk.jam.coloritum.EntityTypeScript
import studio.junk.jam.coloritum.GameState
import studio.junk.jam.coloritum.entities.components.Collision
import studio.junk.jam.coloritum.entities.components.DrainComponent;
import studio.junk.jam.coloritum.entities.components.Lights
import studio.junk.jam.coloritum.entities.components.PigmentComponent
import studio.junk.jam.coloritum.entities.components.Source
import studio.junk.jam.coloritum.entities.components.SpriteComponent;
import studio.junk.jam.coloritum.entities.components.TilePosition
import studio.junk.jam.coloritum.screen.InGame
import box2dLight.Light
import box2dLight.PointLight

/**
 * Needs arguments:
 * Vector2 agrs[0]: position
 * Pigment args[1]: pigment
 * 
 * @author cryptjar
 *
 */

entity {
	addStatic this.args[0], 0.5f
	add new TilePosition(this.args[0])
	add new DrainComponent()
	add new PigmentComponent(this.args[1])
	Light[] ls = new Light[1];
	ls[0] = new PointLight(InGame.rayLightsHandler, GameState.RAYS_NUM, this.args[1].color, 1.5f, this.args[0].x, this.args[0].y)
	ls[0].attachToBody(Collision.mapper.get(ent).body, 0, 0)
	
	add new Lights(ls)
	add new SpriteComponent(this.getTexture("drain"));
}
