using System;
using EFT.Interactive;
using stupid.solutions.Utils;
using UnityEngine;

namespace stupid.solutions.Data;

internal class GameTransitPoint
{
	private Vector3 screenPosition;

	public TransitPoint transitPoint { get; }

	public Vector3 ScreenPosition => screenPosition;

	public bool IsOnScreen { get; private set; }

	public float Distance { get; private set; }

	public string Name { get; set; }

	public string FormattedDistance => $"{Math.Round(Distance)}m";

	public GameTransitPoint(TransitPoint tPoint)
	{
		if (tPoint == null)
		{
			throw new ArgumentNullException("tPoint");
		}
		transitPoint = tPoint;
		screenPosition = default(Vector3);
		Distance = 0f;
		Name = transitPoint.name ?? "";
	}

	public void RecalculateDynamics()
	{
		if (!(transitPoint == null) && GameUtils.IsTransitPointValid(transitPoint))
		{
			screenPosition = GameUtils.WorldPointToScreenPoint(transitPoint.transform.position);
			IsOnScreen = GameUtils.IsScreenPointVisible(screenPosition);
			Distance = Vector3.Distance(Main.MainCamera.transform.position, transitPoint.transform.position);
		}
	}
}
