mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
add OnStartHost and OnStopHost
This commit is contained in:
parent
e7160e709c
commit
fb49c6e132
@ -69,6 +69,16 @@ public interface IQSBAPI
|
||||
/// </summary>
|
||||
UnityEvent<uint> OnPeerLeave();
|
||||
|
||||
/// <summary>
|
||||
/// Invoked on the host when the server is first started.
|
||||
/// </summary>
|
||||
UnityEvent OnStartHost();
|
||||
|
||||
/// <summary>
|
||||
/// Invoked on the host when the server is closed.
|
||||
/// </summary>
|
||||
UnityEvent OnStopHost();
|
||||
|
||||
/// <summary>
|
||||
/// Sets some arbitrary data for a given player.
|
||||
/// </summary>
|
||||
|
@ -69,6 +69,16 @@ public interface IQSBAPI
|
||||
/// </summary>
|
||||
UnityEvent<uint> OnPeerLeave();
|
||||
|
||||
/// <summary>
|
||||
/// Invoked on the host when the server is first started.
|
||||
/// </summary>
|
||||
UnityEvent OnStartHost();
|
||||
|
||||
/// <summary>
|
||||
/// Invoked on the host when the server is closed.
|
||||
/// </summary>
|
||||
UnityEvent OnStopHost();
|
||||
|
||||
/// <summary>
|
||||
/// Sets some arbitrary data for a given player.
|
||||
/// </summary>
|
||||
|
@ -32,6 +32,9 @@ public class QSBAPI : IQSBAPI
|
||||
public UnityEvent<uint> OnPeerJoin() => QSBAPIEvents.OnPeerJoinEvent;
|
||||
public UnityEvent<uint> OnPeerLeave() => QSBAPIEvents.OnPeerLeaveEvent;
|
||||
|
||||
public UnityEvent OnStartHost() => QSBAPIEvents.OnStartHostEvent;
|
||||
public UnityEvent OnStopHost() => QSBAPIEvents.OnStopHostEvent;
|
||||
|
||||
public void SetCustomData<T>(uint playerId, string key, T data) => QSBPlayerManager.GetPlayer(playerId).SetCustomData(key, data);
|
||||
public T GetCustomData<T>(uint playerId, string key) => QSBPlayerManager.GetPlayer(playerId).GetCustomData<T>(key);
|
||||
|
||||
@ -85,4 +88,7 @@ internal static class QSBAPIEvents
|
||||
|
||||
internal static PlayerEvent OnPeerJoinEvent = new();
|
||||
internal static PlayerEvent OnPeerLeaveEvent = new();
|
||||
|
||||
internal static UnityEvent OnStartHostEvent = new();
|
||||
internal static UnityEvent OnStopHostEvent = new();
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ using QSB.WorldSync;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using QSB.API;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB;
|
||||
@ -402,8 +403,15 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart
|
||||
base.OnServerDisconnect(conn);
|
||||
}
|
||||
|
||||
public override void OnStartServer()
|
||||
{
|
||||
QSBAPIEvents.OnStartHostEvent.Invoke();
|
||||
base.OnStartServer();
|
||||
}
|
||||
|
||||
public override void OnStopServer()
|
||||
{
|
||||
QSBAPIEvents.OnStopHostEvent.Invoke();
|
||||
DebugLog.DebugWrite("OnStopServer", MessageType.Info);
|
||||
Destroy(GetComponent<RespawnOnDeath>());
|
||||
DebugLog.ToConsole("Server stopped!", MessageType.Info);
|
||||
|
Loading…
Reference in New Issue
Block a user