quantum-space-buddies/QSB/API/AddonDataManager.cs
JohnCorby 63a5a13342 Revert "test"
This reverts commit 0fc0715048.
2023-08-23 16:03:51 -07:00

27 lines
645 B
C#

using System;
using System.Collections.Generic;
using OWML.Common;
using QSB.Utility;
namespace QSB.API;
public static class AddonDataManager
{
private static readonly Dictionary<int, Action<uint, object>> _handlers = new();
public static void OnReceiveDataMessage(int hash, object data, uint from)
{
if (!_handlers.TryGetValue(hash, out var handler))
{
DebugLog.DebugWrite($"unknown addon message type with hash {hash}", MessageType.Error);
return;
}
handler(from, data);
}
public static void RegisterHandler<T>(int hash, Action<uint, T> handler)
{
_handlers.Add(hash, (from, data) => handler(from, (T)data));
}
}