Skip to content

Commit 7d0262a

Browse files
author
idealpersona
committed
Add steamworks changes for steam version
1 parent 5a5d43c commit 7d0262a

File tree

3 files changed

+40
-17
lines changed

3 files changed

+40
-17
lines changed

Assets.Scripts.Core.SteamWorks/SteamController.cs

+40
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Assets.Scripts.Core.Buriko;
22
using Assets.Scripts.UI.Tips;
33
using Steamworks;
4+
using System;
45
using System.Linq;
56
using UnityEngine;
67

@@ -20,6 +21,45 @@ public class SteamController : MonoBehaviour
2021

2122
private bool needPushStats;
2223

24+
private void Awake()
25+
{
26+
if (Environment.GetCommandLineArgs().Contains("-nosteam"))
27+
{
28+
Debug.Log("-nosteam switch set, skipping steamworks initialization.");
29+
}
30+
else
31+
{
32+
GameObject gameObject = new GameObject("SteamManager");
33+
steamManager = gameObject.AddComponent<SteamManager>();
34+
userStatsReceived = new Callback<UserStatsReceived_t>(OnUserStatsReceived);
35+
gameID = new CGameID(SteamUtils.GetAppID());
36+
Debug.Log("Steamworks initialized. AppId: " + gameID);
37+
}
38+
}
39+
40+
private void Update()
41+
{
42+
if (!(steamManager == null) && SteamManager.Initialized)
43+
{
44+
if (!requestedStats)
45+
{
46+
bool flag = requestedStats = SteamUserStats.RequestCurrentStats();
47+
}
48+
if (Input.GetKeyDown(KeyCode.R) && Application.platform == RuntimePlatform.WindowsEditor)
49+
{
50+
Debug.Log("Resetting achievements");
51+
SteamUserStats.ResetAllStats(bAchievementsToo: true);
52+
requestedStats = false;
53+
}
54+
if (needPushStats)
55+
{
56+
Debug.Log("Storing steam stats.");
57+
SteamUserStats.StoreStats();
58+
needPushStats = false;
59+
}
60+
}
61+
}
62+
2363
public void Close()
2464
{
2565
if (!(steamManager == null))

Assets.Scripts.Core.SteamWorks/SteamManager.cs

-17
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,6 @@ private void Awake()
4040
{
4141
Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this);
4242
}
43-
try
44-
{
45-
if (SteamAPI.RestartAppIfNecessary(new AppId_t(310360u)))
46-
{
47-
GameSystem.Instance.CanExit = true;
48-
Application.Quit();
49-
return;
50-
}
51-
}
52-
catch (DllNotFoundException arg)
53-
{
54-
Debug.LogError("[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" + arg, this);
55-
GameSystem.Instance.CanExit = true;
56-
Application.Quit();
57-
return;
58-
IL_00ac:;
59-
}
6043
m_bInitialized = SteamAPI.Init();
6144
if (!m_bInitialized)
6245
{

bin/Debug/Assembly-CSharp.dll

512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)