-
Notifications
You must be signed in to change notification settings - Fork 75
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
ShipInit & Conditional Hooks #820
base: develop
Are you sure you want to change the base?
ShipInit & Conditional Hooks #820
Conversation
I don't think this is a good idea, it works due to "magic" (you just need to know that declaring a static |
I will agree with this point. I usually tend to have an aversion to magic like this, but feel it outweighs the current alternative (the big register blocks)
If you're referring to If you are referring to the Conditional hooks pattern, my goal will be to slowly move all hook usage to this pattern regardless of this PR, because we don't want code (especially expensive code) running when the user hasn't even opted into a given option. The primary reason it's not already enforced is because it's tedious to write the code for it (see the |
It might also be worth calling out, I'll add to the description, but here I also began using macros for cvar names and cvarGets, none of this is necessary for this PR or the new systems, just a pattern I've begun using because it's more copy/paste friendly (for people copying hooks or something from one file to another)
|
Ok so I think my thoughts on this are: ShipInitPros
Cons
Hook MacrosPros
Cons
Overall I think this is a good step forward for general dev experience. There is the slight tradeoff with discoverability, but I don't feel like things were really "discoverable" before hand, so it is more like a sideways shift in that regards. Documentation and example patterns will be key regardless. |
fa19df8
to
3c45c9f
Compare
9d20270
to
80694e7
Compare
80694e7
to
11340f1
Compare
Alright the majority of the enhancements have been migrated, only the saving/cycle stuff remaining |
ShipInit
This axes our need to have these big register funcs/headers everywhere for our modules that just need to be initialized on startup, along with an added benefit: When you register your InitFunc you can specific N paths (strings) associated with that function, and then at any time you can re-invoke initFuncs associated with that path.
Most people won't need to manually call these InitFuncs anywhere, because it's now built right into our UIWidgets! Any time any CVar associated UIWidget is changed, we invoke all InitFuncs associated with that cvar string. This works extremely well with our next addition:
Conditional Hooks
These are already in use in Anchor, Let it Snow & Dice. They are shortcuts for the common pattern of unregistered your hook and re-registering it based on a condition. This is an important optimization for expensive hooks, but should basically be used for 90% of cases going forward.
This PR converts masks & minigames so far, will do the rest if we agree this is a good pattern.
Additionally, I began using a macro pattern for CVar names and gets, simply to reduce the friction when copy/pasting code from one enhancement file to another. This is entirely separate from the systems above and not a requirement of them. Can easily undo these if people don't like them.
Build Artifacts