using UnityEngine;

public partial class OrbitalBehaviour : MonoBehaviour
{
    [Header("Orbital Information")]
    [SerializeField] private int m_AttachedRing;
    [SerializeField] private float m_DistanceAlongCircumference;
    [SerializeField] private float m_ObjectRadius = 0.1f;
    [SerializeField] private float m_SpinSpeed = 0.1f;

    [SerializeField] private float m_DistanceFromCentre;

    [field: SerializeField] protected float ObjectRadiusMultiplier { get; set; } = 1.0f;
    [field: SerializeField] protected bool IsAttachedToRings { get; set; } = true;

    protected void RegisterObject(OrbitalInitializer init)
    {
        BehaviourManager.RegisterOrbitalInstance(this);
        
        m_DistanceAlongCircumference = init.DistanceAlongCircumference;
        m_ObjectRadius = init.ObjectRadius;
        m_SpinSpeed = init.SpinSpeed;
    }

    public Vector3 TranslateToVector3() => new
    (
        x: m_DistanceFromCentre * Mathf.Cos(m_DistanceAlongCircumference),
        y: m_DistanceFromCentre * Mathf.Sin(m_DistanceAlongCircumference),
        z: 0
    );

    protected virtual void OnOrbitalCollision(OrbitalBehaviour other) { }
    
    protected virtual void OnSimulationRestart() { }
    protected virtual void OnReachCentre() { }
    
    protected void AdvanceRing()
    {
        m_AttachedRing++;
    }
}

public class OrbitalInitializer
{
    public float DistanceAlongCircumference { get; set; }
    public float ObjectRadius { get; set; }
    public float SpinSpeed { get; set; }
}

public class Ring : MonoBehaviour
{
    public int m_ID;
}
