/** @module ecs/sys/debug/ShowForceSystem */

import { initFromConfigClone } from "/scripts/util/config.js"

import ForcesComponent from "/scripts/ecs/comp/move/ForcesComponent.js"
import Color           from "/scripts/graph/Color.js"

import ShowArrowVecSystem from "./ShowArrowVecSystem.js"

export default class ShowForceSystem extends ShowArrowVecSystem {
    static defaultArrowColor        = Color.black()
    static defaultArrowLengthFactor = .01
    static defaultTextColor         = ShowForceSystem.defaultArrowColor

    constructor(ctx, cameraProvider, config = {}) {
        initFromConfigClone(config, config, ShowForceSystem, "arrowColor", "arrowLengthFactor", "textColor")

        config.evalVec = entity => entity.components.get(ForcesComponent).forces.superpos()

        super(ctx, cameraProvider, config)

        this.tag      = "show-force"
        this.priority = -2
        this.required.add(ForcesComponent)
    }
}
