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

public class SystemObjectController : MonoBehaviour {
	[SerializeField] private HitObjectController hitController = null; // set from editor
	[SerializeField] private LineRenderer orbitalLine = null; // set from editor
	public ExplorePointConfig Config {get; private set;}

	public void Init(ExplorePointConfig config) {
		gameObject.SetActive (true);
		Config = config;
		transform.position = Config.GetPosition ();
		SetOrbitalLine (Config);
	}

	private void SetOrbitalLine (ExplorePointConfig config) {
		const float orbitDetailsPerUnit = 8f;
		int details = (int) (2f * Mathf.PI * config.Radius * orbitDetailsPerUnit);
#if UNITY_5_6_OR_NEWER
        orbitalLine.positionCount = details;
		for (int i = 0; i < details; i++) {
			orbitalLine.SetPosition(i, config.GetPosition(360f / (details - 1f) * i));
		}
#else
        orbitalLine.numPositions = details;
        for (int i = 0; i < details; i++) {
            orbitalLine.SetPosition(i, config.GetPosition(360f / (details - 1f) * i));
        }
#endif
    }

	public bool IsHit (Ray ray) {
		return hitController.IsHit (ray);
	}

	void Start () {
		
	}

	void Update () {
		
	}
}
