Replace the legacy EventBase runtime with generated multi-bus bindings and explicit scheduling. Migrate app, data, network, demo, and mod consumers; add generated network-event registration and owner-scoped mod content overrides.
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
#nullable enable
|
|
|
|
using System;
|
|
|
|
namespace ShrinkEventBus
|
|
{
|
|
public sealed class ShrinkEventBusBuilder
|
|
{
|
|
internal ShrinkBusKey Key { get; private set; } = ShrinkBusKey.Game;
|
|
internal ShrinkBusOptions Options { get; private set; } = ShrinkBusOptions.Inline();
|
|
internal Action<IShrinkEvent, Type, ShrinkBusKey>? PostObserver { get; private set; }
|
|
|
|
public ShrinkEventBusBuilder WithKey(ShrinkBusKey key)
|
|
{
|
|
Key = key;
|
|
return this;
|
|
}
|
|
|
|
public ShrinkEventBusBuilder WithOptions(ShrinkBusOptions options)
|
|
{
|
|
Options = (options ?? throw new ArgumentNullException(nameof(options))).CloneValidated();
|
|
return this;
|
|
}
|
|
|
|
public IShrinkEventBus Build() => Options.Scheduler == ShrinkBusSchedulerKind.Inline
|
|
? new ShrinkInlineEventBusInstance(this)
|
|
: new ShrinkEventBusInstance(this);
|
|
|
|
internal ShrinkEventBusBuilder WithPostObserver(
|
|
Action<IShrinkEvent, Type, ShrinkBusKey> observer)
|
|
{
|
|
PostObserver = observer ?? throw new ArgumentNullException(nameof(observer));
|
|
return this;
|
|
}
|
|
}
|
|
}
|