You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.1 KiB
57 lines
2.1 KiB
3 years ago
|
using System;
|
||
|
using MongoDB.Bson.Serialization;
|
||
|
using MongoDB.Bson.Serialization.Conventions;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
public static class MongoRegister
|
||
|
{
|
||
|
static MongoRegister()
|
||
|
{
|
||
|
// 自动注册IgnoreExtraElements
|
||
|
|
||
|
ConventionPack conventionPack = new ConventionPack { new IgnoreExtraElementsConvention(true) };
|
||
|
|
||
|
ConventionRegistry.Register("IgnoreExtraElements", conventionPack, type => true);
|
||
|
|
||
|
#if SERVER
|
||
|
BsonSerializer.RegisterSerializer(typeof(Vector2), new StructBsonSerialize<Vector2>());
|
||
|
BsonSerializer.RegisterSerializer(typeof(Vector3), new StructBsonSerialize<Vector3>());
|
||
|
BsonSerializer.RegisterSerializer(typeof(Vector4), new StructBsonSerialize<Vector4>());
|
||
|
BsonSerializer.RegisterSerializer(typeof(Quaternion), new StructBsonSerialize<Quaternion>());
|
||
|
BsonSerializer.RegisterSerializer(typeof(ResourceAttri), new StructBsonSerialize<ResourceAttri>());
|
||
|
#elif ROBOT
|
||
|
BsonSerializer.RegisterSerializer(typeof(Quaternion), new StructBsonSerialize<Quaternion>());
|
||
|
BsonSerializer.RegisterSerializer(typeof(Vector3), new StructBsonSerialize<Vector3>());
|
||
|
BsonSerializer.RegisterSerializer(typeof(Vector4), new StructBsonSerialize<Vector4>());
|
||
|
BsonSerializer.RegisterSerializer(typeof(ResourceAttri), new StructBsonSerialize<ResourceAttri>());
|
||
|
#else
|
||
|
BsonSerializer.RegisterSerializer(typeof (Vector4), new StructBsonSerialize<Vector4>());
|
||
|
BsonSerializer.RegisterSerializer(typeof (Vector3), new StructBsonSerialize<Vector3>());
|
||
|
#endif
|
||
|
|
||
|
var types = Game.EventSystem.GetTypes();
|
||
|
|
||
|
foreach (Type type in types.Values)
|
||
|
{
|
||
|
if (!type.IsSubclassOf(typeof (Object)))
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (type.IsGenericType)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
BsonClassMap.LookupClassMap(type);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void Init()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|