Skip to content
This repository was archived by the owner on Jan 31, 2026. It is now read-only.

Comments

Extract static initialization logic from instance method OnEngineInit#19

Closed
Copilot wants to merge 3 commits intobug/thread-not-startedfrom
copilot/sub-pr-8-148c5a22-d362-4585-8169-fc277b64d6db
Closed

Extract static initialization logic from instance method OnEngineInit#19
Copilot wants to merge 3 commits intobug/thread-not-startedfrom
copilot/sub-pr-8-148c5a22-d362-4585-8169-fc277b64d6db

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants