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.
34 lines
1012 B
C#
34 lines
1012 B
C#
#nullable enable
|
|
using System;
|
|
using Cysharp.Threading.Tasks;
|
|
using ShrinkContext;
|
|
using ShrinkEventBus;
|
|
|
|
namespace ShrinkContext.EventBusAdapter
|
|
{
|
|
/// <summary>
|
|
/// 把生成的 ShrinkEventBus 绑定包装为可逆效应。
|
|
/// </summary>
|
|
public static class ShrinkEventBusEffects
|
|
{
|
|
/// <summary>
|
|
/// 激活生成的 [ShrinkSubscribe] 绑定,并在 Context 回滚时统一释放。
|
|
/// </summary>
|
|
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));
|
|
|
|
var binding = EventBus.Attach(target, defaultBus);
|
|
return ctx.EffectInverse(() =>
|
|
{
|
|
binding.Dispose();
|
|
return UniTask.CompletedTask;
|
|
});
|
|
}
|
|
}
|
|
}
|