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

Merge hook-docs branch #430

Open
wants to merge 31 commits into
base: dev
Choose a base branch
from
Open

Merge hook-docs branch #430

wants to merge 31 commits into from

Conversation

TwistedTail
Copy link
Member

Besides testing any possible issues we might have overlooked, this pull request is meant to be used as an announcement for this upcoming change.

  • If you happen to have an extension that relies on ACF hooks, you will be affected by these changes.
  • If you happen to have an extension that adds ACF hooks, you should consider using the same naming convention as us.

TLDR: Most, if not all, hooks were renamed to follow a strict naming convention: ACF_[Pre/On/Post][ACTION][ACTOR].

To go a little bit more in-depth, we want to make sure hooks remain consistent in both the way they're written and the way they're employed. All our hooks will use PascalCase for the capitalization and begin with the ACF_ prefix.

After that, you have to choose between Pre, On and Post for the moment in which this hook is being called. Pre implies the action hasn't happened yet, as such you should be able to stop it from happening with this hook. On means the action is about to happen, you shouldn't be able to stop it by now. Post means the action has already happened.

Following that, you need to add your ACTION, this needs to be a verb in present tense.

You end up with the ACTOR of the hook, this will be the thing affected by the action.

TwistedTail and others added 30 commits October 23, 2022 23:11
- Using the Hook library, all ACF hooks have been loaded onto the gamemode table.
- Replaced use of hook.Call with hook.Run
- Added serverside ACF_PlayerChangedZone and ACF_ProtectionModeChanged hooks to the gamemode table.
- Removed ACF_OnReceivedModelData and ACF_OnRequestedModelData hooks as they had pretty much no use outside of their niche.
- Renamed ModelData.QueueRefresh to ModelData.CallOnReceive for better understanding of what the function does.
- Added ModelData.RunCallbacks function.
- The hook has been renamed to ACF_OnRepositoryFetch
- Renamed ACF_AllowMenuOption to ACF_OnMenuOptionEnable.
- Renamed ACF_AllowMenuItem to ACF_OnMenuItemEnable.
- Both hooks will no longer receive the order index as the first argument as it served no use.
- All hooks used by ACF will have to follow the pattern: ACF_[Pre/On/Post][Action in present tense][Affected].
- Added clientside ACF_PreLoadClientSettings hook.
- Added clientside ACF_PreLoadServerSettings hook.
- Added clientside ACF_PostLoadClientSettings.
- Added ACF_PostLoadServerSettings hook.
- Renamed ACF_OnRepositoryFetch to ACF_OnFetchRepository.
- Renamed ACF_OnMenuOptionEnable to ACF_OnEnableMenuOption.
- Renamed ACF_OnMenuItemEnable to ACF_OnEnableMenuItem.
- Renamed ACF_OnClientSettingsLoaded to ACF_OnLoadClientSettings.
- Renamed ACF_OnServerSettingsLoaded to ACF_OnLoadServerSettings.
- Updated all existing menu creation hooks to the current naming convention standard.
- ACF.CreateAmmoMenu and ACF.UpdateAmmoMenu functions will no longer have a second argument for Settings, as the functionality of these has been replaced with hooks.
- Added clientside “ACF_OnCreateAmmoMenu” hook.
- Added clientside “ACF_PreCreateAmmoPreview” hook.
- Added clientside “ACF_PreCreateTracerControls” hook.
- Added clientside “ACF_OnCreateTracerControls” hook.
- Added clientside “ACF_PreCreateAmmoInformation” hook.
- Added clientside “ACF_PreCreateCrateInformation” hook.
- Renamed clientside “ACF_SetupAmmoMenuSettings” hook to “ACF_PreCreateAmmoMenu”.
- Renamed clientside “ACF_AddAmmoPreview” hook to “ACF_OnCreateAmmoPreview”.
- Renamed clientside “ACF_OnAmmoControlsCreate” hook to “ACF_OnCreateAmmoControls”.
- Renamed clientside “ACF_AddCrateDataTrackers” hook to “ACF_OnCreateCrateInformation”.
- Renamed clientside “ACF_AddAmmoInformation” hook to “ACF_OnCreateAmmoInformation”.
- Renamed ACF_BulletEffect hook to ACF_OnCreateBulletEffect.
- The hook will no longer receive the ammo type as the only argument, instead it'll receive the effect itself and the bullet data used by it.
- The hook will no longer have to return a function to override EFFECT.ApplyMovement, since it can now do it within itself.
- Renamed ACF_DrawBoxes hook to ACF_OnDrawBoxes.
- Renamed ACF_OnAddonLoaded hook to ACF_OnLoadAddon
- Renamed ACF_OnRequestedModelData to ACF_OnRequestModelData
- Renamed ACF_OnReceivedModelData to ACF_OnReceiveModelData
- ACF_OnNewGroup => ACF_OnCreateGroup
- ACF_OnNewGroupItem => ACF_OnCreateGroupItem
- ACF_OnNewItem => ACF_OnCreateItem
- ACF_OnClassLoaded => ACF_OnLoadClass
- ACF_OnServerDataUpdate => ACF_OnUpdateServerData
- ACF_OnClientDataUpdate => ACF_OnUpdateClientData
- ACF_OnClock => ACF_OnTick
- ACF_GetDisplayData => ACF_OnGetDisplayData
- ACF_UpdateRoundData => ACF_OnUpdateRound
- ACF_OnEntityResized => ACF_OnResizeEntity
- ACF_OnPlayerLoaded => ACF_OnLoadPlayer
- ACF_IsLegal => ACF_OnCheckLegal
- ACF_KEShove => ACF_OnPushEntity
Also added documentation for a few hooks that have been added in the meantime
- Changed some hooks explicitly comparing to boolean values despite they now have an explicit default value if unused/none given.
@thecraftianman
Copy link
Member

Closes #159

--- @param Data table A table with all the information required for the entity to set itself up.
--- @return boolean # True if the entity can be spawned, false otherwise.
--- @return string # A short explanation on why the entity can't be spawned. Not required if the entity is spawned.
function Gamemode:ACF_CanCreateEntity()
Copy link
Member

Choose a reason for hiding this comment

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

Is ACF_CanCreateEntity/ACF_CanUpdateEntity having the word Can at the front but everything else having it in the middle of the phrase intentional or just an oversight?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's an oversight, probably from the time I was trying to copycat Gmod hook names.

--- @param Class string The entity class that's being verified.
--- @param Data table The table of entity information that's being verified.
--- @param ... any One or many tables or objects that are related to the entity, these will vary on every class.
function Gamemode:ACF_VerifyData()
Copy link
Member

Choose a reason for hiding this comment

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

Should this be changed to ACF_OnVerifyData?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah.

--- @param Player entity The affected player.
--- @param Zone? string | nil The zone which the player moved into, could be nil.
--- @param OldZone? string | nil The zone which the player moved from, could be nil.
function Gamemode:ACF_PlayerChangedZone()
Copy link
Member

Choose a reason for hiding this comment

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

Do ACF_PlayerChangedZone and ACF_ProtectionModeChanged fit the naming standard? They seem kinda out of place.

Copy link
Member Author

Choose a reason for hiding this comment

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

They don't.

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