using Fantasy.Entitas;
using Fantasy.Entitas.Interface;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Options;
namespace Fantasy;
///
/// 把用户的所有容器都放在一个组件里,这样保存的时候也会存储在一个文档里。
/// 如果物品数据过多,可能会超过数据库单条的限制。
/// MongoDB的数据库的单个文档的最大大小限制为16MB。
/// 所以这个几乎不会出现的,完全不需要考虑这个大小的问题了。因为几乎把玩家可能有16MB的物品。
///
public sealed class ContainerComponent : Entity, ISupportedDataBase
{
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary Containers = new Dictionary();
}
// 如果不放心,可以把每个容器单独做一个组件存起来
// 例如下面
///
/// 背包容器组件
///
public sealed class BagContainerComponent : Entity, ISupportedDataBase
{
public Container Container;
}
///
/// 装备容器组件
///
public sealed class EquipContainerComponent : Entity, ISupportedDataBase
{
public Container Container;
}