Works with just character

This commit is contained in:
Garrett
2024-10-05 17:25:11 -05:00
parent f62fc4e32b
commit 7b4a2aa205
10 changed files with 565 additions and 1371 deletions

34
Utilities/GameEvents.cs Normal file
View File

@@ -0,0 +1,34 @@
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<MethodInfo, Delegate> _delegateCache = new Dictionary<MethodInfo, Delegate>();
private static Func<T, TA> GetDelegate<T, TA>(MethodInfo method) where TA : class
{
if (!_delegateCache.TryGetValue(method, out var del))
{
del = (Func<T, TA>)(x => Delegate.CreateDelegate(typeof(TA), x, method) as TA);
_delegateCache[method] = del;
}
return (Func<T, TA>)del;
}
public static void RaiseStaticEvent<T1>(MethodInfo method, T1 arg1, EndpointId target = default, Vector3D? position = null)
{
var del = GetDelegate<IMyEventOwner, Action<T1>>(method);
MyMultiplayer.RaiseStaticEvent(del, arg1, target, position);
}
}
}