Less garbage, fewer GC hitches: no Joint array per part every 0.5 s, cheap aim check after clicks, cached FPS/ping/chat labels; perf report measures object sync, vehicle fx and part/bolt sync correctly
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fe08fa5213
commit
d567d5992a
+33
-9
@@ -367,11 +367,23 @@ namespace MSCO
|
||||
}
|
||||
// grün ab 50, gelb ab 30, sonst rot
|
||||
fpsStyle.normal.textColor = fpsValue < 0f ? UiTheme.Muted : fpsValue >= 50f ? UiTheme.Online : fpsValue >= 30f ? UiTheme.Pending : UiTheme.Danger;
|
||||
var content = new GUIContent(fpsValue < 0f ? "FPS ..." : "FPS " + Mathf.RoundToInt(fpsValue));
|
||||
float width = fpsStyle.CalcSize(content).x;
|
||||
GUI.Box(new Rect(rightEdge - width, 8, width, 24), content, fpsStyle);
|
||||
int shown = fpsValue < 0f ? -1 : Mathf.RoundToInt(fpsValue);
|
||||
if (shown != fpsShown || fpsContent.text == null)
|
||||
{
|
||||
fpsShown = shown;
|
||||
fpsContent.text = shown < 0 ? "FPS ..." : "FPS " + shown;
|
||||
fpsWidth = fpsStyle.CalcSize(fpsContent).x;
|
||||
}
|
||||
GUI.Box(new Rect(rightEdge - fpsWidth, 8, fpsWidth, 24), fpsContent, fpsStyle);
|
||||
}
|
||||
|
||||
// Anzeige-Texte zwischengespeichert (nur bei Änderung neu gebaut, siehe DrawFps/DrawPing)
|
||||
readonly GUIContent fpsContent = new GUIContent(), pingContent = new GUIContent();
|
||||
int fpsShown = int.MinValue;
|
||||
float fpsWidth;
|
||||
string pingShown;
|
||||
float pingTextWidth;
|
||||
|
||||
/// <summary>Text für Anzeige und Konsole.</summary>
|
||||
public string PingText
|
||||
{
|
||||
@@ -379,7 +391,10 @@ namespace MSCO
|
||||
{
|
||||
if (session == null) return "not connected";
|
||||
if (session.IsHost) return "you are the host";
|
||||
return pingMs < 0f ? "measuring..." : Mathf.RoundToInt(pingMs) + " ms";
|
||||
if (pingMs < 0f) return "measuring...";
|
||||
int ms = Mathf.RoundToInt(pingMs);
|
||||
if (ms != pingTextMs || pingTextCache == null) { pingTextMs = ms; pingTextCache = ms + " ms"; }
|
||||
return pingTextCache;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,12 +412,20 @@ namespace MSCO
|
||||
// Farbe nach Qualität: grün < 80 ms, gelb < 150 ms, sonst rot
|
||||
Color color = pingMs < 0f ? UiTheme.Muted : pingMs < 80f ? UiTheme.Online : pingMs < 150f ? UiTheme.Pending : UiTheme.Danger;
|
||||
pingStyle.normal.textColor = color;
|
||||
var content = new GUIContent("PING " + PingText);
|
||||
float width = pingStyle.CalcSize(content).x;
|
||||
GUI.Box(new Rect(Screen.width - width - 12, 8, width, 24), content, pingStyle);
|
||||
string ping = PingText; // ändert sich nur, wenn eine neue Messung da ist
|
||||
if (ping != pingShown)
|
||||
{
|
||||
pingShown = ping;
|
||||
pingContent.text = "PING " + ping;
|
||||
pingTextWidth = pingStyle.CalcSize(pingContent).x;
|
||||
}
|
||||
float width = pingTextWidth;
|
||||
GUI.Box(new Rect(Screen.width - width - 12, 8, width, 24), pingContent, pingStyle);
|
||||
pingWidth = width + 8;
|
||||
}
|
||||
float pingWidth; // Platz, den die Ping-Anzeige belegt (FPS steht links daneben)
|
||||
int pingTextMs = int.MinValue;
|
||||
string pingTextCache;
|
||||
|
||||
// ---------------------------------------------------------------- Cheats (Admin-Menü)
|
||||
|
||||
@@ -2170,12 +2193,12 @@ namespace MSCO
|
||||
PartStart();
|
||||
try { objects.Update(localPlayer, Time.deltaTime); }
|
||||
catch (System.Exception e) { ReportError("object sync", e); }
|
||||
PartStart();
|
||||
PartEnd("object sync");
|
||||
PartStart();
|
||||
try { vehicleFx.Update(objects, SendGame, Time.deltaTime, IsWorldAuthority); }
|
||||
catch (System.Exception e) { ReportError("vehicle lights/sound", e); }
|
||||
PartStart();
|
||||
PartEnd("vehicle lights/sound");
|
||||
PartStart();
|
||||
try { worldSync.Update(IsWorldAuthority, SendGame, Time.unscaledDeltaTime); }
|
||||
catch (System.Exception e) { ReportError("time/weather sync", e); }
|
||||
PartEnd("time/weather sync");
|
||||
@@ -2260,6 +2283,7 @@ namespace MSCO
|
||||
}
|
||||
|
||||
// Abgefangene Schraub-/Montage-Aktionen verschicken
|
||||
PartStart();
|
||||
try
|
||||
{
|
||||
FsmSync.Enabled = ready;
|
||||
|
||||
Reference in New Issue
Block a user