提交示例代码
This commit is contained in:
51
物品和背包的完整代码/Server/Entity/Gate/Container/Container.cs
Normal file
51
物品和背包的完整代码/Server/Entity/Gate/Container/Container.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Fantasy.DataStructure.Collection;
|
||||
using Fantasy.Entitas;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Bson.Serialization.Options;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
/// <summary>
|
||||
/// 代表一个容器的实体
|
||||
/// </summary>
|
||||
public sealed class Container : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置表ID
|
||||
/// </summary>
|
||||
public uint ConfigId;
|
||||
/// <summary>
|
||||
/// 账户的实体
|
||||
/// </summary>
|
||||
[BsonIgnore]
|
||||
public Account Account;
|
||||
/// <summary>
|
||||
/// 对应的Config配置文件
|
||||
/// </summary>
|
||||
[BsonIgnore]
|
||||
public ContainerConfig Config => ContainerConfigData.Instance.Get(ConfigId);
|
||||
/// <summary>
|
||||
/// 当前已经使用的格子的数量
|
||||
/// </summary>
|
||||
public int CurrentCellCount;
|
||||
/// <summary>
|
||||
/// 容器内的物品
|
||||
/// </summary>
|
||||
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
|
||||
public Dictionary<long, Item> Items = new Dictionary<long, Item>();
|
||||
/// <summary>
|
||||
/// 容器内的物品,按照格子进行存储
|
||||
/// </summary>
|
||||
[BsonIgnore]
|
||||
public Dictionary<long, Item> ItemsByCell = new Dictionary<long, Item>();
|
||||
/// <summary>
|
||||
/// 容器内的物品,按照物品配置ID进行分组
|
||||
/// </summary>
|
||||
[BsonIgnore]
|
||||
public readonly OneToManyList<uint, Item> ItemsByConfigId = new OneToManyListPool<uint, Item>();
|
||||
/// <summary>
|
||||
/// 容器内的物品,按照物品类型进行分组
|
||||
/// </summary>
|
||||
[BsonIgnore]
|
||||
public readonly OneToManyList<uint, Item> ItemsByType = new OneToManyListPool<uint, Item>();
|
||||
}
|
||||
Reference in New Issue
Block a user