新定义

This commit is contained in:
bob
2025-07-30 20:35:38 +08:00
parent e612d8fe38
commit 6b113cf32b
18 changed files with 646 additions and 94 deletions

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<LangVersion>default</LangVersion>
<TargetFramework>net9.0</TargetFramework>
@@ -28,6 +28,9 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Game\Activity\" />
<Folder Include="Game\Mail\" />
<Folder Include="Game\Skill\" />
<Folder Include="Map\" />
</ItemGroup>

27
Entity/Game/Fish/Fish.cs Normal file
View File

@@ -0,0 +1,27 @@
using Fantasy.Entitas;
using MongoDB.Bson.Serialization.Attributes;
namespace NB.Game;
public class Fish : Entity
{
/// <summary>
/// 配置id
/// </summary>
[BsonElement("cid")] public int ConfigId;
/// <summary>
/// 重量
/// </summary>
[BsonElement("w")] public int Weight;
/// <summary>
/// 获取时间
/// </summary>
[BsonElement("gt")] public long GetTime;
/// <summary>
/// 失效时间
/// </summary>
[BsonElement("et")] public long ExpirationTime;
}

View File

@@ -16,20 +16,15 @@ public class Item : Entity
/// <summary>
/// 拥有的数量
/// </summary>
public int Count;
[BsonElement("c")] public int Count;
/// <summary>
/// 配置id
/// </summary>
public int ConfigId;
[BsonElement("cid")] public int ConfigId;
/// <summary>
/// 是否绑定
/// </summary>
public bool IsBind;
/// <summary>
/// 当前所属的容器
/// </summary>
[BsonIgnore] public Container Container;
}
[BsonElement("ib")] public bool IsBind;
}

View File

@@ -1,16 +0,0 @@
using Fantasy.Entitas;
namespace NB;
public class PlayerInfo : Entity
{
/// <summary>
/// 昵称
/// </summary>
public string NickName;
/// <summary>
/// 头像
/// </summary>
public string Head;
}

View File

@@ -0,0 +1,19 @@
namespace NB;
public class PlayerVip
{
/// <summary>
/// 是否是vip
/// </summary>
public bool IsVip;
/// <summary>
/// 获取时间
/// </summary>
public long GetTime;
/// <summary>
/// 失效时间
/// </summary>
public long ExpirationTime;
}

View File

@@ -6,17 +6,48 @@ namespace NB.Game;
public sealed class Player : Entity
{
public long CreateTime;
public long LoginTime;
[BsonElement("ct")] public long CreateTime;
[BsonElement("lt")] public long LoginTime;
public PlayerBasic Basic = new PlayerBasic();
public PlayerStatistics Statistics = new PlayerStatistics();
public PlayerDayFlags DayFlags = new PlayerDayFlags();
public PlayerVip Vip = new PlayerVip();
/// <summary>
/// 余额
/// </summary>
public int Money;
/// <summary>
/// 金币
/// </summary>
public int Gold;
/// <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>();
/// <summary>
/// 鱼护
/// </summary>
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary<long, Fish> Fishes = new Dictionary<long, Fish>();
[BsonIgnore] public long SessionRunTimeId;

View File

@@ -0,0 +1,318 @@
using ProtoBuf;
using System.Collections.Generic;
using MongoDB.Bson.Serialization.Attributes;
using Fantasy;
using Fantasy.Network.Interface;
using Fantasy.Serialize;
// ReSharper disable InconsistentNaming
// ReSharper disable RedundantUsingDirective
// ReSharper disable RedundantOverriddenMember
// ReSharper disable PartialTypeWithSinglePart
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable CheckNamespace
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
#pragma warning disable CS8618
namespace Fantasy
{
/// <summary>
/// 角色基础信息
/// </summary>
[ProtoContract]
public partial class RoleBaseInfo : AMessage, IProto
{
public static RoleBaseInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<RoleBaseInfo>();
}
public override void Dispose()
{
NickName = default;
Head = default;
Country = default;
Level = default;
Exp = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<RoleBaseInfo>(this);
#endif
}
[ProtoMember(1)]
public string NickName { get; set; }
[ProtoMember(2)]
public string Head { get; set; }
[ProtoMember(3)]
public string Country { get; set; }
[ProtoMember(4)]
public int Level { get; set; }
[ProtoMember(5)]
public int Exp { get; set; }
}
[ProtoContract]
public partial class KeyValueStringInt64 : AMessage, IProto
{
public static KeyValueStringInt64 Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<KeyValueStringInt64>();
}
public override void Dispose()
{
Key = default;
Value = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<KeyValueStringInt64>(this);
#endif
}
[ProtoMember(1)]
public string Key { get; set; }
[ProtoMember(2)]
public long Value { get; set; }
}
[ProtoContract]
public partial class KeyValueInt64 : AMessage, IProto
{
public static KeyValueInt64 Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<KeyValueInt64>();
}
public override void Dispose()
{
Key = default;
Value = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<KeyValueInt64>(this);
#endif
}
[ProtoMember(1)]
public long Key { get; set; }
[ProtoMember(2)]
public long Value { get; set; }
}
[ProtoContract]
public partial class KeyValueString : AMessage, IProto
{
public static KeyValueString Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<KeyValueString>();
}
public override void Dispose()
{
Key = default;
Value = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<KeyValueString>(this);
#endif
}
[ProtoMember(1)]
public string Key { get; set; }
[ProtoMember(2)]
public string Value { get; set; }
}
/// <summary>
/// 角色信息
/// </summary>
[ProtoContract]
public partial class RoleInfo : AMessage, IProto
{
public static RoleInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<RoleInfo>();
}
public override void Dispose()
{
BaseInfo = default;
RoleId = default;
Items.Clear();
Fishs.Clear();
Activities.Clear();
Currency.Clear();
Slots.Clear();
Skills.Clear();
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<RoleInfo>(this);
#endif
}
[ProtoMember(1)]
public RoleBaseInfo BaseInfo { get; set; }
[ProtoMember(2)]
public long RoleId { get; set; }
[ProtoMember(3)]
public List<ItemInfo> Items = new List<ItemInfo>();
[ProtoMember(4)]
public List<FishInfo> Fishs = new List<FishInfo>();
[ProtoMember(5)]
public List<ActivityInfo> Activities = new List<ActivityInfo>();
[ProtoMember(6)]
public List<KeyValueInt64> Currency = new List<KeyValueInt64>();
[ProtoMember(7)]
public List<KeyValueInt64> Slots = new List<KeyValueInt64>();
[ProtoMember(8)]
public List<SkillInfo> Skills = new List<SkillInfo>();
}
/// <summary>
/// VIP信息
/// </summary>
[ProtoContract]
public partial class VipInfo : AMessage, IProto
{
public static VipInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<VipInfo>();
}
public override void Dispose()
{
OpenTime = default;
ExpirationTime = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<VipInfo>(this);
#endif
}
[ProtoMember(1)]
public long OpenTime { get; set; }
[ProtoMember(2)]
public long ExpirationTime { get; set; }
}
/// <summary>
/// 奖励信息
/// </summary>
[ProtoContract]
public partial class AwardInfo : AMessage, IProto
{
public static AwardInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<AwardInfo>();
}
public override void Dispose()
{
ConfigId = default;
Count = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<AwardInfo>(this);
#endif
}
[ProtoMember(1)]
public long ConfigId { get; set; }
[ProtoMember(2)]
public int Count { get; set; }
}
/// <summary>
/// 物品信息
/// </summary>
[ProtoContract]
public partial class ItemInfo : AMessage, IProto
{
public static ItemInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<ItemInfo>();
}
public override void Dispose()
{
ConfigId = default;
Id = default;
Count = default;
ExpirationTime = default;
GetTime = default;
Abrasion = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<ItemInfo>(this);
#endif
}
[ProtoMember(1)]
public int ConfigId { get; set; }
[ProtoMember(2)]
public long Id { get; set; }
[ProtoMember(3)]
public int Count { get; set; }
[ProtoMember(4)]
public long ExpirationTime { get; set; }
[ProtoMember(5)]
public long GetTime { get; set; }
[ProtoMember(6)]
public long Abrasion { get; set; }
}
/// <summary>
/// fish信息
/// </summary>
[ProtoContract]
public partial class FishInfo : AMessage, IProto
{
public static FishInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<FishInfo>();
}
public override void Dispose()
{
ConfigId = default;
Id = default;
Weight = default;
GetTime = default;
ExpirationTime = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<FishInfo>(this);
#endif
}
[ProtoMember(1)]
public int ConfigId { get; set; }
[ProtoMember(2)]
public long Id { get; set; }
[ProtoMember(3)]
public int Weight { get; set; }
[ProtoMember(4)]
public long GetTime { get; set; }
[ProtoMember(5)]
public long ExpirationTime { get; set; }
}
[ProtoContract]
public partial class ActivityInfo : AMessage, IProto
{
public static ActivityInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<ActivityInfo>();
}
public override void Dispose()
{
Id = default;
StartTime = default;
EndTime = default;
Data.Clear();
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<ActivityInfo>(this);
#endif
}
[ProtoMember(1)]
public long Id { get; set; }
[ProtoMember(2)]
public long StartTime { get; set; }
[ProtoMember(3)]
public long EndTime { get; set; }
[ProtoMember(4)]
public List<KeyValueStringInt64> Data = new List<KeyValueStringInt64>();
}
/// <summary>
/// 技能情况
/// </summary>
[ProtoContract]
public partial class SkillInfo : AMessage, IProto
{
public static SkillInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<SkillInfo>();
}
public override void Dispose()
{
ConfigId = default;
Level = default;
Exp = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<SkillInfo>(this);
#endif
}
[ProtoMember(1)]
public int ConfigId { get; set; }
[ProtoMember(2)]
public int Level { get; set; }
[ProtoMember(3)]
public int Exp { get; set; }
}
}

View File

@@ -18,58 +18,41 @@ using Fantasy.Serialize;
namespace Fantasy
{
/// <summary>
/// GameAccount实体类
/// 好友信息
/// </summary>
[ProtoContract]
public partial class RoleBaseInfo : AMessage, IProto
public partial class FriendInfo : AMessage, IProto
{
public static RoleBaseInfo Create(Scene scene)
public static FriendInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<RoleBaseInfo>();
return scene.MessagePoolComponent.Rent<FriendInfo>();
}
public override void Dispose()
{
Id = default;
AddTime = default;
NickName = default;
Head = default;
Country = default;
Level = default;
Exp = default;
Country = default;
OnlineStatus = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<RoleBaseInfo>(this);
GetScene().MessagePoolComponent.Return<FriendInfo>(this);
#endif
}
[ProtoMember(1)]
public string NickName { get; set; }
public long Id { get; set; }
[ProtoMember(2)]
public string Head { get; set; }
public long AddTime { get; set; }
[ProtoMember(3)]
public string Country { get; set; }
public string NickName { get; set; }
[ProtoMember(4)]
public int Level { get; set; }
public string Head { get; set; }
[ProtoMember(5)]
public int Exp { get; set; }
}
/// <summary>
/// 角色信息
/// </summary>
[ProtoContract]
public partial class RoleInfo : AMessage, IProto
{
public static RoleInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<RoleInfo>();
}
public override void Dispose()
{
BaseInfo = default;
RoleId = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<RoleInfo>(this);
#endif
}
[ProtoMember(1)]
public RoleBaseInfo BaseInfo { get; set; }
[ProtoMember(2)]
public long RoleId { get; set; }
public int Level { get; set; }
[ProtoMember(6)]
public string Country { get; set; }
[ProtoMember(7)]
public int OnlineStatus { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using ProtoBuf;
using System.Collections.Generic;
using MongoDB.Bson.Serialization.Attributes;
using Fantasy;
using Fantasy.Network.Interface;
using Fantasy.Serialize;
// ReSharper disable InconsistentNaming
// ReSharper disable RedundantUsingDirective
// ReSharper disable RedundantOverriddenMember
// ReSharper disable PartialTypeWithSinglePart
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable CheckNamespace
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
#pragma warning disable CS8618
namespace Fantasy
{
}

View File

@@ -0,0 +1,55 @@
using ProtoBuf;
using System.Collections.Generic;
using MongoDB.Bson.Serialization.Attributes;
using Fantasy;
using Fantasy.Network.Interface;
using Fantasy.Serialize;
// ReSharper disable InconsistentNaming
// ReSharper disable RedundantUsingDirective
// ReSharper disable RedundantOverriddenMember
// ReSharper disable PartialTypeWithSinglePart
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable CheckNamespace
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
#pragma warning disable CS8618
namespace Fantasy
{
[ProtoContract]
public partial class MailInfo : AMessage, IProto
{
public static MailInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<MailInfo>();
}
public override void Dispose()
{
Id = default;
Title = default;
Content = default;
SendTime = default;
Type = default;
Items.Clear();
IsRead = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<MailInfo>(this);
#endif
}
[ProtoMember(1)]
public long Id { get; set; }
[ProtoMember(2)]
public string Title { get; set; }
[ProtoMember(3)]
public string Content { get; set; }
[ProtoMember(4)]
public long SendTime { get; set; }
[ProtoMember(5)]
public int Type { get; set; }
[ProtoMember(6)]
public List<AwardInfo> Items = new List<AwardInfo>();
[ProtoMember(7)]
public bool IsRead { get; set; }
}
}