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

Appearance Weakrefs #1815

Merged
merged 95 commits into from
Jan 5, 2025
Merged

Conversation

amylizzle
Copy link
Collaborator

@amylizzle amylizzle commented May 28, 2024

Fairly substantial rewrite of appearance handling.

There are now two appearance classes: MutableIconAppearance and ImmutableIconAppearance

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 use AtomManager.SetAppearance() or if you have a really really good reason use ServerAppearanceSystem.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 a MutableIconAppearance). These are held only as weakrefs in the ServerAppearanceSystem, 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 use ToMutable() to edit them locally for animations and such.

Appearance ID is now stored on the ImmutableIconAppearance and generated by the ServerAppearanceSystem

KNOWN BUG: /turf animations don't apply, it just sets the final state of the turf appearance. Turf animations can go in another PR.

@boring-cyborg boring-cyborg bot added Client Involves the OpenDream client Runtime Involves the OpenDream server/runtime labels May 28, 2024
@amylizzle amylizzle marked this pull request as ready for review May 29, 2024 12:31
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link

github-actions bot commented Dec 4, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

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

Convert into primary constructor
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

Convert into primary constructor
@@ -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

Using directive is not required by the code and can be safely removed
@wixoaGit wixoaGit enabled auto-merge (squash) January 5, 2025 00:52
@wixoaGit wixoaGit merged commit 2033c66 into OpenDreamProject:master Jan 5, 2025
7 checks passed
@amylizzle amylizzle deleted the appearanceRefCounts branch January 5, 2025 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client Involves the OpenDream client Compiler Involves the OpenDream compiler Runtime Involves the OpenDream server/runtime size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants