namespace pdinklag.CPW.Common
{
    /// <summary>
    /// Abstract base for weapon scripts.
    /// </summary>
    public abstract class WeaponScript
    {
        /// <summary>
        /// The scripted weapon.
        /// </summary>
        /// <value></value>
        protected IWeapon Weapon { get; private set; }

        /// <summary>
        /// Shortcut to the weapon prefab.
        /// </summary>
        protected WeaponPrefab Prefab => Weapon.Prefab;

        /// <summary>
        /// Initializes the script.
        /// 
        /// This is called from the game once and should not be used otherwise.
        /// </summary>
        /// <param name="weapon">the scripted weapon</param>
        public void Init(IWeapon weapon)
        {
            Weapon = weapon;
        }

        /// <summary>
        /// Called after the script has been added to the weapon.
        /// </summary>
        public virtual void OnCreate()
        {
        }

        /// <summary>
        /// Called when the weapon has been picked up.
        /// </summary>
        public virtual void OnPickedUp()
        {
        }

        /// <summary>
        /// Called when the weapon has been dropped.
        /// </summary>
        public virtual void OnDropped() 
        {
        }

        /// <summary>
        /// Called when the weapon is about to be placed.
        /// Use this to play unfolding animations while the wrestler plays the placement animation.
        /// </summary>
        public virtual void OnBeforePlace() 
        {
        }

        /// <summary>
        /// Called when the weapon has been placed.
        /// </summary>
        public virtual void OnPlaced() 
        {
        }

        /// <summary>
        /// Called after the script has been removed from the weapon.
        /// </summary>
        public virtual void OnDestroy()
        {
        }
    }
}
