-
Notifications
You must be signed in to change notification settings - Fork 125
Appearance Weakrefs #1815
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
Appearance Weakrefs #1815
Conversation
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Along with related memory optimizations. Saves >1GB of allocations on Paradise init.
| public override MsgGroups MsgGroup => MsgGroups.EntityEvent; | ||
|
|
||
| public MsgNewAppearance() : this(new ImmutableAppearance(MutableAppearance.Default, null)) {} | ||
| public MsgNewAppearance(ImmutableAppearance appearance) => Appearance = appearance; |
Check notice
Code scanning / InspectCode
Convert constructor into primary constructor Note
| public readonly uint? AppearanceId; | ||
| public readonly ScreenLocation ScreenLocation; | ||
|
|
||
| public DMISpriteComponentState(uint? appearanceId, ScreenLocation screenLocation) { |
Check notice
Code scanning / InspectCode
Convert constructor into primary constructor Note
Fairly substantial rewrite of appearance handling.
There are now two appearance classes:
MutableIconAppearanceandImmutableIconAppearanceMutableIconAppearanceis the class you use for mutable appearance stuff. They are not sent to the client. To send them to the client, you must either useAtomManager.SetAppearance()or if you have a really really good reason useServerAppearanceSystem.AddAppearance().ImmutableIconAppearanceis the class that is sent to the client. It cannot be edited. If you want to edit it, you need to create a mutable copy (which is aMutableIconAppearance). These are held only as weakrefs in theServerAppearanceSystem, and are removed from connected clients when they are garbage collected. This means that if you want to keep it alive you must have a hard ref to it somewhere. Any appearance (mutable or no) which has an overlay/underlay counts as a hard ref for that overlay/underlay.The client has copies of the
ImmutableIconAppearanceand can useToMutable()to edit them locally for animations and such.Appearance ID is now stored on the
ImmutableIconAppearanceand generated by theServerAppearanceSystemKNOWN BUG: /turf animations don't apply, it just sets the final state of the turf appearance. Turf animations can go in another PR.