Namespace Shard.Modding.SDK.Event
Interfaces
- ICancellableEvent
An event whose default action a subscriber can veto by setting Cancelled. Once cancelled, later subscribers are skipped unless they opted in with
receiveCancelled: true. Implement this on a class (not a struct) so the flag mutation is seen by every subscriber.
- IEventBus
Publish/subscribe surface for server events. A module subscribes through its IModuleContext.Events so the subscription is scoped to the module and torn down automatically when the module shuts down.
Subscribers run in EventPriority order. A cancelled ICancellableEvent skips later subscribers unless they subscribed with
receiveCancelled: true. Handlers may be synchronous (Subscribe<TEvent>(Action<TEvent>, EventPriority, bool)) or asynchronous (SubscribeAsync<TEvent>(Func<TEvent, ValueTask>, EventPriority, bool)); use PublishAsync<TEvent>(TEvent) to await asynchronous handlers without blocking the publisher.Event convention: a plain type named
SomethingEvent— arecord structfor lightweight, non-cancellable notifications; aclassimplementing ICancellableEvent when cancellable.
Enums
- EventPriority
Order in which subscribers run for an event: Lowest first … Highest last, then Monitor. Earlier handlers shape the outcome (e.g. cancel a ICancellableEvent); Monitor handlers observe the final decision and must not modify the event.