Skip to content

[BUG] Mono NPC wrappers spam warning for removed RequiresRegionUnlocked field #272

Description

@ifBars

Summary

Creating any custom S1API.Entities.NPC on the Mono beta emits one Harmony warning per wrapper instance:

[WARNING] AccessTools.Field: Could not find field for type ScheduleOne.NPCs.NPC and name RequiresRegionUnlocked

Environment

  • S1API: 3.1.15 (S1API.dll)
  • Game: 0.4.6f12 Alternate
  • Runtime: MonoBleedingEdge x64
  • MelonLoader: 0.7.1

Reproduction

  1. Define and register one or more physical custom NPCs derived from S1API.Entities.NPC.
  2. Load a save and allow S1API to construct the wrappers.
  3. Observe one warning for every NPC wrapper constructed.

The warning originates from the instance field initializer in Entities/NPC.cs:

private readonly FieldInfo _requiresRegionUnlockedField =
    AccessTools.Field(typeof(S1NPCs.NPC), "RequiresRegionUnlocked");

The current Mono ScheduleOne.NPCs.NPC type no longer exposes that field. Harmony logs whenever AccessTools.Field misses, so even mods that never use RequiresRegionUnlocked receive repeated warnings.

Suggested compatibility fix

Resolve the optional member without warning (plain reflection or the existing tolerant field/property helper), cache it once per runtime type, and keep the property as a safe fallback/no-op when unavailable. This should remain a separate S1API compatibility fix; downstream mods cannot prevent the initializer warning.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    LowVery minor issue, non gameplay hindering, fix all high prio firstbugSomething isn't workingnpcsNative game NPC system

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions