using System.Collections.Generic;
using UnityEngine;

namespace NBF
{
    public class PlayerCharacter : MonoBehaviour
    {
        public CharacterController CharacterController;
        public CollisionFlags CollisionFlags;

        private FPlayer _player;

        public bool IsSelf;

        private PlayerDriveBase _moverDrive;

        private void Start()
        {
            CharacterController = GetComponent<CharacterController>();
            _player = GetComponent<FPlayer>();

            IsSelf = _player.Data.PlayerID == GameModel.RoleID;

            CharacterController.enabled = false;
            transform.position = _player.Data.position;
            transform.rotation = _player.Data.rotation;
            CharacterController.enabled = true;

            _moverDrive = new PlayerLocalMover();
            _moverDrive.Start(this);
        }

        private void Update()
        {
            _moverDrive?.Update();
        }


        private void LateUpdate()
        {
            _moverDrive?.LateUpdate();
        }

        private void FixedUpdate()
        {
            _moverDrive?.FixedUpdate();
        }
    }
}