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
@@ -7,48 +7,25 @@ using ShrinkEventBus;
namespace ShrinkContext.EventBusAdapter
{
/// <summary>
/// 把 ShrinkEventBus 的订阅/注册包装为可逆效应
/// <c>IShrinkEventSubscription.Dispose</c> 天然就是订阅的逆操作——
/// 组件在 apply 里订阅,停用时随上下文自动退订,无需手写卸载路径。
/// 把生成的 ShrinkEventBus 绑定包装为可逆效应
/// </summary>
public static class ShrinkEventBusEffects
{
/// <summary>订阅事件即效应:ctx 卸载或手动 Dispose 句柄时自动退订。</summary>
public static ShrinkEffectHandle EffectSubscribe<TEvent>(
this ShrinkCtx ctx,
Action<TEvent> handler,
EventPriority priority = EventPriority.NORMAL,
bool receiveCanceled = false)
where TEvent : EventBase
{
if (ctx == null)
throw new ArgumentNullException(nameof(ctx));
if (handler == null)
throw new ArgumentNullException(nameof(handler));
var subscription = EventBus.SubscribeEvent(handler, priority, receiveCanceled);
return ctx.EffectInverse(() =>
{
subscription.Dispose();
return UniTask.CompletedTask;
});
}
/// <summary>
/// 实例对象整体注册即效应:扫描对象上的 [EventSubscribe] 方法(含未织入的非 MonoBehaviour 类),
/// 逆操作为 Unregister。
/// 激活生成的 [ShrinkSubscribe] 绑定,并在 Context 回滚时统一释放。
/// </summary>
public static ShrinkEffectHandle EffectRegister(this ShrinkCtx ctx, object target)
public static ShrinkEffectHandle EffectAttach(this ShrinkCtx ctx, object target,
ShrinkBusKey? defaultBus = null)
{
if (ctx == null)
throw new ArgumentNullException(nameof(ctx));
if (target == null)
throw new ArgumentNullException(nameof(target));
EventBus.Register(target);
var binding = EventBus.Attach(target, defaultBus);
return ctx.EffectInverse(() =>
{
EventBus.Unregister(target);
binding.Dispose();
return UniTask.CompletedTask;
});
}