Skip to content

Commit

Permalink
Update to most recent master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
SokyranTheDragon committed Apr 6, 2024
1 parent 63b50f1 commit 219b93a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Source/Common/Syncing/Worker/SyncWorkerEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Multiplayer.Client;
public class SyncWorkerEntry
{
delegate bool SyncWorkerDelegate(SyncWorker sync, ref object? obj);
delegate void SyncWorkerDelegateNoReturn(SyncWorker sync, ref object? obj);

public Type type;
public bool shouldConstruct;
Expand All @@ -35,8 +36,19 @@ public SyncWorkerEntry(SyncWorkerEntry other)

public void Add(MethodInfo method)
{
// todo: Find a way to do this without DynDelegate
Add(DynDelegate.DynamicDelegate.Create<SyncWorkerDelegate>(method), method.ReturnType == typeof(void));
if (method.ReturnType == typeof(void))
{
var func = (SyncWorkerDelegateNoReturn)Delegate.CreateDelegate(typeof(SyncWorkerDelegateNoReturn), method);
Add((SyncWorker sync, ref object obj) =>
{
func(sync, ref obj);
return true;
}, true);
}
else
{
Add((SyncWorkerDelegate)Delegate.CreateDelegate(typeof(SyncWorkerDelegate), method), false);
}
}

public void Add<T>(SyncWorkerDelegate<T> func)
Expand Down

0 comments on commit 219b93a

Please sign in to comment.