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:
@@ -279,25 +279,25 @@ if (meta.IsEncrypted)
|
||||
|
||||
> 详细文档见 [ShrinkDataSaver.Integration.EventBus](https://github.com/cneicy/ShrinkDataSaver.Integration.EventBus)
|
||||
|
||||
项目中同时包含 `ShrinkDataSaver.Integration.EventBus` 时,桥接器会在游戏启动时自动初始化,将所有原生事件映射到 EventBus:
|
||||
项目中同时包含 `ShrinkDataSaver.Integration.EventBus` 时,由 Context 组件或宿主显式管理桥接生命周期,将原生事件发布到指定的 ShrinkEventBus 2.0 Bus:
|
||||
|
||||
```csharp
|
||||
[EventBusSubscriber]
|
||||
public class SaveUIManager : MonoBehaviour
|
||||
[ShrinkEventSubscriber(DefaultBus = "game")]
|
||||
public sealed partial class SaveUIManager : MonoBehaviour
|
||||
{
|
||||
[EventSubscribe(EventPriority.NORMAL)]
|
||||
[ShrinkSubscribe]
|
||||
private void OnSaveCompleted(SaveCompletedEvent e)
|
||||
{
|
||||
ShowSaveIndicator(e.SlotIndex, e.ModuleNames);
|
||||
}
|
||||
|
||||
[EventSubscribe(EventPriority.NORMAL)]
|
||||
[ShrinkSubscribe]
|
||||
private void OnLoadFailed(LoadFailedEvent e)
|
||||
{
|
||||
ShowErrorDialog(e.ErrorMessage);
|
||||
}
|
||||
|
||||
[EventSubscribe(EventPriority.NORMAL)]
|
||||
[ShrinkSubscribe]
|
||||
private void OnSettingsChanged(SettingsChangedEvent e)
|
||||
{
|
||||
if (e.Key == "MasterVolume")
|
||||
@@ -306,6 +306,8 @@ public class SaveUIManager : MonoBehaviour
|
||||
}
|
||||
```
|
||||
|
||||
普通 C# 对象通过 `EventBus.Attach(target)` 接入;MonoBehaviour 可使用 `ShrinkMonoEventScope`,也可在 `OnEnable`/`OnDisable` 中自行持有并释放 binding。桥接器本身由 `ShrinkDataSaverEventBusComponent` 或 `DataSaverEventBusBridge.Register()`/`Unregister()` 管理。
|
||||
|
||||
**EventBus 事件类型完整列表:**
|
||||
|
||||
`SettingsChangedEvent` · `SaveStartedEvent` · `SaveCompletedEvent` · `SaveFailedEvent` · `LoadStartedEvent` · `LoadCompletedEvent` · `LoadFailedEvent` · `MigrationCompletedEvent` · `SlotDeletedEvent`
|
||||
|
||||
Reference in New Issue
Block a user