mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 05:23:59 +00:00
Add character & inventory manager
This commit is contained in:
71
Common/Database/Inventory/InventoryData.cs
Normal file
71
Common/Database/Inventory/InventoryData.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using MikuSB.Proto;
|
||||
using SqlSugar;
|
||||
|
||||
namespace MikuSB.Database.Inventory;
|
||||
|
||||
[SugarTable("inventory_data")]
|
||||
public class InventoryData : BaseDatabaseDataHelper
|
||||
{
|
||||
public uint NextUniqueUid { get; set; } = 100000;
|
||||
|
||||
[SugarColumn(IsJson = true)]
|
||||
public Dictionary<uint, BaseGameItemInfo> Items { get; set; } = []; // Key: UniqueId
|
||||
|
||||
[SugarColumn(IsJson = true)]
|
||||
public Dictionary<uint, GameWeaponInfo> Weapons { get; set; } = []; // Key: UniqueId
|
||||
|
||||
[SugarColumn(IsJson = true)]
|
||||
public Dictionary<uint, GameSkinInfo> Skins { get; set; } = []; // Key: UniqueId
|
||||
}
|
||||
|
||||
public abstract class BaseGameItemInfo
|
||||
{
|
||||
public uint UniqueId { get; set; }
|
||||
public ulong TemplateId { get; set; }
|
||||
public uint ItemCount { get; set; }
|
||||
}
|
||||
|
||||
public abstract class GrowableItemInfo : BaseGameItemInfo
|
||||
{
|
||||
public bool IsLocked { get; set; }
|
||||
public uint Level { get; set; }
|
||||
public uint Exp { get; set; }
|
||||
public uint EquipAvatarId { get; set; }
|
||||
}
|
||||
|
||||
public class GameWeaponInfo : GrowableItemInfo
|
||||
{
|
||||
public Item ToProto()
|
||||
{
|
||||
var proto = new Item
|
||||
{
|
||||
Id = UniqueId,
|
||||
Template = TemplateId,
|
||||
Count = ItemCount,
|
||||
Enhance = new Enhance
|
||||
{
|
||||
Level = Level
|
||||
}
|
||||
};
|
||||
return proto;
|
||||
}
|
||||
}
|
||||
|
||||
public class GameSkinInfo : BaseGameItemInfo
|
||||
{
|
||||
public uint Level { get; set; }
|
||||
public Item ToProto()
|
||||
{
|
||||
var proto = new Item
|
||||
{
|
||||
Id = UniqueId,
|
||||
Template = TemplateId,
|
||||
Count = ItemCount,
|
||||
Enhance = new Enhance
|
||||
{
|
||||
Level = Level
|
||||
}
|
||||
};
|
||||
return proto;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user