Skip to content

feat: add generic singleton Instance pattern for CustomItem and CustomRole#775

Open
MS-crew wants to merge 1 commit intoExMod-Team:devfrom
MS-crew:instance-for-customs
Open

feat: add generic singleton Instance pattern for CustomItem and CustomRole#775
MS-crew wants to merge 1 commit intoExMod-Team:devfrom
MS-crew:instance-for-customs

Conversation

@MS-crew
Copy link

@MS-crew MS-crew commented Mar 9, 2026

Description

Describe the changes
Adds CustomItem, CustomRole and typed wrappers for all subclasses (CustomWeapon, CustomKeycard, CustomArmor, CustomGrenade, CustomGoggles). Instead of fetching instances via Get(id) or Get(name) which are fragile since ids and names can change at any time with configs, other plugins can now reference a custom item or role directly via example MyCustomGoggles.Instance or MyCustomRole.Instance, getting full strongly typed access to all properties and methods without any casting. This makes cross plugin integrations simpler, less error prone, and more accessible to developers who aren't deeply familiar with the codebase.

What is the current behavior? (You can also link to an open issue here)

What is the new behavior? (if this is a feature change)

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
No

Other information:
Example usage
image

on another plugin via referance or another class

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentations

Submission checklist

  • I have checked the project can be compiled
  • I have tested my changes and it worked as expected

Patches (if there are any changes related to Harmony patches)

  • I have checked no IL patching errors in the console

Other

  • Still requires more testing

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant