using Sandbox.Engine.Multiplayer; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using VRage.Network; using VRageMath; namespace SeamlessClient.Utilities { public class GameEvents { private static Dictionary _delegateCache = new Dictionary(); private static Func GetDelegate(MethodInfo method) where TA : class { if (!_delegateCache.TryGetValue(method, out var del)) { del = (Func)(x => Delegate.CreateDelegate(typeof(TA), x, method) as TA); _delegateCache[method] = del; } return (Func)del; } public static void RaiseStaticEvent(MethodInfo method, T1 arg1, EndpointId target = default, Vector3D? position = null) { var del = GetDelegate>(method); MyMultiplayer.RaiseStaticEvent(del, arg1, target, position); } } }