Characters

This commit is contained in:
2025-10-05 18:21:16 +02:00
parent b52b3aa830
commit 174a399ee7
77 changed files with 14406 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
using Steamworks;
using UnityEngine;
namespace MegaKoop.Game.Networking
{
/// <summary>
/// Handles SteamAPI initialization and callback pumping. Place once in the initial scene.
/// </summary>
[DefaultExecutionOrder(-1000)]
public class SteamBootstrap : MonoBehaviour
{
private static bool isInitialized;
private static SteamBootstrap instance;
public static bool IsInitialized => isInitialized;
private void Awake()
{
if (instance != null)
{
Destroy(gameObject);
return;
}
instance = this;
DontDestroyOnLoad(gameObject);
TryInitializeSteam();
}
private void TryInitializeSteam()
{
if (isInitialized)
{
return;
}
if (!Packsize.Test())
{
Debug.LogError("[SteamBootstrap] Packsize Test returned false. Wrong Steamworks binaries for this platform?");
return;
}
if (!DllCheck.Test())
{
Debug.LogError("[SteamBootstrap] DllCheck Test returned false. Missing Steamworks dependencies.");
return;
}
try
{
isInitialized = SteamAPI.Init();
}
catch (System.DllNotFoundException e)
{
Debug.LogError("[SteamBootstrap] Steamworks native binaries not found: " + e.Message);
isInitialized = false;
}
if (!isInitialized)
{
Debug.LogError("[SteamBootstrap] Failed to initialize Steam API.");
}
else
{
Debug.Log("[SteamBootstrap] Steam API initialized for user " + SteamFriends.GetPersonaName());
}
}
private void Update()
{
if (!isInitialized)
{
return;
}
SteamAPI.RunCallbacks();
}
private void OnDestroy()
{
if (instance == this)
{
ShutdownSteam();
instance = null;
}
}
private void ShutdownSteam()
{
if (!isInitialized)
{
return;
}
SteamAPI.Shutdown();
isInitialized = false;
Debug.Log("[SteamBootstrap] Steam API shutdown.");
}
}
}