GameCharacter clones a MSC human (bodymesh + skeleton, no scripts, physics or animation), puts it into its bind pose, aligns and scales it, and drives the bones every frame from the joint points of the existing MSCO figure (hip, knee, ankle, shoulder, elbow, hand, head pitch, torso lean) by rotating each limb from its rest direction. Limb bones are picked geometrically, so bone naming conventions do not matter. Variant per player id; console 'model classic|game' switches, the MSCO figure is the automatic fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
156 lines
7.6 KiB
C#
156 lines
7.6 KiB
C#
using System;
|
|
|
|
namespace MSCO
|
|
{
|
|
/// <summary>
|
|
/// Alle MSCO-Befehle an einer Stelle - genutzt von der eigenen F7-Konsole (ohne "mp" davor)
|
|
/// und von der MSCLoader-Konsole ("mp ...").
|
|
/// </summary>
|
|
public static class Commands
|
|
{
|
|
public const string Help =
|
|
"connect <host[:port]> - join a dedicated server\n" +
|
|
"switch <nickname> - quickly switch to a favorite server (also /switch in chat)\n" +
|
|
"fav - list your favorite servers\n" +
|
|
"fav add <nick> [host:port] - add a favorite (without address: the server you are on)\n" +
|
|
"fav remove <nick> - remove a favorite\n" +
|
|
"disconnect - leave the server / game\n" +
|
|
"host [port] / join <ip> [port] - direct LAN game (no Steam)\n" +
|
|
"save - save the game (host / singleplayer)\n" +
|
|
"ping [on|off] - show your ping to the server (toggle)\n" +
|
|
"fps [on|off] - show the frames per second (toggle)\n" +
|
|
"/admin - admin menu (kick / ban / teleport / cheats)\n" +
|
|
"vehicles | rig - debug info about vehicles / player models\n" +
|
|
"model [game|classic] - other players as MSC characters or the MSCO figure\n" +
|
|
"vars <filter> - synced vehicle values, e.g. vars oil (debug)\n" +
|
|
"debug - toggle sync debug output\n" +
|
|
"clear - clear this console";
|
|
|
|
static void Favorite(MultiplayerManager mp, string[] args, Action<string> print)
|
|
{
|
|
string sub = args.Length > 1 ? args[1].ToLower() : "list";
|
|
if (sub == "list")
|
|
{
|
|
if (Favorites.All.Count == 0) { print("No favorites yet - open a server in the browser and press FAVORITE, or: fav add <nick>"); return; }
|
|
foreach (Favorites.Favorite f in Favorites.All)
|
|
print(" " + f.Nickname + " -> " + f.Address + (string.IsNullOrEmpty(f.ServerName) ? "" : " (" + f.ServerName + ")"));
|
|
print("switch <nickname> to join one");
|
|
return;
|
|
}
|
|
if (sub == "add" || sub == "set")
|
|
{
|
|
if (args.Length < 3) { print("fav add <nickname> [host:port]"); return; }
|
|
string host = mp.CurrentServerHost, name = mp.CurrentServerName;
|
|
int port = mp.CurrentServerPort;
|
|
if (args.Length > 3 && !ServerBrowser.TryParseAddress(args[3], out host, out port)) { print("Invalid address: " + args[3]); return; }
|
|
if (host == null) { print("You are not on a server - use: fav add <nickname> <host:port>"); return; }
|
|
string error = Favorites.Set(args[2], host, port, name);
|
|
print(error ?? "Favorite '" + Favorites.CleanNickname(args[2]) + "' saved (" + host + ":" + port + ")");
|
|
return;
|
|
}
|
|
if (sub == "remove" || sub == "del" || sub == "delete")
|
|
{
|
|
Favorites.Favorite f = args.Length > 2 ? Favorites.Find(args[2]) : null;
|
|
print(f != null && Favorites.Remove(f) ? "Favorite '" + f.Nickname + "' removed" : "No such favorite");
|
|
return;
|
|
}
|
|
print("fav | fav add <nick> [host:port] | fav remove <nick>");
|
|
}
|
|
|
|
public static void Execute(string[] args, Action<string> print)
|
|
{
|
|
var mp = MultiplayerManager.Instance;
|
|
if (mp == null) { print("Not ready yet"); return; }
|
|
if (args.Length == 0) { print(Help); return; }
|
|
|
|
int port = MultiplayerManager.DefaultPort;
|
|
switch (args[0].ToLower())
|
|
{
|
|
case "help":
|
|
case "?":
|
|
print(Help);
|
|
break;
|
|
case "host":
|
|
if (args.Length > 1) int.TryParse(args[1], out port);
|
|
mp.Host(port);
|
|
break;
|
|
case "join":
|
|
if (args.Length < 2) { print("join <ip> [port]"); return; }
|
|
if (args.Length > 2) int.TryParse(args[2], out port);
|
|
mp.Join(args[1], port);
|
|
break;
|
|
case "stop":
|
|
case "disconnect":
|
|
case "quit":
|
|
mp.Disconnect();
|
|
print("Disconnected.");
|
|
break;
|
|
case "connect":
|
|
{
|
|
string host;
|
|
int serverPort;
|
|
if (args.Length < 2 || !ServerBrowser.TryParseAddress(args[1], out host, out serverPort))
|
|
{
|
|
print("connect <host[:port]>");
|
|
return;
|
|
}
|
|
mp.JoinServer(host, serverPort);
|
|
break;
|
|
}
|
|
case "switch":
|
|
case "sw":
|
|
print(mp.SwitchServer(args.Length > 1 ? args[1] : ""));
|
|
break;
|
|
case "fav":
|
|
case "favs":
|
|
case "favorites":
|
|
Favorite(mp, args, print);
|
|
break;
|
|
case "save":
|
|
mp.SaveGame();
|
|
break;
|
|
case "ping":
|
|
// "ping" schaltet die Anzeige um, "ping on/off" setzt sie
|
|
if (args.Length > 1) mp.ShowPing = args[1].ToLower() == "on" || args[1] == "1";
|
|
else mp.ShowPing = !mp.ShowPing;
|
|
print("Ping: " + mp.PingText + " (display " + (mp.ShowPing ? "on" : "off") + ")");
|
|
break;
|
|
case "fps":
|
|
// "fps" schaltet die Anzeige um, "fps on/off" setzt sie
|
|
if (args.Length > 1) mp.ShowFps = args[1].ToLower() == "on" || args[1] == "1";
|
|
else mp.ShowFps = !mp.ShowFps;
|
|
print("FPS: " + mp.FpsText + " (display " + (mp.ShowFps ? "on" : "off") + ")");
|
|
break;
|
|
case "admin":
|
|
case "/admin":
|
|
mp.OpenAdminMenu();
|
|
break;
|
|
case "rig":
|
|
foreach (string line in mp.DescribeRigs()) print(line);
|
|
break;
|
|
case "model":
|
|
// Mitspieler als echte MSC-Menschen ("game") oder als MSCO-Figur ("classic")
|
|
if (args.Length > 1) RemotePlayer.UseGameModels = args[1].ToLower() != "classic";
|
|
else RemotePlayer.UseGameModels = !RemotePlayer.UseGameModels;
|
|
mp.RebuildAvatars();
|
|
print("Player models: " + (RemotePlayer.UseGameModels ? "MSC characters (model classic = MSCO figure)" : "MSCO figure (model game = MSC characters)"));
|
|
break;
|
|
case "vehicles":
|
|
foreach (string line in mp.DescribeVehicles()) print(line);
|
|
break;
|
|
case "vars":
|
|
// Diagnose: welche Fahrzeugwerte synchronisiert werden (z.B. "vars oil")
|
|
foreach (string line in mp.DescribeVehicleValues(args.Length > 1 ? args[1] : "")) print(line);
|
|
break;
|
|
case "debug":
|
|
FsmSync.Debug = !FsmSync.Debug;
|
|
print("Sync debug output " + (FsmSync.Debug ? "ON" : "OFF"));
|
|
break;
|
|
default:
|
|
print("Unknown command '" + args[0] + "' - type 'help'");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|