- Passenger: auto ride-along only when the vehicle moves (speed from its motion, also for kinematic remote cars) - no more getting stuck while working in the engine bay or re-captured - Bolts with a function (drain plug: stage 0-5 = oil leak on) are synced as stage and applied through the bolt's own stage logic; world authority sends its state once after joining. Fixes endless oil leaking when players had the drain plug in different states - Admin menu VEHICLE tab: fluids with FILL/EMPTY, all Database parts with wear/damage, REPAIR/BREAK per part, REPAIR ALL, filter - Server profile: info and players as two equal cards, no wrapping - fsmdump also lists FSM variables Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
3.6 KiB
C#
99 lines
3.6 KiB
C#
using UnityEngine;
|
|
|
|
namespace MSCO
|
|
{
|
|
/// <summary>
|
|
/// MSCO - My Summer Car Online. Läuft eigenständig (ohne MSCLoader): gestartet über Unity Doorstop, siehe Bootstrap.
|
|
/// </summary>
|
|
public static class MSCO
|
|
{
|
|
/// <summary>
|
|
/// Version der Mod. Kleine Updates: nur die dritte Stelle erhöhen (2.9.1, 2.9.2 ...) - sie bleiben mit
|
|
/// Servern und Mitspielern derselben ersten zwei Stellen kompatibel.
|
|
/// </summary>
|
|
public const string ModVersion = "2.10.2";
|
|
/// <summary>
|
|
/// Netzwerk-Version (die ersten beiden Stellen). Nur erhöhen, wenn sich das Protokoll inkompatibel ändert - dann
|
|
/// auch GameServer.ModVersion im Server.
|
|
/// </summary>
|
|
public const string ProtocolVersion = "2.8";
|
|
|
|
/// <summary>Passt eine andere Version (Server, Host, Mitspieler) zu uns? Verglichen wird die Netzwerk-Version.</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();
|
|
}
|
|
|
|
/// <summary>Beifahrer ein-/aussteigen (Standard P), Konsole (F7), Chat (T) - änderbar mit "bind" in der Konsole.</summary>
|
|
internal static readonly KeyBinding PassengerKey = new KeyBinding("passenger", "Ride along / get out", KeyCode.P);
|
|
internal static readonly KeyBinding ConsoleKey = new KeyBinding("console", "Open the MSCO console", KeyCode.F7);
|
|
internal static readonly KeyBinding ChatKey = new KeyBinding("chat", "Open the chat", KeyCode.T);
|
|
internal static readonly KeyBinding[] Keys = { PassengerKey, ConsoleKey, ChatKey };
|
|
}
|
|
|
|
/// <summary>Tastenbelegung, gespeichert in den PlayerPrefs (früher in den MSCLoader-Einstellungen).</summary>
|
|
public class KeyBinding
|
|
{
|
|
public readonly string Id, Description;
|
|
public readonly KeyCode Default;
|
|
bool loaded;
|
|
KeyCode key;
|
|
|
|
public KeyBinding(string id, string description, KeyCode defaultKey)
|
|
{
|
|
Id = id;
|
|
Description = description;
|
|
Default = defaultKey;
|
|
}
|
|
|
|
string Pref { get { return "MSCO_Key_" + Id; } }
|
|
|
|
public KeyCode Key
|
|
{
|
|
get
|
|
{
|
|
if (!loaded)
|
|
{
|
|
// Erst im Spiel lesen (PlayerPrefs gehen nicht in statischen Initialisierern)
|
|
KeyCode parsed;
|
|
key = TryParse(PlayerPrefs.GetString(Pref, ""), out parsed) ? parsed : Default;
|
|
loaded = true;
|
|
}
|
|
return key;
|
|
}
|
|
set
|
|
{
|
|
key = value;
|
|
loaded = true;
|
|
PlayerPrefs.SetString(Pref, value.ToString());
|
|
PlayerPrefs.Save();
|
|
}
|
|
}
|
|
|
|
public bool GetKeybindDown()
|
|
{
|
|
return Key != KeyCode.None && Input.GetKeyDown(Key);
|
|
}
|
|
|
|
public static bool TryParse(string text, out KeyCode key)
|
|
{
|
|
key = KeyCode.None;
|
|
if (string.IsNullOrEmpty(text)) return false;
|
|
try
|
|
{
|
|
key = (KeyCode)System.Enum.Parse(typeof(KeyCode), text.Trim(), true);
|
|
return true;
|
|
}
|
|
catch { return false; }
|
|
}
|
|
}
|
|
}
|