Add `SharedOnlyEventAttribute` and analyzer
Adds an attribute that can be applied to event structs/classes to indicate that they should only be subscribed to in Shared code. Subscriptions to the event in Server-only code will raise a warning.
Applying the attribute to GetVerbsEvent:
Warning on a server-only subscription:
The attribute also has an optional parameter, AllowClientOnly which defaults to true. If true, subscriptions are also allowed in Client-only code. In most potential use cases (verbs, examines), Client-only subscriptions are fine.
This feature was requested by @slarticodefast to help enforce https://github.com/space-wizards/space-station-14/issues/39286 - subscribing to GetVerbsEvent in server-only code causes the verbs menu to jump around, because it is first populated client-side with Client and Shared verbs, then gets rebuilt when the server sends its version containing new entries. This is a major annoyance for players, and has caused problems where admins accidentally trigger actions on players while trying to use examining verbs on them.
Good freakin shit man!
This engine clearly needs more cool analyzers. Awesome.
Would it not make more sense to have an attribute that worked with bitflags? Like
[NetworkSideOnly(Shared | Client)]?
Yeah, I was thinking that too. Figured I'd do it this way first and upgrade to that if desired. I'll get on it.