Repository navigation
Allow players to control variants they have edit access to - #1737
Conversation
…-variant-switching
Kruptein
left a comment
There was a problem hiding this comment.
On this PR
Thanks for taking a look at the variants.
I have two super minor remarks on the code itself, I do have some more general remarks/ramblings on the entire concept of variants below.
Feel free to give some input on it, but in the super short term I'm probably fine with just merging these changes to fix the open standing issues.
One last thing related to the PR I wanted to ask is how you decided which getShape calls to modify. Did you go through all ~140 or was it mostly a case of doing a bunch of interactions with a variant and see where it broke?
Ramblings on variants
While I like the concept of variants, the actual implementation always causes a lot of headaches. They are a pretty niche feature, but as you've noticed let their presence know throughout the entire codebase and have historically been the source of many a bug.
I'm somewhat tempted to actually get rid of the entire current implementation. While it's neat in theory that every variant is its own proper shape and thus can be completely tuned independently, I'm not sure if it's actually worth all the extra load on the codebase itself. How useful is it really to have the special common/separate tracker/auras setup for example.
A much simpler implementation could just eliminate the bookkeeping of a control shape with all these separate shapes, with just having a new property on regular shapes that maps names to an asset + some size info.
The main drawback is that over time people might request small extra things that differentiate variants on top of a name+asset+size, and while 1 or 2 extra properties could be managed, this can quickly just become a problem where having them be separate shapes would just be cleaner.
I do however think that the ultimate core of what variants stand for is simply being able to dynamically swap the asset. The main issue is that it's hard for me to verify if this sentiment is shared by the users. The nature in how PA is used, makes it so that I have very little info on how people use it. A while back I disabled variants in a release because I was under the impression they were actually not really used and had a lot of bugs. But then to my surprise suddenly people did ask why they couldn't see them anymore.
If we do however want to continue with the existing more complicated setup, we might want to codify it better which shapes are stored in the selection data or in the access data for example. With your changes we're grabbing the visual or base shape depending on context, but it's up to the developer to actively think about doing the proper calls. It might be interesting to have the selection always be exclusively BaseShapeId's or VisualShapeId's for example. Basically creating two new Ids to ensure that throughout the code we know if we need to convert or not, adding some extra safety.
I went through each call and tried to determine if that callsite wanted the current shape, visual, or base shape.
I've also noticed a lot of references to toggle comoposites throughout the code. It has gotten a quite entangled into all sorts of places and makes maintanence and in my case initial reading a tougher job.
My use case and my players' use case is just to swap between assets and size for things like wildshape. Having to mark trackers as 'shared by all' has actually been an issue, where we forget to do it and wonder where the tracker went. I'm of the opinion that most aspects of variants should be shared, with just asset and size differing, maybe name too. I didn't want to do an overhaul of the variant concept just to fix an issue, but personally would prefer for that simpler implementation in the long run.
I could work toward that. But now you've got me thinking of the simplified version as potentially better in the long term. It'd be nice to be able to get community opinions on that. I think we all need to decide what a variant is supposed to be. Is it supposed to allow full independent shapes? That's never how I interpretted it until I saw how it was implemented. |
Oh yeah I didn't expect you too either :D I'm glad to see that your own vision seems to align with mine. The more I think on it, the more I'm convinced that removing it will just be better in all cases. I'll add it as an open-for-input question in the release notes for the upcoming release and unless I get some convincing uses I'll rework it. |
Is it better that I hold off on this for the time being? If the variant implementation might change, then this would be extra work now that would need undone later anyway. Once variant behavior is decided, I can go through and do this if we're still on the current implementation. Unless you want it done now. Also, if you would rather wait until after the next release so you can review the arguments for current variant implementation, then you can just keep this PR open or I can convert it to a draft until then. That way calls scattered throughout the code for |
|
I think we can go ahead with these changes for now, they do fix some aspects around the variants, so it will still provide value for the upcoming release. It's also not too difficult to remove afterwards either, it's essentially just replacing them with getShape again. |
This PR has ToggleComposites (the parent shape of variants) determine the permissions of its children (the variants). This solves a couple of issues:
The majority of lines changes are swapping out
getShapecalls with eithergetBaseShapeorgetVisualShapecalls. Many times when operating on a shape, one actually wants to operate on the drawn shape rather than the parent (eg in cases of rendering), or when one wants to operate on the base shape rather than one of the variants (eg in cases of access checks). Essentially converting this or the opposite into a single function callThis fixes #1522 which describes the issue of players being unable to change the variant of a shape they have ownership of. This had to do with the way permissions were checked by the client.
This also fixes #1729, which was caused by the PropertiesSystem not receiving any information during creation of the ToggleComposite shape. This was a prerequisite to make this change work of course, but since it worked on the same concept of cleaning up ToggleComposites, I included it here. I can remove this fix and submit it as a separate PR if so desired.
Known issues: Changing variants technically requires movement access as well as edit access. This is due to the new variant having to change position to where the previously active variant was. I've always given movement access to anyone with edit access anyway so it doesn't seem like a big issue to me, but it can cause warnings in the server logs. As far as I can tell though, the new variant always successfully appears where the old variant was even when the player doesn't have movement access.