import { Element } from "@/pages/GamePage/Components/Element/Element.ts";
import { Ele } from "@/pages/GamePage/config/Config.ts";
import { collisionSys } from "@/pages/GamePage/GamePage.tsx";
import { Box, SATVector } from "detect-collisions";
import { DEG_TO_RAD } from "pixi.js";

/**
 * 丝状菌
 */
export class Filiform extends Element {

  id: Ele = Ele.Filiform;

  initUI(): void {
  }

  initPhy(): void {
    const { width, height } = this.sp;

    this.body = collisionSys.createBox(
      this.getGlobalPosition(),
      width,
      height,
      {
        userData: {
          ele: this
        }
      }
    );
    this.body.setOffset(new SATVector(-width / 2, -height / 2));
    this.body.setAngle(this.sp.angle * DEG_TO_RAD);
  }

  updatePhy(): void {
    const { width, height } = this.sp;
    this.body.setOffset(new SATVector(-width / 2, -height / 2));
  }
}
