This commit is contained in:
2025-07-27 12:34:04 +08:00
parent 6311c7cb12
commit 743c1d2baa
194 changed files with 81685 additions and 696 deletions

View File

@@ -0,0 +1,7 @@
using Fantasy.Entitas;
namespace Fantasy;
public class ChatComponent : Entity
{
}

View File

@@ -19,6 +19,7 @@
<ItemGroup>
<ProjectReference Include="..\Fantasy\Fantasy.Net\Fantasy.Net\Fantasy.Net.csproj" />
<ProjectReference Include="..\Fantasy\Fantasy.Packages\Fantasy.ConfigTable\Net\Fantasy.ConfigTable.csproj" />
<ProjectReference Include="..\ThirdParty\ThirdParty.csproj" />
</ItemGroup>
<ItemGroup>
@@ -28,6 +29,7 @@
<ItemGroup>
<Folder Include="Gate\" />
<Folder Include="Map\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,46 @@
using Fantasy.DataStructure.Collection;
using Fantasy.Entitas;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Options;
using NB.Game;
namespace NB;
public sealed class Container : 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>
[BsonIgnore] public readonly OneToManyList<uint, Item> ItemsByConfigId = new OneToManyListPool<uint, Item>();
/// <summary>
/// 容器内按物品类型分组
/// </summary>
[BsonIgnore] public readonly OneToManyList<uint, Item> ItemsByType = new OneToManyListPool<uint, Item>();
}

View File

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

View File

@@ -1,16 +0,0 @@
using Fantasy.Entitas;
namespace NB.Game;
public class Currency : Entity
{
/// <summary>
/// 配置id
/// </summary>
public int ConfigId;
/// <summary>
/// 拥有的数量
/// </summary>
public int Count;
}

View File

@@ -1,5 +0,0 @@
namespace NB.Game;
public class DayFlags
{
}

View File

@@ -1,21 +0,0 @@
using Fantasy.Entitas;
namespace NB.Game;
public class GamingInfo : Entity
{
/// <summary>
/// 地图
/// </summary>
public int Map;
/// <summary>
/// 位置
/// </summary>
public int Pos;
/// <summary>
/// 进入时间
/// </summary>
public int Time;
}

View File

@@ -1,26 +0,0 @@
using Fantasy.Entitas;
namespace NB.Game;
public class Guide : Entity
{
/// <summary>
/// 排序
/// </summary>
public int Sort;
/// <summary>
/// 配置id
/// </summary>
public int ConfigId;
/// <summary>
/// 步骤
/// </summary>
public int Step;
/// <summary>
/// 触发时间
/// </summary>
public long GetTime;
}

View File

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

View File

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

View File

@@ -1,11 +0,0 @@
using Fantasy.Entitas;
namespace Fantasy;
/// <summary>
/// 玩家信息
/// </summary>
public class Player : Entity
{
}

View File

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

View File

@@ -1,62 +0,0 @@
using Fantasy.Entitas;
using NB.Game;
namespace NB;
public class UserInfo : Entity
{
/// <summary>
/// 基础信息
/// </summary>
public BasicInfo BasicInfo;
/// <summary>
/// 统计信息
/// </summary>
public UserStatisticsInfo Statistics;
/// <summary>
/// 游戏信息
/// </summary>
public GamingInfo GamingInfo;
/// <summary>
/// 货币信息
/// </summary>
public List<Currency> Currency;
/// <summary>
/// 拥有的物品
/// </summary>
public List<Item> Items;
/// <summary>
/// 参与的活动
/// </summary>
public List<Activity> Activity;
/// <summary>
/// 任务列表
/// </summary>
public List<Mission> Missions;
/// <summary>
/// 账号标识
/// </summary>
public DayFlags DayFlags;
/// <summary>
/// 拥有的技能
/// </summary>
public List<Skill> Abilities;
/// <summary>
/// 引导情况
/// </summary>
public List<Guide> Guides;
/// <summary>
/// 地图情况
/// </summary>
public List<MapMatter> MapMatters;
}

View File

@@ -1,7 +1,16 @@
using Fantasy.Entitas;
using MongoDB.Bson.Serialization.Attributes;
namespace NB.Game;
public enum ItemType
{
None = 0,
Item,
Equip,
Fish,
}
public class Item : Entity
{
/// <summary>
@@ -18,4 +27,9 @@ public class Item : Entity
/// 是否绑定
/// </summary>
public bool IsBind;
}
/// <summary>
/// 当前所属的容器
/// </summary>
[BsonIgnore] public Container Container;
}

View File

@@ -2,6 +2,7 @@
namespace NB.Game;
public class Activity : Entity
public class ItemComponent : Entity
{
}

View File

@@ -1,8 +1,12 @@
using Fantasy.Entitas;
namespace NB.Game;
namespace NB;
public class BasicInfo : Entity
/// <summary>
/// 角色基础数据
/// </summary>
[RoleCom]
public class RoleBasic : Entity
{
/// <summary>
/// 昵称

View File

@@ -0,0 +1,15 @@
using Fantasy.Entitas;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Options;
namespace NB;
/// <summary>
/// 角色货币数据
/// </summary>
[RoleCom]
public class RoleCurrency : Entity
{
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary<int, int> dic = new();
}

View File

@@ -0,0 +1,11 @@
using Fantasy.Entitas;
namespace NB;
/// <summary>
/// 角色状态标志量
/// </summary>
[RoleCom]
public class RoleDayFlags : Entity
{
}

View File

@@ -1,8 +1,12 @@
using Fantasy.Entitas;
namespace NB.Game;
namespace NB;
public class UserStatisticsInfo : Entity
/// <summary>
/// 角色统计数据
/// </summary>
[RoleCom]
public class RoleStatistics : Entity
{
/// <summary>
/// 登录次数
@@ -24,5 +28,8 @@ public class UserStatisticsInfo : Entity
/// </summary>
public long CreateTime;
/// <summary>
/// 钓鱼个数
/// </summary>
public int FishCount;
}

8
Entity/Game/Role/Role.cs Normal file
View File

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

View File

@@ -0,0 +1,10 @@
using CommandLine;
namespace NB;
/// <summary>
/// 挂这个 玩家Role创建时会自动添加此组件
/// </summary>
public class RoleComAttribute : BaseAttribute
{
}

View File

@@ -0,0 +1,8 @@
using Fantasy.Entitas;
namespace NB;
public class RoleManagerComponent : Entity
{
public readonly Dictionary<long, Role> Roles = new();
}

View File

@@ -3,10 +3,8 @@ using MongoDB.Bson.Serialization.Attributes;
namespace NB.Gate;
public sealed class GameAccount : Entity
public sealed class Player : Entity
{
// 1、可以拿ToKen的传递过来的AId来当这个组件的Id.
// 2、让这个Id自动生成、在组件里做一个变量来记录ToKen的AId。 public long AuthenticationId;
public long CreateTime;
public long LoginTime;

View File

@@ -2,12 +2,14 @@ using Fantasy.Entitas;
namespace NB.Gate;
public sealed class GameAccountFlagComponent : Entity
public sealed class PlayerFlagComponent : Entity
{
public bool Kick { get; set; }
public long AccountID;
// 有一种可能当在Account在其他地方被销毁
// 这时候因为这个Account是会回收到池子中所以这个引用还是有效的
// 那这时候就会出现这个引用的Account可能是其他用户的了。
public EntityReference<GameAccount> Account;
public EntityReference<Player> Account;
}

View File

@@ -1,8 +0,0 @@
using Fantasy.Entitas;
namespace NB.Gate;
public sealed class GameAccountManageComponent : Entity
{
public readonly Dictionary<long, GameAccount> Accounts = new();
}

View File

@@ -0,0 +1,8 @@
using Fantasy.Entitas;
namespace NB.Gate;
public sealed class PlayerManageComponent : Entity
{
public readonly Dictionary<long, Player> Players = new();
}

View File

@@ -163,7 +163,6 @@ namespace Fantasy
}
public override void Dispose()
{
Unit = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<M2M_SendUnitRequest>(this);
#endif
@@ -171,7 +170,6 @@ namespace Fantasy
[BsonIgnore]
public M2M_SendUnitResponse ResponseType { get; set; }
public uint OpCode() { return InnerOpcode.M2M_SendUnitRequest; }
public Unit Unit { get; set; }
}
public partial class M2M_SendUnitResponse : AMessage, IRouteResponse
{

View File

@@ -1,8 +0,0 @@
using Fantasy.Entitas;
namespace Fantasy;
public sealed class Unit : Entity
{
}