#if UNITY_EDITOR
using ParrelSync;
#endif
using System;
using System.Collections;
using System.Collections.Generic;
using UDB;
using UnityEngine;

public class NetworkSession
{
    public static string NetworkSessionIDKey {
        get {
#if UNITY_EDITOR
            // Remove this if you don't have ParrelSync installed. 
            // It's used to differentiate the clients, otherwise lobby will count them as the same
            if (ClonesManager.IsClone()) {
                int index = ClonesManager.GetCurrentProjectPath().LastIndexOf(ClonesManager.CloneNameSuffix);
                string suffix = ClonesManager.GetCurrentProjectPath().Substring(index, 8);
                return "NetworkSessionID" + suffix;
            }
            else {
#endif
                return "NetworkSessionID";
#if UNITY_EDITOR
            }
#endif
        }
    }

    public static Guid guid {
        get {
            Guid id;
            String stringId = PlayerPrefs.GetString(NetworkSessionIDKey);
            if (stringId.IsNullOrEmpty()) {
                id = Guid.NewGuid();
                PlayerPrefs.SetString(NetworkSessionIDKey, id.ToString());
            } else {
                id = Guid.Parse(stringId);
            }
            return id;
        }
    }
}
