自动定时数据落地

This commit is contained in:
bob
2025-08-01 18:05:25 +08:00
parent 96f22a3e48
commit c97bd0ab55
30 changed files with 477 additions and 310 deletions

View File

@@ -29,7 +29,6 @@
<ItemGroup>
<Folder Include="Game\Activity\" />
<Folder Include="Game\Skill\" />
<Folder Include="Map\" />
</ItemGroup>

View File

@@ -1,23 +0,0 @@
using Fantasy.Entitas;
namespace NB;
public enum ContainerType : uint
{
/// <summary>
/// 背包
/// </summary>
Bag,
/// <summary>
/// 鱼护
/// </summary>
FishBag,
}
/// <summary>
/// 物品容器组件
/// </summary>
public class ContainerComponent : Entity
{
}

View File

@@ -24,4 +24,14 @@ public class Fish : Entity
/// 失效时间
/// </summary>
[BsonElement("et")] public long ExpirationTime;
/// <summary>
/// 获取地图
/// </summary>
[BsonElement("map")] public int Map;
/// <summary>
/// 物品所属的容器
/// </summary>
[BsonIgnore] FishContainer Container;
}

View File

@@ -0,0 +1,19 @@
using Fantasy.Entitas;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Options;
namespace NB.Game;
public class FishContainer : Entity
{
/// <summary>
/// 最大格子数量
/// </summary>
public int CellCountMax;
/// <summary>
/// 容器内的物品
/// </summary>
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary<long, Item> Fishes = new Dictionary<long, Item>();
}

View File

@@ -11,8 +11,6 @@ public enum ItemType
Fish,
}
public class Item : Entity
{
/// <summary>
@@ -43,5 +41,10 @@ public class Item : Entity
/// <summary>
/// 耐久度
/// </summary>
[BsonElement("a")] public int Abrasion;
[BsonElement("abr")] public int Abrasion;
/// <summary>
/// 物品所属的容器
/// </summary>
[BsonIgnore] ItemContainer Container;
}

View File

@@ -6,34 +6,20 @@ using NB.Game;
namespace NB;
public sealed class Container : Entity
public sealed class ItemContainer : Entity
{
/// <summary>
/// 可用格子数量
/// </summary>
public int CellCount;
/// <summary>
/// 最大格子数量
/// </summary>
public int CellCountMax;
/// <summary>
/// 当前已经使用格子数量
/// </summary>
public int CurrentCellCount;
/// <summary>
/// 容器内的物品
/// </summary>
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary<long, Item> Items = new Dictionary<long, Item>();
/// <summary>
/// 容器内物品,按格子进行分组
/// </summary>
[BsonIgnore] public Dictionary<uint, Item> ItemsByCell = new Dictionary<uint, Item>();
/// <summary>
/// 按物品id分组
/// </summary>

View File

@@ -0,0 +1,10 @@
using Fantasy.Entitas;
namespace NB.Game;
/// <summary>
/// 角色任务
/// </summary>
public class Mission : Entity
{
}

View File

@@ -0,0 +1,32 @@
using Fantasy.Entitas;
using MongoDB.Bson.Serialization.Attributes;
namespace NB.Game;
public class PlayerBasic : Entity
{
/// <summary>
/// 昵称
/// </summary>
public string NickName;
/// <summary>
/// 头像
/// </summary>
public string Head;
/// <summary>
/// 国家
/// </summary>
public string Country;
/// <summary>
/// 等级
/// </summary>
public int Level;
/// <summary>
/// 当前经验
/// </summary>
public int Exp;
}

View File

@@ -0,0 +1,34 @@
using Fantasy.Entitas;
namespace NB.Game;
public enum SlotType
{
None,
/// <summary>
/// 物品
/// </summary>
Item,
/// <summary>
/// 钓组
/// </summary>
Tackle
}
/// <summary>
/// 快速使用插槽
/// </summary>
public class PlayerSlot : Entity
{
/// <summary>
/// 插槽类型
/// </summary>
public SlotType SlotType;
/// <summary>
/// 绑定快速使用的id
/// </summary>
public long BindId;
}

View File

@@ -1,4 +1,5 @@
using Fantasy.Entitas;
using MongoDB.Bson.Serialization.Attributes;
namespace NB;

View File

@@ -3,8 +3,9 @@
namespace NB;
/// <summary>
/// 角色状态标志量
/// 玩家钓组
/// </summary>
public class PlayerDayFlags
public class PlayerTackle : Entity
{
}

View File

@@ -1,6 +1,9 @@
namespace NB;
using Fantasy.Entitas;
using MongoDB.Bson.Serialization.Attributes;
public class PlayerVip
namespace NB;
public class PlayerVip : Entity
{
/// <summary>
/// 是否是vip

View File

@@ -0,0 +1,27 @@
using Fantasy.Entitas;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Options;
namespace NB.Game;
/// <summary>
/// 用户钱包
/// </summary>
public class PlayerWallet : Entity
{
/// <summary>
/// 余额
/// </summary>
public int Money;
/// <summary>
/// 金币
/// </summary>
public int Gold;
/// <summary>
/// 其他货币
/// </summary>
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary<int, int> Other = new();
}

View File

@@ -6,72 +6,35 @@ namespace NB.Game;
public sealed class Player : Entity
{
[BsonElement("ct")] public long CreateTime;
[BsonElement("lt")] public long LoginTime;
/// <summary>
/// 基础信息
/// </summary>
public PlayerBasic Basic;
/// <summary>
/// 昵称
/// 统计信息
/// </summary>
[BsonElement("name")] public string NickName;
public PlayerStatistics Statistics;
/// <summary>
/// 头像
/// 角色vip信息
/// </summary>
public string Head;
public PlayerVip Vip;
/// <summary>
/// 国家
/// 钱包
/// </summary>
public string Country;
public PlayerWallet Wallet;
/// <summary>
/// 等级
/// 背包
/// </summary>
[BsonElement("lv")] public int Level;
/// <summary>
/// 当前经验
/// </summary>
public int Exp;
/// <summary>
/// 余额
/// </summary>
public int Money;
/// <summary>
/// 金币
/// </summary>
public int Gold;
// public PlayerStatistics Statistics = new PlayerStatistics();
// public PlayerDayFlags DayFlags = new PlayerDayFlags();
// public PlayerVip Vip = new PlayerVip();
/// <summary>
/// 其他货币
/// </summary>
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary<int, int> Currency = new();
/// <summary>
/// 插槽
/// </summary>
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary<uint, long> Slots = new Dictionary<uint, long>();
/// <summary>
/// 背包物品
/// </summary>
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary<long, Item> Items = new Dictionary<long, Item>();
public ItemContainer ItemContainer;
/// <summary>
/// 鱼护
/// </summary>
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary<long, Fish> Fishes = new Dictionary<long, Fish>();
public FishContainer FishContainer;
[BsonIgnore] public long SessionRunTimeId;
@@ -82,7 +45,7 @@ public sealed class Player : Entity
[BsonIgnore] public bool NeedSave;
/// <summary>
/// 最后保存时间
/// 需要保存数据库时间
/// </summary>
[BsonIgnore] public long LastSaveTime;
[BsonIgnore] public long NeedSaveTime;
}

View File

@@ -1,8 +0,0 @@
using Fantasy.Entitas;
namespace NB.Game;
public class PlayerAutoSaveComponent : Entity
{
}

View File

@@ -4,5 +4,17 @@ namespace NB.Game;
public sealed class PlayerManageComponent : Entity
{
/// <summary>
/// 10分钟
/// </summary>
public const long AutoSaveTime = 60000; // 600000;
public long AutoSaveTimerId;
public readonly Dictionary<long, Player> Players = new();
/// <summary>
/// 需要保存到数据库的玩家
/// </summary>
public readonly HashSet<long> NeedSavePlayer = new();
}

View File

@@ -0,0 +1,11 @@
using Fantasy.Entitas;
namespace NB.Game;
/// <summary>
/// 角色技能
/// </summary>
public class Skill : Entity
{
}