Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 23, 2025

Addresses code smell: instance method OnEngineInit() was directly writing to static fields (_initialized, Config, _patchesApplied, _shutdownHookRegistered).

Changes:

  • Extracted initialization logic to new static method InitializeStatic(ModConfiguration? config)
  • OnEngineInit() now delegates immediately: InitializeStatic(GetConfiguration())
  • Improved null handling: validate config parameter before assignment instead of using null-forgiving operator followed by null check

Before:

public override void OnEngineInit()
{
    if (_initialized) return;
    Config = GetConfiguration()!;
    // ... writes to static fields throughout
}

After:

public override void OnEngineInit()
{
    InitializeStatic(GetConfiguration());
}

private static void InitializeStatic(ModConfiguration? config)
{
    if (_initialized) return;
    if (config == null) { Error("..."); return; }
    Config = config;
    // ... static field writes now in static context
}

Thread safety and initialization logic unchanged.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 23, 2025 03:41
Co-authored-by: nalathethird <36301692+nalathethird@users.noreply.github.com>
Co-authored-by: nalathethird <36301692+nalathethird@users.noreply.github.com>
Copilot AI changed the title [WIP] Update bHapticsManager architecture based on feedback Extract static initialization logic from instance method OnEngineInit Nov 23, 2025
Copilot AI requested a review from nalathethird November 23, 2025 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants