- MscoMod API (ModApi.cs) and ModLoader: own mods from MSCO\Mods, hooks for menu/game/update/GUI, session and player events, Send/OnMessage between players (MsgType.ModMessage) - Server mods: ModList before Welcome, consent prompt (INSTALL & JOIN), download with SHA-256 check into MSCO\Mods\Servers, active only on that server; game start waits for the download - Mods page in the MSCO menu, console command "mods" - Server browser: MODS pill, VANILLA/MODDED filters, mod list in the server profile - PlayMaker ApplicationQuit is ignored in the main menu (ESC used to close the game) - MODDING.md and examples/HelloMod Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using System.Reflection;
|
|
using System.Text;
|
|
using MSCO;
|
|
using UnityEngine;
|
|
|
|
[assembly: AssemblyTitle("Hello Mod")]
|
|
[assembly: AssemblyProduct("Hello Mod")]
|
|
[assembly: AssemblyVersion("1.0.0.0")]
|
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
[assembly: AssemblyInformationalVersion("1.0.0")]
|
|
|
|
namespace HelloMod
|
|
{
|
|
/// <summary>
|
|
/// Beispiel-Mod: zeigt im Spiel oben links einen Hinweis. Mit H winkst du - alle anderen Spieler, die die Mod auch
|
|
/// haben, sehen "<Name> waves!".
|
|
/// </summary>
|
|
public class HelloMod : MscoMod
|
|
{
|
|
public override string ID { get { return "hellomod"; } }
|
|
public override string Name { get { return "Hello Mod"; } }
|
|
public override string Version { get { return "1.0.0"; } }
|
|
public override string Author { get { return "MBM"; } }
|
|
|
|
bool inGame;
|
|
string lastWave = "";
|
|
float waveUntil;
|
|
|
|
public override void OnLoad() { Log("loaded"); }
|
|
public override void OnMenuLoad() { inGame = false; }
|
|
public override void OnGameLoad() { inGame = true; }
|
|
|
|
public override void Update()
|
|
{
|
|
if (!inGame || !IsInSession || !Input.GetKeyDown(KeyCode.H)) return;
|
|
Send(Encoding.UTF8.GetBytes("wave"));
|
|
Show("You wave!");
|
|
}
|
|
|
|
public override void OnMessage(int fromPlayerId, byte[] data)
|
|
{
|
|
if (Encoding.UTF8.GetString(data) != "wave") return;
|
|
string name;
|
|
Show((Players.TryGetValue(fromPlayerId, out name) ? name : "Someone") + " waves!");
|
|
}
|
|
|
|
public override void OnPlayerJoined(int playerId, string name) { Show(name + " joined - press H to wave"); }
|
|
|
|
void Show(string text)
|
|
{
|
|
lastWave = text;
|
|
waveUntil = Time.realtimeSinceStartup + 4f;
|
|
}
|
|
|
|
public override void OnGUI()
|
|
{
|
|
if (!inGame) return;
|
|
GUI.Label(new Rect(20, 60, 400, 24), "Hello Mod: press H to wave");
|
|
if (Time.realtimeSinceStartup < waveUntil) GUI.Label(new Rect(20, 84, 400, 24), lastWave);
|
|
}
|
|
}
|
|
}
|