Skip to content

Commit

Permalink
fix(SyncList): Change Callback to Action
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGadget1024 committed Mar 23, 2024
1 parent f2d43de commit f2b8986
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Assets/Mirror/Core/SyncList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions Assets/Mirror/Tests/Editor/SyncCollections/SyncListTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public void CallbackTest()
{
bool called = false;

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

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

clientSyncList.Callback += (op, index, oldItem, newItem) =>
clientSyncList.Callback = (op, index, oldItem, newItem) =>
{
called = true;
Expand Down

0 comments on commit f2b8986

Please sign in to comment.