using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SemVer;
using Version = SemVer.Version;
namespace IPA.Utilities
{
///
/// Provides some basic utility methods and properties of Beat Saber
///
public static class BeatSaber
{
private static Version _gameVersion = null;
///
/// Provides the current game version
///
public static Version GameVersion => _gameVersion ?? (_gameVersion = new Version(UnityEngine.Application.version));
///
/// The different types of releases of the game.
///
public enum Release
{
///
/// Indicates a Steam release.
///
Steam,
///
/// Indicates an Oculus release.
///
Oculus
}
private static Release? _releaseCache = null;
///
/// Gets the type of this installation of Beat Saber
///
public static Release ReleaseType => (_releaseCache ?? (_releaseCache = FindSteamVRAsset() ? Release.Steam : Release.Oculus)).Value;
///
/// The path to the Beat Saber install dir
///
public static string InstallPath => Environment.CurrentDirectory;
///
/// The path to the `Libs` folder. Use only if necessary.
///
public static string LibraryPath => Path.Combine(InstallPath, "Libs");
///
/// The path to the `Libs\Native` folder. Use only if necessary.
///
public static string NativeLibraryPath => Path.Combine(LibraryPath, "Native");
private static bool FindSteamVRAsset()
{
// these require assembly qualified names....
var SteamVRCamera = Type.GetType("SteamVR_Camera, Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", false);
var SteamVRExternalCamera = Type.GetType("SteamVR_ExternalCamera, Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", false);
var SteamVRFade = Type.GetType("SteamVR_Fade, Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", false);
return SteamVRCamera != null && SteamVRExternalCamera != null && SteamVRFade != null;
}
}
}