329 lines
7.4 KiB
C#
329 lines
7.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BitStrap;
|
|
using CodeStage.AntiCheat.ObscuredTypes;
|
|
using PygmyMonkey.AdvancedBuilder;
|
|
using Steamworks;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class GlobalSettings : MonoBehaviour
|
|
{
|
|
public enum Platform
|
|
{
|
|
STEAM = 0,
|
|
WEGAME = 1,
|
|
SWITCH = 2,
|
|
PS4 = 3,
|
|
XONE = 4,
|
|
GOG = 5,
|
|
OCULUS = 6,
|
|
ARCADE = 7,
|
|
VIVEPORT = 8,
|
|
MAGENTA = 9
|
|
}
|
|
|
|
private static GlobalSettings instance;
|
|
|
|
[HideInInspector]
|
|
public PlayerSettingsMy playerSettings;
|
|
|
|
[HideInInspector]
|
|
public RenderSettingsMy renderSettings;
|
|
|
|
[HideInInspector]
|
|
public SoundSettings soundSettings;
|
|
|
|
[HideInInspector]
|
|
public LevelsManager levelsManager;
|
|
|
|
[HideInInspector]
|
|
public SaveManager saveManager;
|
|
|
|
[HideInInspector]
|
|
public WeatherSettings weatherSettings;
|
|
|
|
[HideInInspector]
|
|
public EquipmentManager equipmentManager;
|
|
|
|
[HideInInspector]
|
|
public SkillsManager skillsManager;
|
|
|
|
[HideInInspector]
|
|
public FishManager fishManager;
|
|
|
|
public bool isDemo;
|
|
|
|
public bool isBeta;
|
|
|
|
public bool isFinal;
|
|
|
|
public bool turnOnCheats;
|
|
|
|
public bool turnOnMyCheats;
|
|
|
|
public bool useSrdebugger;
|
|
|
|
[Space(10f)]
|
|
public string cheatProfileName = "PlaywayCheat";
|
|
|
|
public string myCheatProfileName = "HubertCheat";
|
|
|
|
[Space(10f)]
|
|
public int gameVersion;
|
|
|
|
public ObscuredInt minOnlineBundleVersion = 362;
|
|
|
|
public bool resetOldSaves = true;
|
|
|
|
public GameObject buildNunberParent;
|
|
|
|
public Text buildNumberText;
|
|
|
|
public Text bugReportText;
|
|
|
|
public string[] testStartArgs = new string[1];
|
|
|
|
[Space(10f)]
|
|
public List<string> betaSteamAccounts = new List<string>();
|
|
|
|
public List<string> teamSteamAccountsID = new List<string>();
|
|
|
|
public List<string> teamWeGameAccountsID = new List<string>();
|
|
|
|
public List<string> teamGogAccountsID = new List<string>();
|
|
|
|
public List<string> teamOculusAccountsID = new List<string>();
|
|
|
|
public List<string> betaSteamAccountsID = new List<string>();
|
|
|
|
public GameObject chooseBetaWidget;
|
|
|
|
[Space(10f)]
|
|
public List<string> crackSteamAccountsID = new List<string>();
|
|
|
|
public List<string> crackProfileNames = new List<string>();
|
|
|
|
public List<string> cheatSteamAccountsID = new List<string>();
|
|
|
|
[Space(10f)]
|
|
public TournamentManager.TournamentDefinition tournamentDefinition = new TournamentManager.TournamentDefinition();
|
|
|
|
[Space(10f)]
|
|
[ReadOnly]
|
|
public Platform currentPlatform;
|
|
|
|
public string platformProfileName = string.Empty;
|
|
|
|
public ulong platformProfileID;
|
|
|
|
public static GlobalSettings Instance
|
|
{
|
|
get
|
|
{
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private GlobalSettings()
|
|
{
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
Time.timeScale = 1f;
|
|
isDemo = false;
|
|
currentPlatform = Platform.STEAM;
|
|
Debug.Log(SystemInfo.operatingSystem);
|
|
Debug.Log("Platform: " + currentPlatform);
|
|
Debug.Log("Build " + ((IntPtr.Size != 8) ? "32" : "64") + "-bit");
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
|
|
playerSettings = GetComponent<PlayerSettingsMy>();
|
|
renderSettings = GetComponent<RenderSettingsMy>();
|
|
soundSettings = GetComponent<SoundSettings>();
|
|
levelsManager = GetComponentInChildren<LevelsManager>();
|
|
weatherSettings = GetComponent<WeatherSettings>();
|
|
saveManager = GetComponent<SaveManager>();
|
|
equipmentManager = GetComponentInChildren<EquipmentManager>();
|
|
skillsManager = GetComponentInChildren<SkillsManager>();
|
|
fishManager = GetComponentInChildren<FishManager>();
|
|
playerSettings.skillsManager = skillsManager;
|
|
renderSettings.Initialize();
|
|
if ((turnOnCheats || true) && useSrdebugger)
|
|
{
|
|
SRDebug.Init();
|
|
}
|
|
if ((bool)chooseBetaWidget)
|
|
{
|
|
chooseBetaWidget.SetActive(false);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UnityEngine.Object.DestroyImmediate(base.gameObject);
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
LanguageChanged();
|
|
}
|
|
|
|
public void LanguageChanged()
|
|
{
|
|
if ((bool)buildNumberText)
|
|
{
|
|
buildNumberText.text = "UFS " + AppParameters.Get.bundleVersion + ":" + AppParameters.Get.buildNumber;
|
|
}
|
|
if ((bool)bugReportText)
|
|
{
|
|
bugReportText.text = ((!isDemo) ? string.Empty : "KICKSTARTER DEMO\n") + "F5 - " + Utilities.GetTranslation("GUI/REPORT_BUG").ToUpper();
|
|
}
|
|
}
|
|
|
|
public void ShowInfo(bool show)
|
|
{
|
|
if ((bool)buildNumberText)
|
|
{
|
|
buildNumberText.enabled = show;
|
|
}
|
|
if ((bool)bugReportText)
|
|
{
|
|
bugReportText.enabled = show;
|
|
}
|
|
}
|
|
|
|
public void CheckBetaAccount()
|
|
{
|
|
}
|
|
|
|
public void CheckGameVersion(int savedGameVersion)
|
|
{
|
|
Debug.Log("CheckGameVersion gameVersion: " + gameVersion + " savedGameVersion: " + savedGameVersion);
|
|
if (gameVersion > 0 && (savedGameVersion == -1 || savedGameVersion == 0) && resetOldSaves)
|
|
{
|
|
saveManager.Reset();
|
|
}
|
|
if (gameVersion != savedGameVersion)
|
|
{
|
|
playerSettings.SaveGameVersion();
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void CheckTextureMemory()
|
|
{
|
|
Utilities.CheckTextureMemory();
|
|
}
|
|
|
|
public string GetPlatformProfileName()
|
|
{
|
|
if (platformProfileName == string.Empty && SteamManager.Initialized)
|
|
{
|
|
platformProfileName = SteamFriends.GetPersonaName();
|
|
}
|
|
return platformProfileName;
|
|
}
|
|
|
|
public ulong GetPlatformProfileID()
|
|
{
|
|
if (platformProfileID == 0 && SteamManager.Initialized)
|
|
{
|
|
platformProfileID = SteamUser.GetSteamID().m_SteamID;
|
|
}
|
|
return platformProfileID;
|
|
}
|
|
|
|
public bool IsMyProfileCracked()
|
|
{
|
|
bool result = false;
|
|
if (!SteamManager.Instance || !SteamManager.Initialized)
|
|
{
|
|
Debug.LogError(string.Concat("IsMyProfileCracked SteamManager.Instance: ", SteamManager.Instance, " SteamManager.Initialized: ", SteamManager.Initialized, " SteamManager.hasSteamAppIdFile: ", SteamManager.hasSteamAppIdFile));
|
|
result = true;
|
|
return true;
|
|
}
|
|
if (CheckCrackSteamID(Convert.ToUInt64(GetPlatformProfileID()).ToString()))
|
|
{
|
|
Debug.LogError("CheckCrackSteamID");
|
|
result = true;
|
|
}
|
|
if (CheckCrackProfileName(GetPlatformProfileName()))
|
|
{
|
|
Debug.LogError("CheckCrackProfileName");
|
|
result = true;
|
|
}
|
|
if (!CheckAppInstalled())
|
|
{
|
|
Debug.LogError("!CheckAppInstalled");
|
|
result = true;
|
|
}
|
|
if (CheckVACBanned())
|
|
{
|
|
Debug.LogError("CheckVACBanned");
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public bool CheckCrackPhotonPlayer(PhotonPlayer photonPlayer)
|
|
{
|
|
bool flag = false;
|
|
if (crackProfileNames.Contains(photonPlayer.NickName))
|
|
{
|
|
flag = true;
|
|
}
|
|
if (!flag && photonPlayer.CustomProperties.ContainsKey("steamId") && crackSteamAccountsID.Contains(Convert.ToUInt64(photonPlayer.CustomProperties["steamId"]).ToString()))
|
|
{
|
|
flag = true;
|
|
}
|
|
if (flag || !photonPlayer.CustomProperties.ContainsKey("gameBundleVersion") || (int)photonPlayer.CustomProperties["gameBundleVersion"] < (int)minOnlineBundleVersion)
|
|
{
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
public bool CheckCrackProfileName(string profileName)
|
|
{
|
|
return crackProfileNames.Contains(profileName);
|
|
}
|
|
|
|
public bool CheckCrackSteamID(ulong profileID)
|
|
{
|
|
return crackSteamAccountsID.Contains(Convert.ToUInt64(profileID).ToString());
|
|
}
|
|
|
|
public bool CheckCrackSteamID(string profileID)
|
|
{
|
|
return crackSteamAccountsID.Contains(profileID);
|
|
}
|
|
|
|
public bool CheckCheatSteamID(ulong profileID)
|
|
{
|
|
return cheatSteamAccountsID.Contains(Convert.ToUInt64(profileID).ToString());
|
|
}
|
|
|
|
public bool CheckAppInstalled()
|
|
{
|
|
return SteamApps.BIsAppInstalled((AppId_t)(uint)SteamManager.Instance.gameId);
|
|
}
|
|
|
|
public bool CheckVACBanned()
|
|
{
|
|
return SteamApps.BIsVACBanned();
|
|
}
|
|
|
|
public bool CheckTeamSteamID()
|
|
{
|
|
bool result = false;
|
|
if (!SteamManager.Initialized || teamSteamAccountsID.Contains(GetPlatformProfileID().ToString()))
|
|
{
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
}
|