using UnityEngine;
using ScrambleKit.Move;

namespace ScrambleKit.Weapons
{
    public class WeaponCore : MonoBehaviour
    {
        public bool IsReady { get; private set; }
        public bool IsHeld { get; private set; }

        public MoveInputSource Input { get; private set; }

        public void Ready(MoveInputSource inputSource)
        {
            Input = inputSource;
            IsReady = true;
            gameObject.SetActive(true);
        }

        public void Stow()
        {
            IsReady = false;
            IsHeld = true;
            gameObject.SetActive(false);
        }

        public void Drop()
        {
            IsReady = false;
            IsHeld = false;
            gameObject.SetActive(true);
            transform.parent = null;
        }

        public void Equip(Transform owner)
        {
            IsReady = true;
            IsHeld = true;
            gameObject.SetActive(true);
            transform.parent = owner;
            transform.localPosition = Vector3.zero;
        }

        public void Start()
        {
            Stow();
        }
    }
}
