Skip to main content

CustomControllerOffsetReader

A class in Root.Township, Alta.Character.

Client service (created by VContainer) that reads per-hand position and scale offsets from custom_controller_offsets.json next to the game's data folder, watches the file, and applies the offsets to the local player's hands.

Constructors​

MemberWhat it is
CustomControllerOffsetReader()Creates a CustomControllerOffsetReader with default values.

Fields​

5 private and internal fields
MemberWhat it is
private const string FileNameThe offsets file name, custom_controller_offsets.json.
private readonly FileSystemWatcher fileSystemWatcherWatches the offsets file for writes.
private static readonly Logger loggerNLog logger for this class.
private static readonly string projectRootFolder above Application.dataPath, where the offsets file lives. The file is created with defaults if missing.
private CustomControllerOffset settingsThe last offsets read from the file. Null until the file changes.

Properties​

1 private and internal property
MemberWhat it is
private bool IsDisposed { get; set; }True after the reader has been disposed.

Methods​

MemberWhat it is
void Dispose()Disposes the file watcher.
void Initialize()VContainer entry point: applies the offsets. Settings are only loaded once the file changes, so this usually does nothing at start.
protected override void Finalize()Finalizer that disposes without touching managed objects.
7 private and internal methods
MemberWhat it is
private void ApplyOffsets()Clamps the offsets and applies them to both hands of PlayerController.Current, if settings are loaded and a local player exists.
private bool CanApplyOffsets()True when settings are loaded and a local player exists. If there is no player yet, it waits for LocalPlayerSet.
private static Vector3 ClampScale(Vector3 scale)Clamps a scale to 0.5 to 1.5. Note: Y and Z are set from the clamped X, so the scale ends up uniform.
private void Dispose(bool disposing)Disposes the file watcher.
private void EnforceOffsetLimits()Limits each hand's position offset to 0.5 m and clamps its scale.
private void OnFileChanged(object sender, FileSystemEventArgs e)Reloads the settings from the file when it is written and applies them on the main thread.
private void OnLocalPlayerSet(PlayerController playerController)Applies the offsets once the local player appears, then unsubscribes.