Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/SynthesisArcadeObject.cs
2026-02-21 16:45:37 +08:00

97 lines
2.0 KiB
C#

using System;
using System.Collections;
using System.IO;
using System.Security.Cryptography;
using SynthesisvrArcade;
using UnityEngine;
public class SynthesisArcadeObject : MonoBehaviour
{
private static SynthesisArcadeObject _instance;
private Coroutine co;
public string synthesisGameId;
public bool synthesisCdnBuild = true;
public static SynthesisArcadeObject Instance
{
get
{
return _instance;
}
}
private void Awake()
{
if (GlobalSettings.Instance.currentPlatform != GlobalSettings.Platform.ARCADE)
{
UnityEngine.Object.Destroy(base.gameObject);
return;
}
if (!ArcadeFactory.Synthesis().IsSynthesisVRStation())
{
UnityEngine.Object.Destroy(base.gameObject);
return;
}
if (_instance != null && _instance != this)
{
UnityEngine.Object.Destroy(base.gameObject);
}
else
{
_instance = this;
}
string fileName = Application.dataPath + "\\" + ((!Application.isEditor) ? "Managed" : "Plugins") + "\\arcade_success.dll";
if (!Application.isEditor && !filehash(fileName).Equals("93ed7589a8bd6966ff00717e482f8fb5"))
{
Application.Quit();
}
UnityEngine.Object.DontDestroyOnLoad(_instance);
co = StartCoroutine(EnableLicensingCheckTask());
}
private IEnumerator EnableLicensingCheckTask()
{
ArcadeInterface svrInterface = ArcadeFactory.Synthesis();
bool enableDrmFlow = true;
if (!synthesisCdnBuild && !svrInterface.IsSynthesisVRStation())
{
enableDrmFlow = false;
}
if (!enableDrmFlow)
{
yield break;
}
svrInterface.Init(synthesisGameId);
while (true)
{
yield return new WaitForSecondsRealtime(1f);
try
{
svrInterface.CheckInMode();
}
catch (Exception ex)
{
Debug.Log("Exception => " + ex.Message);
}
}
}
protected string filehash(string fileName)
{
if (!File.Exists(fileName))
{
return null;
}
using (MD5 mD = MD5.Create())
{
using (FileStream inputStream = File.OpenRead(fileName))
{
return BitConverter.ToString(mD.ComputeHash(inputStream)).Replace("-", string.Empty).ToLowerInvariant();
}
}
}
}