using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace DuckHunter
{
    public class SmartBowController : MonoBehaviour
    {
        public static SmartBowController Instance;

        void Start() {
            Instance = this;
            SimulateMouseController.ins?.RemoveOpenLocker("NotGame");
            CameraToLook.ins.onParseRotation += OnRotationUpdate;
        }

        void OnDestroy() {
            if (Instance == this) Instance = null;
        }

        public void OnRotationUpdate(Quaternion rotation)
        {
            GameManager.Instance?.OnModuleRotationUpdate(rotation);
        }

        float _lastShootTime = 0;
        public void OnShooting(float speed)
        {
            if (Time.time == 0) return;
            if (Time.realtimeSinceStartup - _lastShootTime < 1) return;
            _lastShootTime = Time.realtimeSinceStartup;
            GameManager.Instance?.OnModuleShooting(speed,true);
        }

        public void ResetAim() {
            // AimHandler.ins.DoIdentity();
            AutoResetView.DoIdentity();
        }
    }
}
