
@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.Lights
import studio.junk.jam.coloritum.entities.components.PigmentComponent
import studio.junk.jam.coloritum.screen.InGame
import box2dLight.Light
import box2dLight.PointLight

/**
 * Needs arguments:
 * Vector2 agrs[0]: position
 * Vector2 args[1]: init Velocity
 * int args[2]    : wobble period
 * Pigment args[3]: pigment
 * 
 * @author cryptjar
 *
 */

entity {
	addDynamic(this.args[0], this.args[1].scl(GameState.LIGHT_BULB_VEL), 0.1f)
	add new studio.junk.jam.coloritum.entities.components.LightBulb(this.args[2])
	add new PigmentComponent(this.args[3])
	Light[] ls = new Light[3];

	ls[0] = new PointLight(InGame.rayLightsHandler, GameState.RAYS_NUM, this.args[3].color, 0.8f, 0, 0)
	ls[0].attachToBody(Collision.mapper.get(ent).body, 0, 0)
	ls[1] = new PointLight(InGame.rayLightsHandler, GameState.RAYS_NUM, this.args[3].color, 0.8f, 0, 0)
	ls[1].attachToBody(Collision.mapper.get(ent).body, 0, 0)
	ls[2] = new PointLight(InGame.rayLightsHandler, GameState.RAYS_NUM, this.args[3].color, 0.8f, 0, 0)
	ls[2].attachToBody(Collision.mapper.get(ent).body, 0, 0)
	add new Lights(ls)
}
