import { AnimationTree, float64 } from 'godot'
import Player from './player'
import PlayerInput from './player_input'
import { onready } from 'godot.annotations'

export const PlayerAnimationName = Object.freeze({
  Idle: 'Idle',
  Walk: 'Walking',
  Run: 'SlowRun',
  Interact: 'Interact',
  Aim: 'PistolIdle',
  Fire: 'Shooting'
} as const)

export default class PlayerAnimation extends AnimationTree {
  //private static Interact = 'parameters/conditions/interact'
  private static Movement = 'parameters/Movement/blend_position'

  @onready('../')
  player!: Player

  @onready('../Input')
  readonly player_input!: PlayerInput

  _process(_delta: float64): void {
    this.set(PlayerAnimation.Movement, this.player.velocity.length_squared())
  }
}
