-
Notifications
You must be signed in to change notification settings - Fork 632
Add ObjectExtension system #5429
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
Conversation
| actorEntry = &play->setupActorList[0]; | ||
| for (i = 0; i < play->numSetupActors; i++) { | ||
| Actor_SpawnEntry(&play->actorCtx, actorEntry++, play); | ||
| Actor* spawnedActor = Actor_SpawnEntry(&play->actorCtx, actorEntry++, play); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if this line should be included in the #region, since it was changed and not added. Let me know what the policy is to do here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it really matters, but I think this is fine as is. If you removed the entire region, the code would function exactly as before the change, so I think in that sense the way it is now is correct. The compiler would warn us about the unused assignment afterwards anyway to clue us in that it also needs to be changed (assuming we see it in the sea of warnings lol.)
| return NULL; | ||
| } | ||
|
|
||
| // #region SOH [ObjectExtension] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this (and the line in Actor_Delete) should be hooks, but I wanted to keep the review focused on the new system. If this is merged, I intend to add those hooks and convert this code to use them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I didn't add a hook when I ported 2ship's ActorExtensions because 2ship itself wasn't using hooks for it so I kind of assumed that there was some technical reason why a hook was difficult to do there. If you've got a way to use a hook I say go nuts.
|
I don't see anything inherently wrong in the code, but I think I'd understand it better if there were an example of it in use. |
|
Well there is the ActorListIndex already that you can see in action currently on the Actor Viewer. |
The adds the ObjectExtension system, which allows you to attach extra data to pointers. This is a response to #5204 which I thought was too much of a deviation to be appropriate as a code review. It attempts to solve the same problem as ActorExtension -- adding new fields to structs while minimizing source code changes. The core differences are:
std::any. This allows it to know the type and be able to properly construct and deconstruct nontrivial objects. This also requiresGetandSetto be templated.ObjectExtension::Registerhelper that hides the implementation details of the system.Build Artifacts