Add StickGame Assets
This commit is contained in:
81
phr/StickGame/Assets/SteamIntegration/BootstrapManager.cs
Normal file
81
phr/StickGame/Assets/SteamIntegration/BootstrapManager.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using FishNet.Managing;
|
||||
using Steamworks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class BootstrapManager : MonoBehaviour
|
||||
{
|
||||
private static BootstrapManager instance;
|
||||
private void Awake() => instance = this;
|
||||
|
||||
[SerializeField] private string menuName = "MenuSceneSteam";
|
||||
[SerializeField] private NetworkManager _networkManager;
|
||||
[SerializeField] private FishySteamworks.FishySteamworks _fishySteamworks;
|
||||
|
||||
protected Callback<LobbyCreated_t> LobbyCreated;
|
||||
protected Callback<GameLobbyJoinRequested_t> JoinRequest;
|
||||
protected Callback<LobbyEnter_t> LobbyEntered;
|
||||
|
||||
public static ulong CurrentLobbyID;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
LobbyCreated = Callback<LobbyCreated_t>.Create(OnLobbyCreated);
|
||||
JoinRequest = Callback<GameLobbyJoinRequested_t>.Create(OnJoinRequest);
|
||||
LobbyEntered = Callback<LobbyEnter_t>.Create(OnLobbyEntered);
|
||||
}
|
||||
|
||||
|
||||
public static void CreateLobby()
|
||||
{
|
||||
SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypeFriendsOnly, 4);
|
||||
}
|
||||
|
||||
private void OnLobbyCreated(LobbyCreated_t callback)
|
||||
{
|
||||
Debug.Log("Starting lobby creation: " + callback.m_eResult.ToString());
|
||||
if (callback.m_eResult != EResult.k_EResultOK)
|
||||
return;
|
||||
|
||||
CurrentLobbyID = callback.m_ulSteamIDLobby;
|
||||
SteamMatchmaking.SetLobbyData(new CSteamID(CurrentLobbyID), "HostAddress", SteamUser.GetSteamID().ToString());
|
||||
SteamMatchmaking.SetLobbyData(new CSteamID(CurrentLobbyID), "name", SteamFriends.GetPersonaName().ToString() + "'s lobby");
|
||||
_fishySteamworks.SetClientAddress(SteamUser.GetSteamID().ToString());
|
||||
_fishySteamworks.StartConnection(true);
|
||||
Debug.Log("Lobby creation was successful");
|
||||
}
|
||||
|
||||
private void OnJoinRequest(GameLobbyJoinRequested_t callback)
|
||||
{
|
||||
SteamMatchmaking.JoinLobby(callback.m_steamIDLobby);
|
||||
}
|
||||
|
||||
private void OnLobbyEntered(LobbyEnter_t callback)
|
||||
{
|
||||
CurrentLobbyID = callback.m_ulSteamIDLobby;
|
||||
|
||||
// MainMenuManager.LobbyEntered(SteamMatchmaking.GetLobbyData(new CSteamID(CurrentLobbyID), "name"), _networkManager.IsServer);
|
||||
|
||||
_fishySteamworks.SetClientAddress(SteamMatchmaking.GetLobbyData(new CSteamID(CurrentLobbyID), "HostAddress"));
|
||||
_fishySteamworks.StartConnection(false);
|
||||
}
|
||||
|
||||
public static void JoinByID(CSteamID steamID)
|
||||
{
|
||||
Debug.Log("Attempting to join lobby with ID: " + steamID.m_SteamID);
|
||||
if (SteamMatchmaking.RequestLobbyData(steamID))
|
||||
SteamMatchmaking.JoinLobby(steamID);
|
||||
else
|
||||
Debug.Log("Failed to join lobby with ID: " + steamID.m_SteamID);
|
||||
}
|
||||
|
||||
public static void LeaveLobby()
|
||||
{
|
||||
SteamMatchmaking.LeaveLobby(new CSteamID(CurrentLobbyID));
|
||||
CurrentLobbyID = 0;
|
||||
|
||||
instance._fishySteamworks.StopConnection(false);
|
||||
if (instance._networkManager.IsServer)
|
||||
instance._fishySteamworks.StopConnection(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa38c84cbc25ad4419d78bdc5a2abd75
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
phr/StickGame/Assets/SteamIntegration/Steam Settings.asset
Normal file
44
phr/StickGame/Assets/SteamIntegration/Steam Settings.asset
Normal file
@@ -0,0 +1,44 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 242f29df75dec3d4cb1cbb74a477bee6, type: 3}
|
||||
m_Name: Steam Settings
|
||||
m_EditorClassIdentifier:
|
||||
applicationId:
|
||||
m_AppId: 480
|
||||
callbackTick_Milliseconds: 15
|
||||
isDebugging: 0
|
||||
server:
|
||||
autoInitialize: 0
|
||||
autoLogon: 0
|
||||
ip: 0
|
||||
queryPort: 27016
|
||||
gamePort: 27015
|
||||
serverVersion: 1.0.0.0
|
||||
spectatorPort: 27017
|
||||
usingGameServerAuthApi: 0
|
||||
enableHeartbeats: 1
|
||||
supportSpectators: 0
|
||||
spectatorServerName: Usually GameDescription + Spectator
|
||||
anonymousServerLogin: 0
|
||||
gameServerToken: See https://steamcommunity.com/dev/managegameservers
|
||||
isPasswordProtected: 0
|
||||
serverName: My Server Name
|
||||
gameDescription: Usually the name of your game
|
||||
gameDirectory: e.g. its folder name
|
||||
isDedicated: 0
|
||||
maxPlayerCount: 4
|
||||
botPlayerCount: 0
|
||||
mapName:
|
||||
gameData:
|
||||
rulePairs: []
|
||||
stats: []
|
||||
achievements: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 537856c16aaa3b545820363703062580
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user