space-station-14 icon indicating copy to clipboard operation
space-station-14 copied to clipboard

Ghost Role Lottery + UI Tweaks

Open TekuNut opened this issue 2 years ago • 6 comments

About the PR

Changes ghost roles to pick players randomly instead of being first-requester. Roles have individual timers that trigger the lottery once elapsed (all roles currently get 30 seconds). If the timer elapses and nobody selects the role, the role entry will remain.

The entries have been condensed to having a single row of buttons per role. Request will change to "Cancel" and vice-versa, and Follow cycles through the available entities.

The Ghost Roles button itself will now remove highlighting once clicked. The first addition of a role causes the button to be highlighted again. Subsequent additions of the same role will not until the entry is removed.

Requires https://github.com/space-wizards/RobustToolbox/pull/3130

#9477 and #8928 are related issues.

TODO

  • [x] Use a single timer for all lottery roles.
  • [x] Allow roles to opt out of lottery. Make mouse and PAI opt out.
  • [x] Add role grouping, allowing admins to put down multiple ghost roles and have them show as an event entry in the ghost roles.
  • [ ] (Optional) Add priority support for role lotteries. May not be needed yet with lottery opt out.

Screenshots

ghost-role-lottery.webm

Changelog

:cl:

  • tweak: Ghost roles are given to requesting players via lottery.
  • tweak: Ghost roles button highlights to indicate new roles are available.

TekuNut avatar Aug 01 '22 01:08 TekuNut

that ui looks clean af. The one thing i wonder is if this applies to all ghost roles or if it is only for some. I could see this as a problem for things like mouse ghost roles grabbing up all ghosts.

EmoGarbage404 avatar Aug 01 '22 01:08 EmoGarbage404

That's a good point. The need for priority among roles would probably necessitate that a single timer is used for all roles(at least I can't see how you can have priority if the mouse roles elapsed before everything else).

I'm thinking:

  • Have a single timer for roles lottery (farewell progress bar dividers).
  • Ghost role additions are deferred to the next lottery period to prevent additions towards the end being sniped + annoying UI reshuffling when someone is about to click.
  • (Maybe) Sort roles by priority, putting more important towards the top.
  • (Maybe) Show which roles are being added in the next lottery? I'm not sure if this is beneficial (or maybe even counter-productive).

I'm also think of changing the Role Button highlighting, by adding a per-role toggle for if the player wants to know if that role is ever present in the ghost role entries (for now, just a button per entry).

Thoughts?

TekuNut avatar Aug 01 '22 01:08 TekuNut

https://discord.com/channels/310555209753690112/310555209753690112/1003484090625953792

  • Certain roles shouldn't be part of a lottery by default.
  • Need for admins to be able to spawn entities as part of a group for events. This should show up as a single entry in the ghost roles that players can sign up for.

TekuNut avatar Aug 01 '22 08:08 TekuNut

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

github-actions[bot] avatar Aug 02 '22 19:08 github-actions[bot]

ghost-role-role-groups.webm

Added an initial version for role groups. For how it works:

  • Admins can start any number of role groups. They can have 1 active role at any time.
  • Entities placed down that fulfil certain criteria are automatically added to the active role group. Currently this is just having a GhostRoleTakeoverAvailableComponent as part of the prototype.
  • Debug verbs can be used for adding any other entities to the active role group.
  • Admins can not edit other admins role groups. (Operations on entities still work, such as delete. They just can't attach to their own role group if it is already part of yours).
  • Deleting a role group will be default not delete entities. There is a checkbox to also perform the deletion on all entities in the role group. (Entities controlled by player's should be excluded).
  • Role groups are "released" into the lottery. Once this happens, entities should no longer be able to be attached/detached to the role group.
  • Once a role group is released, once all entities are used (or prematurely killed/deleted), the role group will be deleted.

Some other changes:

  • Lotteries run on a single timer. This was done to simplify the logic and permit future enhancements such as player priorities.
  • Certain entity types (namely mouse and PAI) are not lottery-able. Instead they will continue to be first-come first-served. This is shown in the UI as the "Take" button instead of "Request".
  • Added a CVar for the global lottery timer. Changes to this get reflected in the next lottery.

TekuNut avatar Aug 14 '22 01:08 TekuNut

Question time:

  • ~~GhostRoleSystem + GhostRoleGroupSystem have a circular dependency with GhostRoleLotterySystem. To resolve this, I opted to use events (specifically, what I later found out to be Method Events) and had GhostRoleLotterySystem as dependencies in ther other two. Should I do this another way (and what would be preferred).~~ Went with direct method calls + events
  • ~~Entities are shown as unknown when freshly placed, since the ghost role groups send the EntityUid's back to the client, and attempts to query the client-side entity manager for the names to display immediately on receiving the EUI state. Is there any places I can look at to see how this is resolved? (Worst case, I'll simply get the string name on the server side while building the state message).~~ Opted to send the name along with the EntityUid.

TekuNut avatar Aug 14 '22 02:08 TekuNut

the ghost role group stuff is very neat but IMO the placement part of it is really jank just looking at it and I feel like it's better for admins to just have to add them to groups manually. that, or change the 'activate ghost role placement' to instead hook into clicking on entities, so any clicked-on already spawned entities are just added to the group instead of having to hook into placement

mirrorcult avatar Aug 31 '22 12:08 mirrorcult

will try and take a look at the rest later

mirrorcult avatar Aug 31 '22 12:08 mirrorcult

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

github-actions[bot] avatar Sep 05 '22 14:09 github-actions[bot]

This is gonna be very hard to recover without a lot of effort, I tried forking it and merging upstream to it... god there's so many conflicts, and out of date stuff. To be expected though!

QuietlyWhisper avatar Apr 17 '23 14:04 QuietlyWhisper