fix(SyncList): Change Callback to Action

This commit is contained in:
MrGadget 2024-03-23 11:54:14 -04:00
parent f2d43de036
commit f2b89867a0
3 changed files with 5 additions and 6 deletions

View File

@ -15,8 +15,7 @@ public enum Operation : byte
OP_CLEAR
}
public delegate void SyncListChanged(Operation op, int itemIndex, T oldItem, T newItem);
public event SyncListChanged Callback;
public Action<Operation, int, T, T> Callback;
readonly IList<T> objects;
readonly IEqualityComparer<T> comparer;

View File

@ -48,7 +48,7 @@ public void OldValueShouldNotBeNewValue()
serverList[0] = player;
bool callbackCalled = false;
clientList.Callback += (SyncList<TestPlayer>.Operation op, int itemIndex, TestPlayer oldItem, TestPlayer newItem) =>
clientList.Callback = (SyncList<TestPlayer>.Operation op, int itemIndex, TestPlayer oldItem, TestPlayer newItem) =>
{
Assert.That(op == SyncList<TestPlayer>.Operation.OP_SET, Is.True);
Assert.That(itemIndex, Is.EqualTo(0));

View File

@ -278,7 +278,7 @@ public void CallbackTest()
{
bool called = false;
clientSyncList.Callback += (op, index, oldItem, newItem) =>
clientSyncList.Callback = (op, index, oldItem, newItem) =>
{
called = true;
@ -299,7 +299,7 @@ public void CallbackRemoveTest()
{
bool called = false;
clientSyncList.Callback += (op, index, oldItem, newItem) =>
clientSyncList.Callback = (op, index, oldItem, newItem) =>
{
called = true;
@ -318,7 +318,7 @@ public void CallbackRemoveAtTest()
{
bool called = false;
clientSyncList.Callback += (op, index, oldItem, newItem) =>
clientSyncList.Callback = (op, index, oldItem, newItem) =>
{
called = true;