Files
MSCO/MSCO.cs
T
MrMahoandClaude Opus 5.5 ea1b0f74d9 Mod 2.8.1: separate mod version from network protocol version
ModVersion (2.8.1, shown in MSCLoader/MSC Launcher) and ProtocolVersion
(2.8) are separate; only the first two digits are compared (P2P host, Steam
lobby, server info, server browser) and only the protocol version is sent,
so minor updates stay compatible with 2.8 servers, hosts and players.
README: how to publish minor and major updates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 17:48:07 +02:00

108 lines
4.3 KiB
C#

using MSCLoader;
using UnityEngine;
namespace MSCO
{
public class MSCO : Mod
{
/// <summary>
/// Version der Mod (MSCLoader / MSC Launcher). Kleine Updates: nur die dritte Stelle erhöhen (2.8.1, 2.8.2 ...) -
/// sie bleiben mit 2.8-Servern und -Mitspielern kompatibel.
/// </summary>
public const string ModVersion = "2.8.1";
/// <summary>
/// Netzwerk-Version (die ersten beiden Stellen). Nur erhöhen, wenn sich das Protokoll inkompatibel ändert - dann
/// auch GameServer.ModVersion im Server und eine neue Mod-Version 2.9.0 o.ä.
/// </summary>
public const string ProtocolVersion = "2.8";
/// <summary>Passt eine andere Version (Server, Host, Mitspieler) zu uns? Verglichen werden nur die ersten zwei Stellen.</summary>
public static bool Compatible(string other)
{
return Protocol(other) == ProtocolVersion;
}
/// <summary>"2.8.3" -> "2.8"</summary>
public static string Protocol(string version)
{
if (string.IsNullOrEmpty(version)) return "";
string[] parts = version.Trim().Split('.');
return parts.Length >= 2 ? parts[0] + "." + parts[1] : version.Trim();
}
public override string ID => "MSCO"; // Your (unique) mod ID
public override string Name => "MSCO"; // Your mod name
public override string Author => "MBM"; // Name of the Author (your name)
public override string Version => ModVersion; // Version
public override string Description => "Online mod by mbm.wtf"; // Short description of your mod
public override Game SupportedGames => Game.MySummerCar;
// Logo in der MSCLoader-Modliste (branding/logo-128.png, in die DLL eingebettet)
public override byte[] Icon { get { return Branding.LogoPng; } set { } }
bool commandAdded;
public override void ModSetup()
{
SetupFunction(Setup.OnMenuLoad, Mod_OnMenuLoad);
SetupFunction(Setup.OnLoad, Mod_OnLoad);
SetupFunction(Setup.PostLoad, Mod_PostLoad);
SetupFunction(Setup.OnSave, Mod_OnSave);
SetupFunction(Setup.OnGUI, Mod_OnGUI);
SetupFunction(Setup.Update, Mod_Update);
SetupFunction(Setup.FixedUpdate, Mod_FixedUpdate);
SetupFunction(Setup.ModSettings, Mod_Settings);
}
/// <summary>Taste zum Ein-/Aussteigen als Beifahrer (in den MSCLoader-Einstellungen änderbar).</summary>
internal static SettingsKeybind PassengerKey;
/// <summary>MSCO-Konsole (Standard F7) und Chat (Standard T), ebenfalls änderbar.</summary>
internal static SettingsKeybind ConsoleKey, ChatKey;
private void Mod_Settings()
{
// All settings should be created here.
// DO NOT put anything that isn't settings or keybinds in here!
PassengerKey = Keybind.Add("passenger", "Ride as passenger (toggle)", KeyCode.P);
ChatKey = Keybind.Add("chat", "Open chat", KeyCode.T);
// Nicht F8: im Pausenmenü öffnet F8 ein Test-Menü des Spiels. Neue ID, damit alte F8-Belegungen nicht übernommen werden
ConsoleKey = Keybind.Add("console_f7", "Open MSCO console", KeyCode.F7);
}
private void Mod_OnMenuLoad()
{
MscoLog.Info("Welcome to MSCO by mbm.wtf");
// Netzwerk + Lobby leben in einem eigenen Objekt, das Szenenwechsel überlebt
MultiplayerManager.Ensure();
if (!commandAdded)
{
ConsoleCommand.Add(new MpCommand());
commandAdded = true;
}
}
private void Mod_OnLoad()
{
// Called once, when mod is loading after game is fully loaded
}
private void Mod_PostLoad()
{
// Called once, after all mods finished OnLoad
}
private void Mod_OnSave()
{
// Called once, when save and quit
}
private void Mod_OnGUI()
{
// Lobby/Status zeichnet der MultiplayerManager
}
private void Mod_Update()
{
// Netzwerk läuft im MultiplayerManager
}
private void Mod_FixedUpdate()
{
// FixedUpdate is called once per fixed frame
}
}
}