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.
- Listed in Players and characters
- Inherits or implements
IDisposable,IInitializable,IIsolate - Attributes
UsedImplicitly,Preserve
Constructors
| Member | What it is |
|---|---|
CustomControllerOffsetReader() | Creates a CustomControllerOffsetReader with default values. |
Fields
5 private and internal fields
| Member | What it is |
|---|---|
private const string FileName | The offsets file name, custom_controller_offsets.json. |
private readonly FileSystemWatcher fileSystemWatcher | Watches the offsets file for writes. |
private static readonly Logger logger | NLog logger for this class. |
private static readonly string projectRoot | Folder above Application.dataPath, where the offsets file lives. The file is created with defaults if missing. |
private CustomControllerOffset settings | The last offsets read from the file. Null until the file changes. |
Properties
1 private and internal property
Methods
7 private and internal methods
| Member | What 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. |