This repository has been archived on 2026-05-30. You can view files and clone it, but cannot push or open issues or pull requests.
Files
undead-universal-patch-il2cpp/Core/SteamPlatform.cs

46 lines
1.8 KiB
C#

using Il2CppInterop.Runtime;
using Steamworks;
using System;
using undead_universal_patch_il2cpp.Core.Content.CustomRecNet;
using UnityEngine;
namespace undead_universal_patch_il2cpp.Core;
public class SteamPlatform : MonoBehaviour
{
public static string AuthTicket { get; set; } = null;
void GetAuthTicket() {
SteamPlatformManager manager = PlatformManager.Instance.GetComponentInChildren<SteamPlatformManager>();
manager.GetAuthSessionTicket().Then(
DelegateSupport.ConvertDelegate<Il2CppSystem.Action<SteamPlatformManager.AuthSessionTicket>>((SteamPlatformManager.AuthSessionTicket ticket) =>
{
if (!string.IsNullOrEmpty(ticket.Error)) UniversalPatchPlugin.Log.LogError($"Could not get Steam auth ticket!: {ticket.Error}");
else
{
AuthTicket = BitConverter.ToString(ticket.Ticket).Replace("-", "").ToUpperInvariant().TrimEnd('0');
Util.ConditionalDebug($"Got new Steam auth ticket");
}
}));
}
void Start()
{
RecNetInteractions.onLogout.Add(GetAuthTicket);
RecNetInteractions.onPlatformInitialize.Add(GetAuthTicket);
/*
Every time the user logs out of matchmaking
or when PlatformManager initializes, fetch a new ticket.
The user might be logging out to the account selection screen
where they might create a new one; a Steam auth ticket is added to
the auth params in the create request and it must be valid.
It *is* possible (though very unlikely) that the user creates a new account
before the first ticket is fetched, since the method that gets a ticket is
an IPromise.
If this way of doing things isn't the best, fix it and I'll merge
*/
}
}