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
@@ -23,7 +23,7 @@ internal static class ShrinkNetworkSemanticScanner
private const string MessageInterfaceName = "ShrinkNetwork.IShrinkNetworkMessage";
private const string RequestInterfaceName = "ShrinkNetwork.IShrinkNetworkRequest";
private const string ResponseBaseName = "ShrinkNetwork.ShrinkRpcResponseBase";
private const string HasResultAttributeName = "ShrinkEventBus.HasResultAttribute";
private const string ResultEventInterfaceName = "ShrinkEventBus.IShrinkResultEvent`1";
private const string NetworkEventAttributeName = "ShrinkNetwork.Integration.EventBus.ShrinkNetworkEventAttribute";
private const string DeltaEventInterfaceName = "ShrinkNetwork.Integration.EventBus.IShrinkNetworkDeltaEvent";
@@ -136,7 +136,7 @@ internal static class ShrinkNetworkSemanticScanner
Opcode = opcode,
Route = route.Trim(),
SourcePath = GetSourceName(type),
HasResult = HasAttribute(type, HasResultAttributeName),
HasResult = ImplementsOpenGeneric(type, ResultEventInterfaceName),
IsNetworkEvent = HasAttribute(type, NetworkEventAttributeName),
IsDeltaEvent = Implements(type, DeltaEventInterfaceName),
SyncGroup = GetConstructorString(stateSync, 0),
@@ -314,6 +314,14 @@ internal static class ShrinkNetworkSemanticScanner
return type.GetInterfaces().Any(item => string.Equals(item.FullName, interfaceFullName, StringComparison.Ordinal));
}
private static bool ImplementsOpenGeneric(Type type, string interfaceFullName)
{
return type.GetInterfaces().Any(item =>
item.IsGenericType &&
string.Equals(item.GetGenericTypeDefinition().FullName, interfaceFullName,
StringComparison.Ordinal));
}
private static bool Inherits(Type type, string baseTypeFullName)
{
for (var current = type.BaseType; current != null; current = current.BaseType)
+1 -1
View File
@@ -297,7 +297,7 @@ new ShrinkMessagePackNetworkSerializer()
## ⚠️ 注意事项
- `BindTransport(...)` 只负责绑定传输与启动监听,不会替你注册业务 handler
- `TriggerEvent` 类桥接若依赖可选程序集,当前通过运行时反射自动接入;未安装扩展包时会静默跳过
- EventBus 桥接统一使用 `Post/PostAsync` 和编译期生成注册;未安装 `ShrinkNetwork.Integration.EventBus` 时不会建立桥接,也不会做运行时程序集扫描
- `GeneratedServers/*/Generated/` 中的产物允许重建,不要把人工业务逻辑直接写进自动生成文件;模板托管区虽有哈希保护,也应通过独立业务文件扩展
- 运行依赖中的 `Kcp-CSharp.dll``System.Runtime.CompilerServices.Unsafe.dll` 需要与 Unity 平台兼容