2.10.8: fewer hitches
- Sending on a background thread (the game thread blocked whenever the TCP buffer was full, e.g. while uploading the save); small frames are batched - Server save requests: routine saves wait for a calm moment (not while driving fast) and are announced; urgent flag from server 2.10.5 - Dynamic built-in font for all MSCO GUI (Unity logged hundreds of "Font size and style overrides" warnings with stutters) - Admin VEHICLE tab rescans every 30 s / after actions instead of every 5 s; time/weather FSM search less often - Reused buffers for Build/Frame/Poll (less garbage, fewer GC pauses) - Hitch log: GC and save detection, count of hitches between reports - Show Bolt Size 1.0.1: finds the FPSCamera (Camera.main may be missing), uses MSCO's shared FSM list instead of FindObjectsOfType every 2 s Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,9 +7,9 @@ using UnityEngine;
|
||||
[assembly: AssemblyTitle("Show Bolt Size")]
|
||||
[assembly: AssemblyProduct("Show Bolt Size")]
|
||||
[assembly: AssemblyDescription("Shows the size of the bolt you look at, so you pick the right wrench.")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyInformationalVersion("1.0.0")]
|
||||
[assembly: AssemblyVersion("1.0.1.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.1.0")]
|
||||
[assembly: AssemblyInformationalVersion("1.0.1")]
|
||||
|
||||
namespace ShowBoltSize
|
||||
{
|
||||
@@ -22,12 +22,12 @@ namespace ShowBoltSize
|
||||
{
|
||||
public override string ID { get { return "showboltsize"; } }
|
||||
public override string Name { get { return "Show Bolt Size"; } }
|
||||
public override string Version { get { return "1.0.0"; } }
|
||||
public override string Version { get { return "1.0.1"; } }
|
||||
public override string Author { get { return "MBM"; } }
|
||||
|
||||
const float MaxDistance = 1.3f;
|
||||
const float BoltRadius = 0.025f; // so groß wirkt eine Schraube beim Zielen
|
||||
const float ScanInterval = 2f;
|
||||
const float ScanInterval = 5f;
|
||||
|
||||
sealed class Bolt
|
||||
{
|
||||
@@ -41,28 +41,47 @@ namespace ShowBoltSize
|
||||
float nextScan;
|
||||
string label;
|
||||
GUIStyle style;
|
||||
Camera camera;
|
||||
bool reported;
|
||||
|
||||
public override void OnMenuLoad() { inGame = false; bolts.Clear(); label = null; }
|
||||
public override void OnMenuLoad() { inGame = false; bolts.Clear(); label = null; camera = null; reported = false; }
|
||||
public override void OnGameLoad() { inGame = true; nextScan = 0f; }
|
||||
|
||||
/// <summary>
|
||||
/// Spielerkamera: Camera.main gibt es in My Summer Car nicht immer (die Kamera des Spielers ist "FPSCamera").
|
||||
/// </summary>
|
||||
Camera FindCamera()
|
||||
{
|
||||
if (camera != null && camera.enabled && camera.gameObject.activeInHierarchy) return camera;
|
||||
camera = null;
|
||||
foreach (Camera c in Camera.allCameras)
|
||||
if (c.name == "FPSCamera") { camera = c; break; }
|
||||
if (camera == null) camera = Camera.main;
|
||||
return camera;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
label = null;
|
||||
if (!inGame) return;
|
||||
Camera cam = Camera.main;
|
||||
Camera cam = FindCamera();
|
||||
if (cam == null) return;
|
||||
if (Time.realtimeSinceStartup >= nextScan) Scan();
|
||||
if (Time.realtimeSinceStartup >= nextScan) Scan(cam);
|
||||
|
||||
Transform eye = cam.transform;
|
||||
Vector3 eyePos = eye.position, forward = eye.forward;
|
||||
Bolt best = null;
|
||||
float bestAngle = float.MaxValue;
|
||||
foreach (Bolt b in bolts)
|
||||
for (int i = 0; i < bolts.Count; i++)
|
||||
{
|
||||
if (b.Transform == null || !b.Transform.gameObject.activeInHierarchy) continue;
|
||||
Vector3 to = b.Transform.position - eye.position;
|
||||
float distance = to.magnitude;
|
||||
if (distance > MaxDistance || distance < 0.05f) continue;
|
||||
float angle = Vector3.Angle(eye.forward, to);
|
||||
Bolt b = bolts[i];
|
||||
if (b.Transform == null) continue;
|
||||
Vector3 to = b.Transform.position - eyePos;
|
||||
float sq = to.sqrMagnitude;
|
||||
if (sq > MaxDistance * MaxDistance || sq < 0.0025f) continue;
|
||||
if (!b.Transform.gameObject.activeInHierarchy) continue;
|
||||
float distance = Mathf.Sqrt(sq);
|
||||
float angle = Vector3.Angle(forward, to);
|
||||
float limit = Mathf.Atan2(BoltRadius, distance) * Mathf.Rad2Deg + 0.5f;
|
||||
if (angle < limit && angle < bestAngle)
|
||||
{
|
||||
@@ -73,11 +92,15 @@ namespace ShowBoltSize
|
||||
if (best != null) label = Describe(best);
|
||||
}
|
||||
|
||||
void Scan()
|
||||
/// <summary>
|
||||
/// Schrauben aus MSCOs gemeinsamer Liste aller FSMs holen (SceneCache) - nicht selbst das ganze Spiel durchsuchen,
|
||||
/// das ließ das Spiel alle paar Sekunden kurz hängen.
|
||||
/// </summary>
|
||||
void Scan(Camera cam)
|
||||
{
|
||||
nextScan = Time.realtimeSinceStartup + ScanInterval;
|
||||
bolts.Clear();
|
||||
foreach (PlayMakerFSM fsm in Object.FindObjectsOfType<PlayMakerFSM>())
|
||||
foreach (PlayMakerFSM fsm in SceneCache.Fsms(30f))
|
||||
{
|
||||
if (fsm == null || fsm.FsmName != "Screw") continue;
|
||||
FsmFloat f = fsm.FsmVariables.FindFsmFloat("BoltSize");
|
||||
@@ -85,6 +108,11 @@ namespace ShowBoltSize
|
||||
if (f == null && i == null) continue;
|
||||
bolts.Add(new Bolt { Transform = fsm.transform, SizeF = f, SizeI = i });
|
||||
}
|
||||
if (!reported)
|
||||
{
|
||||
reported = true;
|
||||
Log("camera " + cam.name + ", " + bolts.Count + " bolts with a size");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Größe in mm. Das Spiel speichert sie je nach Schraube als 10 oder als 1.0 (= 10 mm).</summary>
|
||||
|
||||
Reference in New Issue
Block a user