Skip to content

Lookup compiler-generated objects dynamically#98

Merged
miniduikboot merged 6 commits into
NuclearPowered:masterfrom
XtraCube:master-2
Jun 9, 2026
Merged

Lookup compiler-generated objects dynamically#98
miniduikboot merged 6 commits into
NuclearPowered:masterfrom
XtraCube:master-2

Conversation

@XtraCube

Copy link
Copy Markdown
Contributor

Reactor currently patches a few state machines generated by the C# compiler. This is generally okay but with updates to the game, the names of the compiler generated classes can change. Additionally, these names are not consistent across platforms.

By dynamically resolving these objects at runtime, Reactor will be more resilient to game updates and platform differences, allowing for a single build to be used across multiple platforms.

This PR adds two new utility classes:

  • CompilerGeneratedObjectWrapper: This class provides a wrapper around a compiler generated object. It provides two functions, GetField and SetField, to get and set fields on objects via reflection.
  • StateMachineWrapper<T>: This class inherits from CompilerGeneratedObjectWrapper to add state machine specific utilities.

These classes can be used by other mods that depend on Reactor as well.

@XtraCube

Copy link
Copy Markdown
Contributor Author

I'm fixing a couple bugs with this PR, I'll request a review when it is ready

@XtraCube

Copy link
Copy Markdown
Contributor Author

Okay I think it is ready for review

@XtraCube XtraCube marked this pull request as ready for review January 15, 2026 21:57
@XtraCube XtraCube closed this Jan 16, 2026
@XtraCube XtraCube deleted the master-2 branch January 16, 2026 00:13
@XtraCube

Copy link
Copy Markdown
Contributor Author

OK that was unintentional, lemme remake the PR

@XtraCube XtraCube restored the master-2 branch January 16, 2026 00:14
@XtraCube XtraCube reopened this Jan 16, 2026
@XtraCube

Copy link
Copy Markdown
Contributor Author

@js6pak mentioned we may want to avoid dynamic invokes and use a delegate or something. I'll look into that when I'm free.

@miniduikboot miniduikboot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I can't merge as is due to the compiler warnings

Comment thread Reactor/Utilities/Il2CppCompilerGeneratedObjectWrapper.cs
Comment thread Reactor/Utilities/Il2CppStateMachineWrapper.cs
@XtraCube

XtraCube commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

All warnings should be resolved now

@miniduikboot miniduikboot merged commit 16c8c3e into NuclearPowered:master Jun 9, 2026
1 check passed
@miniduikboot

Copy link
Copy Markdown
Collaborator

thanks!

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