using DoomDeathmatch.Component.Util;
using OpenTK.Mathematics;

namespace DoomDeathmatch.Component.MVC.Controller;

public class MovementController : Engine.Scene.Component.Component
{
  public float Speed { get; set; } = 10.0f;

  private RigidbodyComponent _rigidbody = null!;
  private DragComponent _dragComponent = null!;

  public override void Awake()
  {
    _rigidbody = GameObject.GetComponent<RigidbodyComponent>()!;
    _dragComponent = GameObject.GetComponent<DragComponent>()!;

    ArgumentNullException.ThrowIfNull(_rigidbody);
    ArgumentNullException.ThrowIfNull(_dragComponent);
  }

  public void ApplyMovement(Vector3 parDirection)
  {
    _rigidbody.AddForce(_dragComponent.Drag * Speed * parDirection);
  }
}