mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
add register required to api
This commit is contained in:
parent
3a81238831
commit
62c654318e
@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using OWML.Common;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace APITestMod;
|
||||
|
||||
public interface IQSBAPI
|
||||
{
|
||||
/// <summary>
|
||||
/// If called, all players connected to YOUR hosted game must have this mod installed.
|
||||
/// </summary>
|
||||
void RegisterRequiredForAllPlayers(IModBehaviour mod);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the player ID of the current player.
|
||||
/// </summary>
|
||||
@ -65,4 +68,4 @@ public interface IQSBAPI
|
||||
/// <param name="messageType">The unique key of the message.</param>
|
||||
/// <param name="handler">The action to be ran when the message is received. The uint is the player ID that sent the messsage.</param>
|
||||
void RegisterHandler<T>(string messageType, Action<uint, T> handler);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,14 @@
|
||||
using System;
|
||||
using OWML.Common;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace QSB.API;
|
||||
|
||||
public interface IQSBAPI
|
||||
{
|
||||
/// <summary>
|
||||
/// If called, all players connected to YOUR hosted game must have this mod installed.
|
||||
/// </summary>
|
||||
void RegisterRequiredForAllPlayers(IModBehaviour mod);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the player ID of the current player.
|
||||
/// </summary>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OWML.Common;
|
||||
using QSB.API.Messages;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
@ -9,6 +10,12 @@ namespace QSB.API;
|
||||
|
||||
public class QSBAPI : IQSBAPI
|
||||
{
|
||||
public void RegisterRequiredForAllPlayers(IModBehaviour mod)
|
||||
{
|
||||
var uniqueName = mod.ModHelper.Manifest.UniqueName;
|
||||
QSBCore.Addons.Add(uniqueName, mod);
|
||||
}
|
||||
|
||||
public uint GetLocalPlayerID() => QSBPlayerManager.LocalPlayerId;
|
||||
public string GetPlayerName(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Name;
|
||||
public uint[] GetPlayerIDs() => QSBPlayerManager.PlayerList.Select(x => x.PlayerId).ToArray();
|
||||
|
@ -235,7 +235,7 @@ public class QSBCore : ModBehaviour
|
||||
/// This addon MUST NOT send any network messages, or create any worldobjects.
|
||||
/// </summary>
|
||||
/// <param name="addon">The behaviour of the addon.</param>
|
||||
public static void RegisterCosmeticAddon(IModBehaviour addon)
|
||||
public static void RegisterNotRequiredForAllPlayers(IModBehaviour addon)
|
||||
{
|
||||
var uniqueName = addon.ModHelper.Manifest.UniqueName;
|
||||
var addonAssembly = addon.GetType().Assembly;
|
||||
|
Loading…
Reference in New Issue
Block a user