using NaughtyAttributes;
using Station46.Scripts;
using UnityEngine;

namespace Station46.Modules.Rings.Scripts
{
    [RequireComponent(typeof(Emission))]
    public class Ring : MonoBehaviour
    {
        public float speed;

        [ShowNativeProperty] public float Displacement { get; set; }
        public Emission Emission { get; private set; }

        private void Awake()
        {
            Emission = GetComponent<Emission>();
        }

        private void Update()
        {
            var t = transform;
            var position = t.localPosition;
            var delta = position.y - Displacement;
            t.localPosition = new Vector3(0, position.y - delta * speed, 0);
        }
    }
}