Files
2026-03-05 11:39:06 +08:00

34 lines
1.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Fantasy.Entitas;
using Fantasy.Entitas.Interface;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Options;
namespace Fantasy;
/// <summary>
/// 把用户的所有容器都放在一个组件里,这样保存的时候也会存储在一个文档里。
/// 如果物品数据过多,可能会超过数据库单条的限制。
/// MongoDB的数据库的单个文档的最大大小限制为16MB。
/// 所以这个几乎不会出现的完全不需要考虑这个大小的问题了。因为几乎把玩家可能有16MB的物品。
/// </summary>
public sealed class ContainerComponent : Entity, ISupportedDataBase
{
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary<int, Container> Containers = new Dictionary<int, Container>();
}
// 如果不放心,可以把每个容器单独做一个组件存起来
// 例如下面
/// <summary>
/// 背包容器组件
/// </summary>
public sealed class BagContainerComponent : Entity, ISupportedDataBase
{
public Container Container;
}
/// <summary>
/// 装备容器组件
/// </summary>
public sealed class EquipContainerComponent : Entity, ISupportedDataBase
{
public Container Container;
}