class LightBehavior3 extends Sup.Behavior {
  update() {
    let girl = Sup.getActor("Player");
    let girlPos = girl.getLocalPosition();
    let mousePos = Sup.Input.getMousePosition();
    this.actor.setPosition(girlPos.x, girlPos.y, 0);
    
    let girlPosNorm = girlPos.normalize();
    let rad = Math.atan2(mousePos.y - girlPosNorm.y, mousePos.x);
    if (rad < 0) {
      rad = (rad < (-Math.PI / 2)) ? Math.PI : 0;
    }
    this.actor.setEulerZ(rad);
    
    if (Sup.Input.isKeyDown("SHIFT")) {
      this.incrementColor(girl);
    }
  }
  
  incrementColor(girl) {
    let colors = girl.getBehavior(PlayerBehavior3).colors;
    let color = this.actor.spriteRenderer.getColor();
    let { h, s, l } = color.getHSL();
    let newH = h + .01;
    newH = (newH > colors[1]) ? colors[0] : newH;
    color.setHSL(newH, s, l);
    this.actor.spriteRenderer.setColor(color);
  }
}
Sup.registerBehavior(LightBehavior3);
