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:
@@ -214,7 +214,7 @@ namespace ShrinkContext.AppAdapter
|
||||
$"waiting={WaitingModuleIds.Count} disabled={_disabled.Count} " +
|
||||
$"modules=[{string.Join(", ", active)}]");
|
||||
|
||||
EventBus.TriggerEvent(new ShrinkAppStartedEvent
|
||||
EventBus.Post(new ShrinkAppStartedEvent
|
||||
{
|
||||
ModuleIds = active.ToArray()
|
||||
});
|
||||
|
||||
@@ -19,6 +19,15 @@ namespace ShrinkContext.AppAdapter.Tests
|
||||
/// </summary>
|
||||
public class ShrinkAppLoaderHostTests
|
||||
{
|
||||
[ShrinkEventSubscriber(DefaultBus = "game")]
|
||||
private sealed class AppStartedProbe
|
||||
{
|
||||
public ShrinkAppStartedEvent? Value { get; private set; }
|
||||
|
||||
[ShrinkSubscribe]
|
||||
private void OnStarted(ShrinkAppStartedEvent value) => Value = value;
|
||||
}
|
||||
|
||||
private ShrinkAppSettings _settings = null!;
|
||||
|
||||
[SetUp]
|
||||
@@ -46,8 +55,8 @@ namespace ShrinkContext.AppAdapter.Tests
|
||||
new FakeInstaller("app.a", "a"),
|
||||
new FakeInstaller("app.b", "b") { DependsOn = new[] { "app.a" } });
|
||||
|
||||
ShrinkAppStartedEvent? started = null;
|
||||
using (var subscription = EventBus.SubscribeEvent<ShrinkAppStartedEvent>(e => started = e))
|
||||
var probe = new AppStartedProbe();
|
||||
using (EventBus.Attach(probe))
|
||||
{
|
||||
TestAwait.Run(host.StartAsync());
|
||||
}
|
||||
@@ -55,8 +64,8 @@ namespace ShrinkContext.AppAdapter.Tests
|
||||
Assert.IsTrue(host.IsRunning);
|
||||
Assert.IsTrue(host.IsModuleActive("app.a"));
|
||||
Assert.IsTrue(host.IsModuleActive("app.b"), "依赖模块在提供者激活后自动激活");
|
||||
Assert.IsNotNull(started);
|
||||
CollectionAssert.AreEquivalent(new[] { "app.a", "app.b" }, started!.ModuleIds);
|
||||
Assert.IsNotNull(probe.Value);
|
||||
CollectionAssert.AreEquivalent(new[] { "app.a", "app.b" }, probe.Value!.ModuleIds);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user