Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflection based Hero field/property fix #3

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Aragas
Copy link
Contributor

@Aragas Aragas commented Jul 2, 2021

Without delegates, will require Harmony.Extension package, keeping it simple
Fixes #2

Without delegates, will require Harmony.Extension package, keeping it simple

private delegate TextObject GetHeroNamePropertyDelegate(Hero instance);
private static readonly MethodInfo? GetHeroNameProperty = AccessTools.PropertyGetter(typeof(Hero), nameof(Hero.Name));
private static readonly AccessTools.FieldRef<Hero, TextObject>? GetHeroNameField = AccessTools.FieldRefAccess<Hero, TextObject>("Hero");
Copy link
Owner

@zijistark zijistark Jul 2, 2021

Choose a reason for hiding this comment

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

I think the string that would need to be passed into AccessTools.FieldRefAccess<,> is the name of the field (Name), not the class as it is here (Hero).

AccessTools.FieldRefAccess<T, F>(string) Documentation

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.

I have crash beta 1.6.0
2 participants