Some changes to support mod reloading. (ModAPI messages are still not being recieved properly in nexus mod) this could be a serverside issue but unknown currently

This commit is contained in:
Garrett
2024-11-09 23:38:17 -06:00
parent f631d2b9ff
commit 0fc7fee73f
7 changed files with 371 additions and 30 deletions

36
Utilities/NetUtils.cs Normal file
View File

@@ -0,0 +1,36 @@
using ProtoBuf;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SeamlessClient.Utilities
{
public class NetUtils
{
public static byte[] Serialize<T>(T instance)
{
if (instance == null)
return null;
using (var m = new MemoryStream())
{
Serializer.Serialize(m, instance);
return m.ToArray();
}
}
public static T Deserialize<T>(byte[] data)
{
if (data == null)
return default(T);
using (var m = new MemoryStream(data))
{
return Serializer.Deserialize<T>(m);
}
}
}
}