feat(sdk): migrate to EventBus 2.0

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.
This commit is contained in:
2026-08-26 01:15:48 +08:00
parent 67d32795c4
commit ad5a7b68a3
129 changed files with 5071 additions and 5584 deletions
@@ -8,6 +8,16 @@ namespace ShrinkCommand.Integration
{
public static class ShrinkCommandEventBusBridge
{
[ShrinkEventSubscriber(OwnerId = "shrink.command", DefaultBus = "game")]
private sealed class CommandRequestSubscriber
{
[ShrinkSubscribe(Priority = ShrinkEventPriority.Lowest)]
private UniTask OnExecuteRequest(ShrinkCommandExecuteRequestEvent eventArgs)
{
return HandleExecuteRequestAsync(eventArgs);
}
}
private sealed class ServiceRegistration
{
public string ServiceName = ShrinkCommandConstants.DefaultServiceName;
@@ -20,7 +30,7 @@ namespace ShrinkCommand.Integration
private static readonly object SyncRoot = new();
private static readonly Dictionary<string, ServiceRegistration> RegisteredByName = new(StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary<ShrinkCommandService, ServiceRegistration> RegisteredByService = new();
private static bool _initialized;
private static IDisposable? _requestHandlerBinding;
[UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.SubsystemRegistration)]
private static void ResetStaticState()
@@ -37,7 +47,8 @@ namespace ShrinkCommand.Integration
RegisteredByService.Clear();
RegisteredByName.Clear();
_initialized = false;
_requestHandlerBinding?.Dispose();
_requestHandlerBinding = null;
}
}
@@ -113,17 +124,16 @@ namespace ShrinkCommand.Integration
Source = source
};
await EventBus.TriggerEventAsync(requestEvent);
await EventBus.PostAsync(requestEvent);
return requestEvent.ExecutionResult ?? ShrinkCommandExecutionResult.Failure("没有命令桥处理该请求。");
}
private static void EnsureInitialized()
{
if (_initialized)
if (_requestHandlerBinding != null)
return;
_initialized = true;
EventBus.RegisterEvent<ShrinkCommandExecuteRequestEvent>(HandleExecuteRequestAsync, EventPriority.LOWEST);
_requestHandlerBinding = EventBus.Attach(new CommandRequestSubscriber());
}
private static async UniTask HandleExecuteRequestAsync(ShrinkCommandExecuteRequestEvent eventArgs)
@@ -159,7 +169,7 @@ namespace ShrinkCommand.Integration
private static void PublishExecuting(ServiceRegistration registration, ShrinkCommandExecutingInfo info)
{
EventBus.TriggerEvent(new ShrinkCommandExecutingEvent
EventBus.Post(new ShrinkCommandExecutingEvent
{
ServiceName = registration.ServiceName,
RawInput = info.RawInput,
@@ -174,7 +184,7 @@ namespace ShrinkCommand.Integration
{
var commandPath = info.Command?.Path ?? string.Empty;
var arguments = new Dictionary<string, string>(info.Arguments, StringComparer.OrdinalIgnoreCase);
EventBus.TriggerEvent(new ShrinkCommandExecutedEvent
EventBus.Post(new ShrinkCommandExecutedEvent
{
ServiceName = registration.ServiceName,
RawInput = info.RawInput,
@@ -189,7 +199,7 @@ namespace ShrinkCommand.Integration
if (info.Result.IsSuccess)
return;
EventBus.TriggerEvent(new ShrinkCommandFailedEvent
EventBus.Post(new ShrinkCommandFailedEvent
{
ServiceName = registration.ServiceName,
RawInput = info.RawInput,