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:
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "ShrinkEventBus.PlayMode.Tests",
|
||||
"rootNamespace": "ShrinkEventBus.PlayMode.Tests",
|
||||
"references": [
|
||||
"ShrinkEventBus.Runtime",
|
||||
"UniTask"
|
||||
],
|
||||
"optionalUnityReferences": ["TestAssemblies"],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": ["UNITY_INCLUDE_TESTS"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b03fa714413c4af5ad4140e7a409ef2f
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
#nullable enable
|
||||
|
||||
using System.Collections;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
namespace ShrinkEventBus.PlayMode.Tests
|
||||
{
|
||||
internal readonly struct MonoLifecycleEvent : IShrinkEvent
|
||||
{
|
||||
public MonoLifecycleEvent(int value) => Value = value;
|
||||
public int Value { get; }
|
||||
}
|
||||
|
||||
[ShrinkEventSubscriber(DefaultBus = "game")]
|
||||
internal sealed class MonoLifecycleTarget : MonoBehaviour
|
||||
{
|
||||
public int Sum { get; private set; }
|
||||
|
||||
[ShrinkSubscribe]
|
||||
private void OnEvent(MonoLifecycleEvent value) => Sum += value.Value;
|
||||
}
|
||||
|
||||
public sealed class ShrinkMonoEventScopePlayModeTests
|
||||
{
|
||||
[UnityTest]
|
||||
public IEnumerator OnEnableAttachesAndOnDisableReleases()
|
||||
{
|
||||
var gameObject = new GameObject("ShrinkMonoEventScope-PlayMode");
|
||||
gameObject.SetActive(false);
|
||||
var target = gameObject.AddComponent<MonoLifecycleTarget>();
|
||||
gameObject.AddComponent<ShrinkMonoEventScope>();
|
||||
|
||||
gameObject.SetActive(true);
|
||||
yield return null;
|
||||
yield return EventBus.PostAsync(new MonoLifecycleEvent(3)).ToCoroutine();
|
||||
Assert.AreEqual(3, target.Sum);
|
||||
|
||||
gameObject.SetActive(false);
|
||||
yield return null;
|
||||
yield return EventBus.PostAsync(new MonoLifecycleEvent(5)).ToCoroutine();
|
||||
Assert.AreEqual(3, target.Sum);
|
||||
Object.Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f42b5f6f2249483b9978f0fa729d479b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user