快速使用协议
This commit is contained in:
@@ -12,16 +12,21 @@ public sealed class PlayerItemContainerComponent : Entity
|
||||
/// 最大格子数量
|
||||
/// </summary>
|
||||
public int CellCountMax;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 容器内的物品
|
||||
/// </summary>
|
||||
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
|
||||
public Dictionary<long, Item> Items = new Dictionary<long, Item>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 物品绑定信息
|
||||
/// </summary>
|
||||
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
|
||||
public Dictionary<long, List<long>> Binding = new Dictionary<long, List<long>>();
|
||||
|
||||
/// <summary>
|
||||
/// 快速使用插槽
|
||||
/// </summary>
|
||||
public List<long> Slots = new List<long>(9);
|
||||
}
|
||||
@@ -58,6 +58,7 @@ namespace Fantasy
|
||||
ErrorCode = default;
|
||||
Items.Clear();
|
||||
Rigs.Clear();
|
||||
Slots.Clear();
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<Game2C_GetItemsResponse>(this);
|
||||
#endif
|
||||
@@ -68,6 +69,8 @@ namespace Fantasy
|
||||
[ProtoMember(2)]
|
||||
public List<ItemBindInfo> Rigs = new List<ItemBindInfo>();
|
||||
[ProtoMember(3)]
|
||||
public List<long> Slots = new List<long>();
|
||||
[ProtoMember(4)]
|
||||
public uint ErrorCode { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -204,6 +207,61 @@ namespace Fantasy
|
||||
public uint ErrorCode { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// /////////// ******** 快速使用插槽 *******/////////////
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// 请求设置快速使用
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class C2Game_SetSlotRequest : AMessage, ICustomRouteRequest
|
||||
{
|
||||
public static C2Game_SetSlotRequest Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<C2Game_SetSlotRequest>();
|
||||
}
|
||||
public override void Dispose()
|
||||
{
|
||||
Index = default;
|
||||
Id = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2Game_SetSlotRequest>(this);
|
||||
#endif
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public Game2C_SetSlotResponse ResponseType { get; set; }
|
||||
public uint OpCode() { return OuterOpcode.C2Game_SetSlotRequest; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public int Index { get; set; }
|
||||
[ProtoMember(2)]
|
||||
public long Id { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 请求设置快速使用响应
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class Game2C_SetSlotResponse : AMessage, ICustomRouteResponse
|
||||
{
|
||||
public static Game2C_SetSlotResponse Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<Game2C_SetSlotResponse>();
|
||||
}
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
Slots.Clear();
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<Game2C_SetSlotResponse>(this);
|
||||
#endif
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.Game2C_SetSlotResponse; }
|
||||
[ProtoMember(1)]
|
||||
public List<long> Slots = new List<long>();
|
||||
[ProtoMember(2)]
|
||||
public uint ErrorCode { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// /////////// ******** 鱼护 *******/////////////
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
|
||||
@@ -9,15 +9,17 @@ namespace Fantasy
|
||||
public const uint Game2C_ItemChange = 2147493649;
|
||||
public const uint C2Game_RigChangeRequest = 2281711379;
|
||||
public const uint Game2C_RigChangeResponse = 2415929107;
|
||||
public const uint C2Game_GetFishsRequest = 2281711380;
|
||||
public const uint Game2C_GetFishsResponse = 2415929108;
|
||||
public const uint C2Game_SetSlotRequest = 2281711380;
|
||||
public const uint Game2C_SetSlotResponse = 2415929108;
|
||||
public const uint C2Game_GetFishsRequest = 2281711381;
|
||||
public const uint Game2C_GetFishsResponse = 2415929109;
|
||||
public const uint Game2C_FishChange = 2147493650;
|
||||
public const uint C2Game_SellFishRequest = 2281711381;
|
||||
public const uint Game2C_SellFishResponse = 2415929109;
|
||||
public const uint C2Game_BuyRequest = 2281711382;
|
||||
public const uint Game2C_BuyResponse = 2415929110;
|
||||
public const uint C2Map_CreateRoomRequest = 2281711383;
|
||||
public const uint Map2C_CreateRoomResponse = 2415929111;
|
||||
public const uint C2Game_SellFishRequest = 2281711382;
|
||||
public const uint Game2C_SellFishResponse = 2415929110;
|
||||
public const uint C2Game_BuyRequest = 2281711383;
|
||||
public const uint Game2C_BuyResponse = 2415929111;
|
||||
public const uint C2Map_CreateRoomRequest = 2281711384;
|
||||
public const uint Map2C_CreateRoomResponse = 2415929112;
|
||||
public const uint C2G_ExitRoomRequest = 268445457;
|
||||
public const uint G2C_ExitRoomResponse = 402663185;
|
||||
public const uint C2G_EnterMapRequest = 268445458;
|
||||
@@ -28,8 +30,8 @@ namespace Fantasy
|
||||
public const uint C2G_LoginRequest = 268445460;
|
||||
public const uint G2C_LoginResponse = 402663188;
|
||||
public const uint G2C_RepeatLogin = 134227729;
|
||||
public const uint C2Game_GetRoleInfoRequest = 2281711384;
|
||||
public const uint Game2C_GetRoleInfoResponse = 2415929112;
|
||||
public const uint C2Game_GetRoleInfoRequest = 2281711385;
|
||||
public const uint Game2C_GetRoleInfoResponse = 2415929113;
|
||||
public const uint Map2C_RoleEnterRoomNotify = 2147493652;
|
||||
public const uint Map2C_RoleExitRoomNotify = 2147493653;
|
||||
public const uint C2Map_RolePropertyChange = 2147493654;
|
||||
@@ -40,37 +42,37 @@ namespace Fantasy
|
||||
public const uint C2Map_Look = 2147493659;
|
||||
public const uint Map2C_MoveNotify = 2147493660;
|
||||
public const uint Map2C_LookeNotify = 2147493661;
|
||||
public const uint C2S_GetConversationsRequest = 2281711385;
|
||||
public const uint S2C_GetConversationsResponse = 2415929113;
|
||||
public const uint C2S_SendMailRequest = 2281711386;
|
||||
public const uint S2C_SendMailResponse = 2415929114;
|
||||
public const uint C2S_DeleteMailRequest = 2281711387;
|
||||
public const uint S2C_DeleteMailResponse = 2415929115;
|
||||
public const uint C2S_GetConversationsRequest = 2281711386;
|
||||
public const uint S2C_GetConversationsResponse = 2415929114;
|
||||
public const uint C2S_SendMailRequest = 2281711387;
|
||||
public const uint S2C_SendMailResponse = 2415929115;
|
||||
public const uint C2S_DeleteMailRequest = 2281711388;
|
||||
public const uint S2C_DeleteMailResponse = 2415929116;
|
||||
public const uint S2C_HaveMail = 2147493662;
|
||||
public const uint S2C_MailState = 2147493663;
|
||||
public const uint C2S_CreateChannelRequest = 2281711388;
|
||||
public const uint S2C_CreateChannelResponse = 2415929116;
|
||||
public const uint C2S_JoinChannelRequest = 2281711389;
|
||||
public const uint S2C_JoinChannelResponse = 2415929117;
|
||||
public const uint C2S_SendMessageRequest = 2281711390;
|
||||
public const uint S2C_SendMessageResponse = 2415929118;
|
||||
public const uint C2S_CreateChannelRequest = 2281711389;
|
||||
public const uint S2C_CreateChannelResponse = 2415929117;
|
||||
public const uint C2S_JoinChannelRequest = 2281711390;
|
||||
public const uint S2C_JoinChannelResponse = 2415929118;
|
||||
public const uint C2S_SendMessageRequest = 2281711391;
|
||||
public const uint S2C_SendMessageResponse = 2415929119;
|
||||
public const uint S2C_Message = 2147493664;
|
||||
public const uint C2S_CreateClubRequest = 2281711391;
|
||||
public const uint S2C_CreateClubResponse = 2415929119;
|
||||
public const uint C2S_GetClubInfoRequest = 2281711392;
|
||||
public const uint S2C_GetClubInfoResponse = 2415929120;
|
||||
public const uint C2S_GetMemberListRequest = 2281711393;
|
||||
public const uint S2C_GetMemberListResponse = 2415929121;
|
||||
public const uint C2S_GetClubListRequest = 2281711394;
|
||||
public const uint S2C_GetClubListResponse = 2415929122;
|
||||
public const uint C2S_JoinClubRequest = 2281711395;
|
||||
public const uint S2C_JoinClubResponse = 2415929123;
|
||||
public const uint C2S_LeaveClubRequest = 2281711396;
|
||||
public const uint S2C_LeaveClubResponse = 2415929124;
|
||||
public const uint C2S_DissolveClubRequest = 2281711397;
|
||||
public const uint S2C_DissolveClubResponse = 2415929125;
|
||||
public const uint C2S_DisposeJoinRequest = 2281711398;
|
||||
public const uint S2C_DisposeJoinResponse = 2415929126;
|
||||
public const uint C2S_CreateClubRequest = 2281711392;
|
||||
public const uint S2C_CreateClubResponse = 2415929120;
|
||||
public const uint C2S_GetClubInfoRequest = 2281711393;
|
||||
public const uint S2C_GetClubInfoResponse = 2415929121;
|
||||
public const uint C2S_GetMemberListRequest = 2281711394;
|
||||
public const uint S2C_GetMemberListResponse = 2415929122;
|
||||
public const uint C2S_GetClubListRequest = 2281711395;
|
||||
public const uint S2C_GetClubListResponse = 2415929123;
|
||||
public const uint C2S_JoinClubRequest = 2281711396;
|
||||
public const uint S2C_JoinClubResponse = 2415929124;
|
||||
public const uint C2S_LeaveClubRequest = 2281711397;
|
||||
public const uint S2C_LeaveClubResponse = 2415929125;
|
||||
public const uint C2S_DissolveClubRequest = 2281711398;
|
||||
public const uint S2C_DissolveClubResponse = 2415929126;
|
||||
public const uint C2S_DisposeJoinRequest = 2281711399;
|
||||
public const uint S2C_DisposeJoinResponse = 2415929127;
|
||||
public const uint S2C_ClubChange = 2147493665;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class C2Game_GetItemsRequestHandler : RouteRPC<Player, C2Game_GetItemsReq
|
||||
var itemContainer = entity.GetComponent<PlayerItemContainerComponent>();
|
||||
response.Items = itemContainer.GetItemInfos();
|
||||
response.Rigs = itemContainer.GetRigInfos();
|
||||
response.Slots = itemContainer.Slots;
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
43
Hotfix/Game/Handler/C2Game_SetSlotRequestHandler.cs
Normal file
43
Hotfix/Game/Handler/C2Game_SetSlotRequestHandler.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Game;
|
||||
|
||||
public class C2Game_SetSlotRequestHandler : RouteRPC<Player, C2Game_SetSlotRequest, Game2C_SetSlotResponse>
|
||||
{
|
||||
protected override async FTask Run(Player entity, C2Game_SetSlotRequest request, Game2C_SetSlotResponse response,
|
||||
Action reply)
|
||||
{
|
||||
var itemContainer = entity.GetComponent<PlayerItemContainerComponent>();
|
||||
if (itemContainer == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrArgs;
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.Index < 0 || request.Index >= itemContainer.Slots.Count)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrArgs;
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.Id > 0)
|
||||
{
|
||||
if (!itemContainer.Items.TryGetValue(request.Id, out var item))
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrArgs;
|
||||
return;
|
||||
}
|
||||
|
||||
itemContainer.Slots[request.Index] = request.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemContainer.Slots[request.Index] = 0;
|
||||
}
|
||||
|
||||
await itemContainer.Save();
|
||||
response.Slots = itemContainer.Slots;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,30 @@ public sealed class ItemContainerDestroySystem : DestroySystem<PlayerItemContain
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ItemContainerAwakeSystem : AwakeSystem<PlayerItemContainerComponent>
|
||||
{
|
||||
protected override void Awake(PlayerItemContainerComponent self)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ItemContainerAwakeSystem1 : DeserializeSystem<PlayerItemContainerComponent>
|
||||
{
|
||||
protected override void Deserialize(PlayerItemContainerComponent self)
|
||||
{
|
||||
if (self.Slots.Count < 9)
|
||||
{
|
||||
var add = 9 - self.Slots.Count;
|
||||
for (int i = 0; i < add; i++)
|
||||
{
|
||||
self.Slots.Add(0);
|
||||
}
|
||||
|
||||
// _ = self.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerItemContainerComponentSystem
|
||||
{
|
||||
#region Save
|
||||
@@ -65,47 +89,8 @@ public static class PlayerItemContainerComponentSystem
|
||||
|
||||
item = null;
|
||||
return false;
|
||||
// if (!self.ItemsByConfigId.TryGetValue(configId, out var itemList))
|
||||
// {
|
||||
// item = null;
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// item = itemList.First();
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// 通过配置id获取物品
|
||||
// /// </summary>
|
||||
// /// <param name="self"></param>
|
||||
// /// <param name="configId"></param>
|
||||
// /// <param name="items"></param>
|
||||
// public static void GetItemByConfigId(this ItemContainer self, uint configId, List<Item> items)
|
||||
// {
|
||||
// if (!self.ItemsByConfigId.TryGetValue(configId, out var itemList))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// items.AddRange(itemList);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 通过类型获取物品
|
||||
// /// </summary>
|
||||
// /// <param name="self"></param>
|
||||
// /// <param name="type"></param>
|
||||
// /// <param name="items"></param>
|
||||
// public static void GetItemByType(this ItemContainer self, ItemType type, List<Item> items)
|
||||
// {
|
||||
// if (!self.ItemsByType.TryGetValue((uint)type, out var itemList))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// items.AddRange(itemList);
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Add
|
||||
@@ -146,22 +131,6 @@ public static class PlayerItemContainerComponentSystem
|
||||
return ret;
|
||||
}
|
||||
|
||||
// public static List<GearInfo> GetGearInfos(this PlayerItemContainerComponent self)
|
||||
// {
|
||||
// List<GearInfo> ret = new List<GearInfo>(self.FishingRig.Count);
|
||||
//
|
||||
// foreach (var (rod, rigs) in self.FishingRig)
|
||||
// {
|
||||
// GearInfo gearInfo = new GearInfo();
|
||||
// gearInfo.Rod = rod;
|
||||
// gearInfo.Rigs.AddRange(rigs);
|
||||
// ret.Add(gearInfo);
|
||||
// }
|
||||
//
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
|
||||
public static ItemBindInfo GetRigInfo(this PlayerItemContainerComponent self, long id)
|
||||
{
|
||||
if (self.Binding.TryGetValue(id, out var info))
|
||||
|
||||
@@ -2,5 +2,8 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAssemblyHelper_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3cbbaf32e578423d8d0163d75da8233f87e00_003F76_003Ff4d4d636_003FAssemblyHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAssemblyLoadContext_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb241c378a97f4447a2e6baf64e656013e8e910_003F96_003Fd3906b05_003FAssemblyLoadContext_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAssembly_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb241c378a97f4447a2e6baf64e656013e8e910_003F9f_003Fab186807_003FAssembly_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAwakeSystem_00601_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3cbbaf32e578423d8d0163d75da8233f87e00_003Fd6_003F72740830_003FAwakeSystem_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADestroySystem_00601_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3cbbaf32e578423d8d0163d75da8233f87e00_003Fbd_003Fcd9cb7f1_003FDestroySystem_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADictionary_00602_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F76803a04e31b4fee99d90bcbfc5a6bdde8e930_003F33_003F170c5f2b_003FDictionary_00602_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AScene_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3cbbaf32e578423d8d0163d75da8233f87e00_003F6a_003F5adfe93e_003FScene_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AWorld_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3cbbaf32e578423d8d0163d75da8233f87e00_003F4f_003F90b7c061_003FWorld_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
||||
@@ -14,6 +14,7 @@ message Game2C_GetItemsResponse // ICustomRouteResponse
|
||||
{
|
||||
repeated ItemInfo Items = 1; //物品信息
|
||||
repeated ItemBindInfo Rigs = 2; //钓组信息
|
||||
repeated int64 Slots = 3; //快速使用插槽
|
||||
}
|
||||
|
||||
///请求使用物品
|
||||
@@ -53,6 +54,21 @@ message Game2C_RigChangeResponse // ICustomRouteResponse
|
||||
}
|
||||
|
||||
|
||||
////////////// ******** 快速使用插槽 *******/////////////
|
||||
///请求设置快速使用
|
||||
message C2Game_SetSlotRequest // ICustomRouteRequest,Game2C_SetSlotResponse,GameRoute
|
||||
{
|
||||
int32 Index = 1;//插槽位置
|
||||
int64 Id = 2;//快速使用物品
|
||||
}
|
||||
|
||||
///请求设置快速使用响应
|
||||
message Game2C_SetSlotResponse // ICustomRouteResponse
|
||||
{
|
||||
repeated int64 Slots = 1; //快速使用插槽
|
||||
}
|
||||
|
||||
|
||||
////////////// ******** 鱼护 *******/////////////
|
||||
|
||||
///请求鱼护列表
|
||||
|
||||
Reference in New Issue
Block a user