MSCO 2.10.0: mod support, ESC no longer quits from the main menu
- 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>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Beispiel-Mod für MSCO. Bauen: msbuild HelloMod.csproj -p:Configuration=Release
|
||||
Ergebnis bin\Release\HelloMod.dll nach <Spielordner>\MSCO\Mods kopieren (oder auf dem Server nach data/mods).
|
||||
GamePath anpassen, wenn My Summer Car woanders liegt.
|
||||
-->
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>HelloMod</RootNamespace>
|
||||
<AssemblyName>HelloMod</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Unity Full v3.5</TargetFrameworkProfile>
|
||||
<LangVersion>13</LangVersion>
|
||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<GamePath Condition=" '$(GamePath)' == '' ">F:\SteamLibrary\steamapps\common\My Summer Car</GamePath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>$(GamePath)\mysummercar_Data\Managed\UnityEngine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<!-- MSCO selbst (die Mod-Schnittstelle MscoMod) -->
|
||||
<Reference Include="MSCO">
|
||||
<HintPath>$(GamePath)\MSCO\MSCO.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="HelloMod.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Reference in New Issue
Block a user