New in 0.1.2: - Debug color overlay: tint cars by physics state (yellow=frozen, cyan=fast-path, magenta=full-accuracy), individual toggles per state - Exclude locomotives from Physics Optimizer and Auto Freeze - Debug stats line in overlay showing live counts per state - Resync quality 1/16 option added Defaults tuned for new installs: - Resync quality: 1/4 -> 1/8 - Speed threshold: ~0.7 mph -> 0.2 mph - Overlay opacity: 100% -> 75% Rename: Physics Overhaul -> Physics Optimizer throughout
52 lines
2.1 KiB
C#
52 lines
2.1 KiB
C#
using HarmonyLib;
|
|
using UnityEngine;
|
|
using UnityModManagerNet;
|
|
|
|
namespace RailroaderPhysicsOverhaul;
|
|
|
|
public static class Main
|
|
{
|
|
internal static UnityModManager.ModEntry ModEntry { get; private set; }
|
|
public static ModSettings Settings { get; private set; }
|
|
|
|
public static bool Load(UnityModManager.ModEntry modEntry)
|
|
{
|
|
ModEntry = modEntry;
|
|
|
|
// Load persisted settings (creates defaults if Settings.xml doesn't exist yet).
|
|
Settings = ModSettings.Load(modEntry);
|
|
|
|
// Apply settings to runtime state before any patches run.
|
|
ConsistLOD.Enabled = Settings.OptimizerEnabled;
|
|
ConsistLOD.DistanceThreshold = Settings.DistanceThreshold;
|
|
ConsistLOD.ResyncInterval = Settings.ResyncInterval;
|
|
ConsistLOD.BlacklistEnabled = Settings.BlacklistEnabled;
|
|
ConsistLOD.IsBlacklist = Settings.IsBlacklist;
|
|
foreach (string name in Settings.RoadNumberList)
|
|
ConsistLOD.RoadNumberList.Add(name);
|
|
|
|
ConsistLOD.ExcludeLocomotives = Settings.ExcludeLocosFromLOD;
|
|
ConsistFreezer.ExcludeLocomotives = Settings.ExcludeLocosFromFreeze;
|
|
ConsistFreezer.AutoFreezeEnabled = Settings.AutoFreezeEnabled;
|
|
ConsistFreezer.AutoFreezeDistance = Settings.AutoFreezeDistance;
|
|
ConsistFreezer.AutoFreezeSpeedThreshold = Settings.AutoFreezeSpeedThreshold;
|
|
|
|
var harmony = new Harmony(modEntry.Info.Id);
|
|
harmony.PatchAll();
|
|
PhysicsTimer.TryPatchPositionCars(harmony, modEntry.Logger);
|
|
|
|
var go = new GameObject("RailroaderPhysicsOverhaul.Overlay");
|
|
Object.DontDestroyOnLoad(go);
|
|
var overlay = go.AddComponent<PhysicsOverlayGUI>();
|
|
overlay.Visible = Settings.ShowOverlay;
|
|
overlay.Opacity = Settings.OverlayOpacity;
|
|
go.AddComponent<CarDebugVisualizer>();
|
|
|
|
// UMM settings panel callbacks.
|
|
modEntry.OnGUI = entry => SettingsGUI.Draw(entry, Settings);
|
|
modEntry.OnSaveGUI = entry => Settings.Save(entry);
|
|
|
|
modEntry.Logger.Log("RailroaderPhysicsOverhaul loaded.");
|
|
return true;
|
|
}
|
|
}
|