Skip to content

Commit

Permalink
Merge pull request #413 from PlayEveryWare/release-3.0.1
Browse files Browse the repository at this point in the history
Release 3.0.1
  • Loading branch information
andrew-hirata-playeveryware authored Sep 25, 2023
2 parents 5809be6 + e5c5f74 commit e564ed7
Show file tree
Hide file tree
Showing 17 changed files with 320 additions and 17 deletions.
4 changes: 4 additions & 0 deletions Assets/Plugins/Linux/EOSManager_Linux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@
using Epic.OnlineServices.IntegratedPlatform;

#if !UNITY_EDITOR_WIN && (UNITY_STANDALONE_LINUX || UNITY_EDITOR_LINUX)

#if !UNITY_EDITOR_LINUX
[assembly: AlwaysLinkAssembly]
#endif

namespace PlayEveryWare.EpicOnlineServices
{
//-------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Assets/Plugins/Source/Core/EOSManager_defaultplatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
using Epic.OnlineServices.Auth;
using Epic.OnlineServices.Logging;
using System.Runtime.InteropServices;
#endif

#if !UNITY_STANDALONE_WIN || !UNITY_EDITOR_WIN || !UNITY_WSA_10_0 || !UNITY_SWITCH || !UNITY_PS4 || !UNITY_PS5 || !UNITY_ANDROID

Expand Down Expand Up @@ -83,4 +82,5 @@ static private void ConfigureSystemPlatformCreateOptions(ref Options createOptio
}
}
#endif
#endif

4 changes: 4 additions & 0 deletions Assets/Plugins/Windows/EOSManager_Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@
using System.Text;

#if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN || UNITY_WSA_10_0)

#if !UNITY_EDITOR_WIN
[assembly: AlwaysLinkAssembly]
#endif

namespace PlayEveryWare.EpicOnlineServices
{
//-------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions Assets/Plugins/macOS/EOSManager_macOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
using System.Runtime.InteropServices;

#if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX

#if !UNITY_EDITOR_OSX
[assembly: AlwaysLinkAssembly]
#endif

namespace PlayEveryWare.EpicOnlineServices
{
//-------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/FacePunch.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

230 changes: 230 additions & 0 deletions Assets/Scripts/FacePunch/FacePunchSteamManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
/*
* Copyright (c) 2021 PlayEveryWare
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

/*
* This script is made using Facepunch.Steamworks Version 2.3.2
*/


#if ENABLE_FACEPUNCH_STEAM && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || STEAMWORKS_WIN || STEAMWORKS_LIN_OSX)

using UnityEngine;
using System.IO;

namespace PlayEveryWare.EpicOnlineServices.Samples.Steam
{
public class SteamManager : MonoBehaviour
{
protected static SteamManager s_instance;
public static SteamManager Instance
{
get
{
if (s_instance == null)
{
return new GameObject("FacepunchSteamManager").AddComponent<SteamManager>();
}
else
{
return s_instance;
}
}
}

protected bool m_bInitialized = false;
public static bool Initialized
{
get
{
return Instance.m_bInitialized;
}
}

#if UNITY_2019_3_OR_NEWER
// In case of disabled Domain Reload, reset static members before entering Play Mode.
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void InitOnPlayMode()
{
s_instance = null;
}
#endif
protected virtual void Awake()
{
// Only one instance of SteamManager at a time!
if (s_instance != null)
{
Destroy(gameObject);
return;
}
s_instance = this;

// We want our SteamManager Instance to persist across scenes.
DontDestroyOnLoad(gameObject);

try
{
uint steamAppId = GetSteamAppID();
Steamworks.SteamClient.Init(steamAppId);
Debug.LogWarning("[Facepunch Steamworks] Initialized");
}
catch (System.Exception e)
{
Debug.LogError(e.Message);
Debug.LogError("[Facepunch Steamworks] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this);

// Something went wrong - it's one of these:
//
// Steam is closed?
// Can't find steam_api dll?
// Don't have permission to play app?
//

return;

}
m_bInitialized = true;
}

protected virtual void OnEnable()
{
if (s_instance == null)
{
s_instance = this;
}

if (!m_bInitialized)
{
return;
}
}

protected virtual void OnDestroy()
{
if (s_instance != this)
{
return;
}

s_instance = null;

if (!m_bInitialized)
{
return;
}

Steamworks.SteamClient.Shutdown();
}

public void StartLoginWithSteam(EOSManager.OnAuthLoginCallback onLoginCallback)
{
#if DISABLESTEAMWORKS
onLoginCallback?.Invoke(new Epic.OnlineServices.Auth.LoginCallbackInfo() { ResultCode = Epic.OnlineServices.Result.UnexpectedError });
#else

string steamId = Steamworks.SteamClient.SteamId.ToString();

byte[] sessionTicket = Steamworks.SteamUser.GetAuthSessionTicket().Data;
string sessionTicketString = System.BitConverter.ToString(sessionTicket).Replace("-", "");

if (steamId == null)
{
Debug.LogError("ExternalAuth failed: Steam ID not valid");
}
else if (sessionTicketString == null)
{
Debug.LogError("ExternalAuth failed: Steam session ticket not valid");
}
else
{
EOSManager.Instance.StartLoginWithLoginTypeAndToken(
Epic.OnlineServices.Auth.LoginCredentialType.ExternalAuth,
Epic.OnlineServices.ExternalCredentialType.SteamSessionTicket,
steamId,
sessionTicketString,
onLoginCallback);
}
#endif
}
public async void StartConnectLoginWithSteamAppTicket(EOSManager.OnConnectLoginCallback onLoginCallback)
{
byte[] encryptedAppTicket = await Steamworks.SteamUser.RequestEncryptedAppTicketAsync();
if (encryptedAppTicket == null)
{
Debug.LogError("Connect Login failed: Unable to get Steam app ticket");
onLoginCallback?.Invoke(new Epic.OnlineServices.Connect.LoginCallbackInfo() { ResultCode = Epic.OnlineServices.Result.UnexpectedError });
}
else
{
string appTicketString = System.BitConverter.ToString(encryptedAppTicket).Replace("-", "");
EOSManager.Instance.StartConnectLoginWithOptions(Epic.OnlineServices.ExternalCredentialType.SteamAppTicket, appTicketString, onloginCallback: onLoginCallback);
}
}
public void StartConnectLoginWithSteamSessionTicket(EOSManager.OnConnectLoginCallback onLoginCallback)
{
byte[] sessionTicket = Steamworks.SteamUser.GetAuthSessionTicket().Data;
if (sessionTicket == null)
{
Debug.LogError("Connect Login failed: Unable to get Steam session ticket");
onLoginCallback?.Invoke(new Epic.OnlineServices.Connect.LoginCallbackInfo() { ResultCode = Epic.OnlineServices.Result.UnexpectedError });
}
else
{
string sessionTicketString = System.BitConverter.ToString(sessionTicket).Replace("-", "");
EOSManager.Instance.StartConnectLoginWithOptions(Epic.OnlineServices.ExternalCredentialType.SteamSessionTicket, sessionTicketString, onloginCallback: onLoginCallback);
}
}

uint GetSteamAppID()
{
string steamAppIdPath = Path.Combine(Directory.GetCurrentDirectory(), "steam_appid.txt");

uint steamAppID;

//Read the value in steam_appid.txt if it exists
if (File.Exists(steamAppIdPath))
{
using (StreamReader streamReader = new StreamReader(steamAppIdPath))
{
string appIdAsText = streamReader.ReadToEnd();
if (uint.TryParse(appIdAsText, out steamAppID))
{
return steamAppID;
}

//If the value is invalid, return the default value.
Debug.LogError("steam_appid.txt contains invalid value, make sure it only contains the games app id and nothing else");
return 0;
}
}

//Creates a default steam_appid.txt if its missing
StreamWriter appIdFile = File.CreateText(steamAppIdPath);
appIdFile.Write("480");
appIdFile.Close();
Debug.LogError("steam_appid.txt created, open the file and rewrite the app id with your games app id");

return 480;

}
}
}
#endif
11 changes: 11 additions & 0 deletions Assets/Scripts/FacePunch/FacePunchSteamManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "com.playeveryware.eos.samples.facepunch-steamworks",
"rootNamespace": "",
"references": [
"GUID:3a63500f0eef43a438c0553491f7c5da",
"GUID:be1f6e9efffcfce41aeb5c2f4c27cf75"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Assets/Scripts/Steam/SteamManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
//
// Version: 1.0.12

#if !ENABLE_FACEPUNCH_STEAM

#if !STEAMWORKS_MODULE || !(UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || STEAMWORKS_WIN || STEAMWORKS_LIN_OSX)
#define DISABLESTEAMWORKS
#endif
Expand Down Expand Up @@ -410,4 +412,6 @@ public void StartConnectLoginWithSteamAppTicket(EOSManager.OnConnectLoginCallbac
#endif
}
}
}
}

#endif
5 changes: 3 additions & 2 deletions Assets/Scripts/com.playeveryware.eos.samples.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
"GUID:3a63500f0eef43a438c0553491f7c5da",
"GUID:575987b8fe219a04c8864880f8ca646b",
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:8979f042b0046d344a016c4b2f59e32b",
"GUID:e0c32ae092d640a42bb7d7442a830160",
"GUID:95f7fb3da141c854cb8570e857d6f1a9",
"GUID:9cd18375d954b144ca6843704e93ace1",
"GUID:a095d5f0621c943d19ea12b9bd6fc47a",
"GUID:be1f6e9efffcfce41aeb5c2f4c27cf75",
"GUID:d05351cc96cc28c41bee26cf7187c9e6",
"GUID:da388c951237dad49ac09ebed548a2dd",
"GUID:75469ad4d38634e559750d17036d5f7c"
"GUID:da388c951237dad49ac09ebed548a2dd"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
15 changes: 14 additions & 1 deletion EOSUnityPlugin_package_template/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
### Fixed

##[4.0.0] - 2023-09-15
##[3.0.1] - 2023-09-22
### Inprogress
### Unreleased
### Added
- Facepunch steamworks login support - squashed
### Changed
### Removed
### Fixed
- fix : compile error when EOS_DISABLE
- fix : remove duplicate asmrefs



##[3.0.0] - 2023-09-15

### Inprogress
### Unreleased
Expand Down
Loading

0 comments on commit e564ed7

Please sign in to comment.