Added GM:OnDuplicated(ent, entDupeTable)#2408
Added GM:OnDuplicated(ent, entDupeTable)#2408Grocel wants to merge 1 commit intoFacepunch:masterfrom
Conversation
Works like `ENTITY:OnDuplicated(ent, entDupeTable)` but doesn't require adding/detouring `ent.OnDuplicated` on `OnEntityCreated` calls for addon-foreign entities.
In adjacent to: Facepunch/garrysmod#2408 Works like `ENTITY:OnDuplicated(ent, entDupeTable)` but doesn't require adding/detouring `ent.OnDuplicated` on `OnEntityCreated` calls for addon-foreign entities.
Removes the need for the "OnEntityCreated" hack. Requires these pull request to be merged: - Facepunch/garrysmod#2408 - wiremod/advdupe2#528
|
Would be very useful to have this hook coming from the perspective of a developer on ACF-3. We've wanted something like this for a while, iirc |
|
The name should be something more like PostDuplicatorPaste which is more consistent with the PostEntityPaste hook. |
Don't think it would reflect what it does. It is called in the beginning if the duplication process (even before ent:Spawn()), not the end of it. The name is being picked as an analog to of the entity's hook name. However what do you think of naming it |
|
Oh I thought you were adding a post paste hook, which gmod also needs. Nvm |
If this one gets of the ground, I can submit PRs adding those for both projects as well. |
|
My concern with this is cost of execution. This is already a problem for large dupes. A post-duplication hook would be a safer bet, even if it would be more annoying to work with to modify a single entity entry. |
Can we ensure that there is no misunderstanding between your and my idea? |
I think it would be worth actually profiling the cost vs a hypothetical before coming to this conclusion. |
Works like
ENTITY:OnDuplicated(ent, entDupeTable)but doesn't require adding/detouringent.OnDuplicatedonOnEntityCreatedcalls for addon-foreign entities.This adds a easy way to add generic logic early to the duplication life cycle. It is called a way before
duplicator.RegisterEntityModifier()added callers are being iterated. The new hook also reduces the risk of conflicts caused by detours of pre-existingent.OnDuplicatedcode.Test script: