-
Notifications
You must be signed in to change notification settings - Fork 114
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
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
@@ -1,6 +1,7 @@ | |||
using OpenDreamRuntime.Objects; | |||
using OpenDreamRuntime.Procs; | |||
using OpenDreamRuntime.Procs.DebugAdapter; | |||
using OpenDreamRuntime.Rendering; |
Check warning
Code scanning / InspectCode
Redundant using directive Warning
Fairly substantial rewrite of appearance handling.
There are now two appearance classes:
MutableIconAppearance
andImmutableIconAppearance
MutableIconAppearance
is 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()
.ImmutableIconAppearance
is 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
ImmutableIconAppearance
and can useToMutable()
to edit them locally for animations and such.Appearance ID is now stored on the
ImmutableIconAppearance
and generated by theServerAppearanceSystem
KNOWN BUG: /turf animations don't apply, it just sets the final state of the turf appearance. Turf animations can go in another PR.