Skip to content

Refactor hook creation#85

Merged
Kasuromi merged 3 commits intoBepInEx:masterfrom
limoka:refactor-hooks
Apr 1, 2023
Merged

Refactor hook creation#85
Kasuromi merged 3 commits intoBepInEx:masterfrom
limoka:refactor-hooks

Conversation

@limoka
Copy link
Copy Markdown
Contributor

@limoka limoka commented Mar 31, 2023

This PR improves the way hooks are done. Now a hook is created by implementing Hook class. The only things that need to be defined are the hook delegate, hook method and find target method function.

This removes some boilerplate code, and splits hooks across files for more modularity.
No functional changes. Tested on Core Keeper 2021.3.14f

@Kasuromi Kasuromi merged commit d669532 into BepInEx:master Apr 1, 2023
@limoka limoka deleted the refactor-hooks branch April 1, 2023 13:43
Comment on lines +10 to +13
private bool isApplied;
private T detour;
internal T method;
internal T original;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wrong naming, fields should be private and begin with _ and _original should be exposed with something like

public T Original => _original;

js6pak added a commit that referenced this pull request Apr 1, 2023
@ds5678 ds5678 added this to the 1.4.6 milestone Jul 15, 2024
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.

4 participants