diff --git a/Source/Common/Syncing/Worker/SyncWorkerEntry.cs b/Source/Common/Syncing/Worker/SyncWorkerEntry.cs index ada01cfc..2f8f2a37 100644 --- a/Source/Common/Syncing/Worker/SyncWorkerEntry.cs +++ b/Source/Common/Syncing/Worker/SyncWorkerEntry.cs @@ -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; @@ -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(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(SyncWorkerDelegate func)