From a22c505984697881f5f911a165ee022087b69e09 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Mon, 20 May 2024 22:36:58 +0800 Subject: *rename --- Thronefall_1_0/Decompile/SteamManager.cs | 209 ------------------------------- 1 file changed, 209 deletions(-) delete mode 100644 Thronefall_1_0/Decompile/SteamManager.cs (limited to 'Thronefall_1_0/Decompile/SteamManager.cs') diff --git a/Thronefall_1_0/Decompile/SteamManager.cs b/Thronefall_1_0/Decompile/SteamManager.cs deleted file mode 100644 index fb2f904..0000000 --- a/Thronefall_1_0/Decompile/SteamManager.cs +++ /dev/null @@ -1,209 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using AOT; -using Steamworks; -using UnityEngine; -using UnityEngine.Events; - -[DisallowMultipleComponent] -public class SteamManager : MonoBehaviour -{ - public struct LeaderboardEntry - { - public string username; - - public int score; - } - - protected static bool s_EverInitialized = false; - - protected static SteamManager s_instance; - - protected bool m_bInitialized; - - protected SteamAPIWarningMessageHook_t m_SteamAPIWarningMessageHook; - - private static CallResult _findLeaderboardCallback = new CallResult(); - - public static int scoreToUpload = -1; - - private static CallResult _downloadedScoresCallback = new CallResult(); - - public List lastDownloadedLeaderboardEntires = new List(); - - public UnityEvent OnLeaderboardDownloadCallbackComplete = new UnityEvent(); - - public static SteamManager Instance - { - get - { - if (s_instance == null) - { - return new GameObject("SteamManager").AddComponent(); - } - return s_instance; - } - } - - public static bool Initialized => Instance.m_bInitialized; - - [MonoPInvokeCallback(typeof(SteamAPIWarningMessageHook_t))] - protected static void SteamAPIDebugTextHook(int nSeverity, StringBuilder pchDebugText) - { - Debug.LogWarning(pchDebugText); - } - - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] - private static void InitOnPlayMode() - { - s_EverInitialized = false; - s_instance = null; - } - - protected virtual void Awake() - { - if (s_instance != null) - { - UnityEngine.Object.Destroy(base.gameObject); - return; - } - s_instance = this; - scoreToUpload = -1; - if (s_EverInitialized) - { - throw new Exception("Tried to Initialize the SteamAPI twice in one session!"); - } - UnityEngine.Object.DontDestroyOnLoad(base.transform.root.gameObject); - if (!Packsize.Test()) - { - Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this); - } - if (!DllCheck.Test()) - { - Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this); - } - try - { - if (SteamAPI.RestartAppIfNecessary(AppId_t.Invalid)) - { - Debug.Log("[Steamworks.NET] Shutting down because RestartAppIfNecessary returned true. Steam will restart the application."); - Application.Quit(); - return; - } - } - catch (DllNotFoundException ex) - { - Debug.Log("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + ex, this); - Application.Quit(); - return; - } - m_bInitialized = SteamAPI.Init(); - if (!m_bInitialized) - { - Debug.Log("[Steamworks.NET] SteamAPI_Init() failed. This is likely the case because the Steam client is not running.", this); - } - else - { - s_EverInitialized = true; - } - } - - protected virtual void OnEnable() - { - if (s_instance == null) - { - s_instance = this; - } - if (m_bInitialized && m_SteamAPIWarningMessageHook == null) - { - m_SteamAPIWarningMessageHook = SteamAPIDebugTextHook; - SteamClient.SetWarningMessageHook(m_SteamAPIWarningMessageHook); - } - } - - protected virtual void OnDestroy() - { - if (!(s_instance != this)) - { - s_instance = null; - if (m_bInitialized) - { - SteamAPI.Shutdown(); - } - } - } - - protected virtual void Update() - { - if (m_bInitialized) - { - SteamAPI.RunCallbacks(); - } - } - - public void UploadHighscore(int _score, string _leaderboardName) - { - if (Initialized) - { - if (scoreToUpload != -1) - { - Debug.LogError("You can't upload multiple scores symultaneously with the current system."); - return; - } - scoreToUpload = _score; - SteamAPICall_t hAPICall = SteamUserStats.FindOrCreateLeaderboard(_leaderboardName, ELeaderboardSortMethod.k_ELeaderboardSortMethodDescending, ELeaderboardDisplayType.k_ELeaderboardDisplayTypeNumeric); - _findLeaderboardCallback.Set(hAPICall, OnFindLeaderboardForUploadingScore); - } - } - - public void OnFindLeaderboardForUploadingScore(LeaderboardFindResult_t _callback, bool _failure) - { - if (_failure) - { - scoreToUpload = -1; - return; - } - SteamUserStats.UploadLeaderboardScore(_callback.m_hSteamLeaderboard, ELeaderboardUploadScoreMethod.k_ELeaderboardUploadScoreMethodKeepBest, scoreToUpload, new int[0], 0); - scoreToUpload = -1; - } - - public void DownloadFriendsHighscores(string _leaderboardName) - { - lastDownloadedLeaderboardEntires.Clear(); - if (Initialized) - { - SteamAPICall_t hAPICall = SteamUserStats.FindLeaderboard(_leaderboardName); - _findLeaderboardCallback.Set(hAPICall, OnFindLeaderboardFodDownloadingFriendsScore); - } - } - - public void OnFindLeaderboardFodDownloadingFriendsScore(LeaderboardFindResult_t _callback, bool _failure) - { - if (!_failure) - { - SteamAPICall_t hAPICall = SteamUserStats.DownloadLeaderboardEntries(_callback.m_hSteamLeaderboard, ELeaderboardDataRequest.k_ELeaderboardDataRequestFriends, 1, 100); - _downloadedScoresCallback.Set(hAPICall, OnDownloadedScores); - } - } - - public void OnDownloadedScores(LeaderboardScoresDownloaded_t _callback, bool _failure) - { - if (_failure) - { - OnLeaderboardDownloadCallbackComplete.Invoke(); - return; - } - SteamUserStats.GetLeaderboardName(_callback.m_hSteamLeaderboard); - int[] pDetails = new int[0]; - for (int i = 0; i < _callback.m_cEntryCount; i++) - { - SteamUserStats.GetDownloadedLeaderboardEntry(_callback.m_hSteamLeaderboardEntries, i, out var pLeaderboardEntry, pDetails, 0); - LeaderboardEntry item = default(LeaderboardEntry); - item.username = SteamFriends.GetFriendPersonaName(pLeaderboardEntry.m_steamIDUser); - item.score = pLeaderboardEntry.m_nScore; - lastDownloadedLeaderboardEntires.Add(item); - } - OnLeaderboardDownloadCallbackComplete.Invoke(); - } -} -- cgit v1.1-26-g67d0