submodule对gitea不管用,所以直接拉了一份拉格兰

This commit is contained in:
2025-02-04 16:29:43 +08:00
parent b0bfc803e3
commit d149a2ea0f
1023 changed files with 43308 additions and 18 deletions

View File

@@ -0,0 +1,22 @@
using System.Numerics;
using LiteDB;
namespace Lagrange.OneBot.Utility;
public static class Vector2Mapper
{
public static void RegisterType() => BsonMapper.Global.RegisterType(Serialize, Deserialize);
public static BsonValue Serialize(Vector2 parameter) => new BsonDocument(new Dictionary<string, BsonValue>
{
{ "X", parameter.X },
{ "Y", parameter.Y }
});
public static Vector2 Deserialize(BsonValue bsonValue)
{
float x = (float)bsonValue["X"].AsDouble;
float y = (float)bsonValue["Y"].AsDouble;
return new Vector2(x, y);
}
}