using com.adjust.sdk;
using RedShellSDK;
using UnityEngine;

namespace RedShellUnity;

public class RedShell : MonoBehaviour
{
	private static RedShell instance;

	private static bool quitting;

	private static bool verboseLogs;

	public static void SetApiKey(string apiKey)
	{
		if (!Adjust.IsEditor())
		{
			_ = verboseLogs;
			setupInstance();
			global::RedShellSDK.RedShellSDK.SetApiKey(apiKey);
		}
	}

	public static void SetUserId(string userId)
	{
		if (!Adjust.IsEditor())
		{
			_ = verboseLogs;
			setupInstance();
			global::RedShellSDK.RedShellSDK.SetUserId(userId);
		}
	}

	public static void SetVerboseLogs(bool verboseLogs)
	{
		if (!Adjust.IsEditor())
		{
			RedShell.verboseLogs = verboseLogs;
			setupInstance();
			global::RedShellSDK.RedShellSDK.SetVerboseLogs(verboseLogs);
		}
	}

	public static void MarkConversion()
	{
		if (!Adjust.IsEditor())
		{
			_ = verboseLogs;
			setupInstance();
			instance.StartCoroutine(global::RedShellSDK.RedShellSDK.MarkConversion());
		}
	}

	public static void LogEvent(string type)
	{
		if (!Adjust.IsEditor())
		{
			_ = verboseLogs;
			setupInstance();
			instance.StartCoroutine(global::RedShellSDK.RedShellSDK.LogEvent(type));
		}
	}

	private void Awake()
	{
		if (!Adjust.IsEditor())
		{
			if (instance != null)
			{
				Object.Destroy(base.gameObject.GetComponent<RedShell>());
				return;
			}
			instance = this;
			Object.DontDestroyOnLoad(base.gameObject);
		}
	}

	private void OnDestroy()
	{
		if (!(instance != this))
		{
			quitting = true;
			instance = null;
		}
	}

	private static void setupInstance()
	{
		if (!Adjust.IsEditor() && !quitting && instance == null)
		{
			_ = verboseLogs;
			instance = new GameObject("Red Shell").AddComponent<RedShell>();
		}
	}
}
