From dd3a2208734d71964ee570ef692bfdf719b6ff84 Mon Sep 17 00:00:00 2001 From: wserver/wangdisen <1065498738@qq.com> Date: Tue, 23 Aug 2022 16:38:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B0=8F=E5=B1=8B=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=86=9C=E5=9C=BA=E5=88=97=E8=A1=A8=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Proto/OuterMessage.proto | 17 +++++++ .../C2M_CabinUpdateFarmlandsHandler.cs | 36 +++++++++++++ Server/Hotfix/Server.Hotfix.csproj | 3 ++ Server/Model/Generate/Message/OuterMessage.cs | 31 +++++++++++ Server/Model/Generate/Message/OuterOpcode.cs | 2 + Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs | 51 +++++++++++++------ .../Codes/Hotfix/Demo/Operate/CabinOperate.cs | 27 +++++++++- .../Model/Generate/Message/OuterMessage.cs | 31 +++++++++++ .../Model/Generate/Message/OuterOpcode.cs | 2 + 9 files changed, 182 insertions(+), 18 deletions(-) create mode 100644 Server/Hotfix/Demo/Cabin/Handler/C2M_CabinUpdateFarmlandsHandler.cs diff --git a/Proto/OuterMessage.proto b/Proto/OuterMessage.proto index 61197ef..1696269 100644 --- a/Proto/OuterMessage.proto +++ b/Proto/OuterMessage.proto @@ -1411,3 +1411,20 @@ message M2C_CabinSeed // IActorLocationResponse string Message = 92; } + +//ResponseType M2C_CabinUpdateFarmlands +message C2M_CabinUpdateFarmlands // IActorLocationRequest +{ + int32 RpcId = 90; + repeated int64 FarmlandIds = 1; + long CabinId = 2; +} + +message M2C_CabinUpdateFarmlands // IActorLocationResponse +{ + int32 RpcId = 90; + int32 Error = 91; + string Message = 92; + +} + diff --git a/Server/Hotfix/Demo/Cabin/Handler/C2M_CabinUpdateFarmlandsHandler.cs b/Server/Hotfix/Demo/Cabin/Handler/C2M_CabinUpdateFarmlandsHandler.cs new file mode 100644 index 0000000..c11d566 --- /dev/null +++ b/Server/Hotfix/Demo/Cabin/Handler/C2M_CabinUpdateFarmlandsHandler.cs @@ -0,0 +1,36 @@ +using System; + +namespace ET +{ + + + public class C2M_CabinUpdateFarmlandsHandler: AMActorLocationRpcHandler + { + protected async override ETTask Run(Unit unit, C2M_CabinUpdateFarmlands request, M2C_CabinUpdateFarmlands response, Action reply) + { + try + { + var cabin = unit.GetGrandChild(request.CabinId); + if (cabin == null) + { + response.Error = ErrorCode.ERR_CabinNotFound; + } + else + { + CabinOperate.CabinUpdateFarmlands(unit,cabin,request.FarmlandIds); + response.Error = ErrorCode.ERR_Success; + } + + reply(); + } + catch (Exception e) + { + response.Message = e.ToString(); + response.Error = ErrorCode.ERR_OperateFail; + reply(); + } + + await ETTask.CompletedTask; + } + } +} \ No newline at end of file diff --git a/Server/Hotfix/Server.Hotfix.csproj b/Server/Hotfix/Server.Hotfix.csproj index cd16d06..a870a99 100644 --- a/Server/Hotfix/Server.Hotfix.csproj +++ b/Server/Hotfix/Server.Hotfix.csproj @@ -85,6 +85,9 @@ Demo\Menu\MenuSystem.cs + + Demo\Operate\CabinOperate.cs + Demo\Operate\ConstructOperate.cs diff --git a/Server/Model/Generate/Message/OuterMessage.cs b/Server/Model/Generate/Message/OuterMessage.cs index 2790caf..dfd9358 100644 --- a/Server/Model/Generate/Message/OuterMessage.cs +++ b/Server/Model/Generate/Message/OuterMessage.cs @@ -2937,4 +2937,35 @@ namespace ET } + [ResponseType(nameof(M2C_CabinUpdateFarmlands))] + [Message(OuterOpcode.C2M_CabinUpdateFarmlands)] + [ProtoContract] + public partial class C2M_CabinUpdateFarmlands: Object, IActorLocationRequest + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(1)] + public List FarmlandIds = new List(); + + [ProtoMember(2)] + public long CabinId { get; set; } + + } + + [Message(OuterOpcode.M2C_CabinUpdateFarmlands)] + [ProtoContract] + public partial class M2C_CabinUpdateFarmlands: Object, IActorLocationResponse + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(91)] + public int Error { get; set; } + + [ProtoMember(92)] + public string Message { get; set; } + + } + } diff --git a/Server/Model/Generate/Message/OuterOpcode.cs b/Server/Model/Generate/Message/OuterOpcode.cs index 5d81e7c..90191d7 100644 --- a/Server/Model/Generate/Message/OuterOpcode.cs +++ b/Server/Model/Generate/Message/OuterOpcode.cs @@ -175,5 +175,7 @@ namespace ET public const ushort M2C_CabinAddFarmland = 10172; public const ushort C2M_CabinSeed = 10173; public const ushort M2C_CabinSeed = 10174; + public const ushort C2M_CabinUpdateFarmlands = 10175; + public const ushort M2C_CabinUpdateFarmlands = 10176; } } diff --git a/Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs b/Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs index 7dd43e6..879f2e8 100644 --- a/Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs +++ b/Unity/Codes/Hotfix/Demo/Helper/CabinHelper.cs @@ -5,11 +5,11 @@ namespace ET { public static class CabinHelper { - public static async ETTask GoCabin(Unit unit,People people,Cabin cabin) + public static async ETTask GoCabin(Unit unit, People people, Cabin cabin) { try { - C2M_GoCabin msg = new C2M_GoCabin() { PeopleId = people.Id,CabinId = cabin.Id}; + C2M_GoCabin msg = new C2M_GoCabin() { PeopleId = people.Id, CabinId = cabin.Id }; M2C_GoCabin resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_GoCabin; if (resp.Error == ErrorCode.ERR_Success) { @@ -29,12 +29,12 @@ namespace ET throw; } } - - public static async ETTask ArriveCabin(Unit unit,People people,Cabin cabin) + + public static async ETTask ArriveCabin(Unit unit, People people, Cabin cabin) { try { - C2M_ArriveCabin msg = new C2M_ArriveCabin() { PeopleId = people.Id,CabinId = cabin.Id}; + C2M_ArriveCabin msg = new C2M_ArriveCabin() { PeopleId = people.Id, CabinId = cabin.Id }; M2C_ArriveCabin resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_ArriveCabin; if (resp.Error == ErrorCode.ERR_Success) { @@ -53,14 +53,13 @@ namespace ET Log.Error(e.ToString()); throw; } - - } - public static async ETTask AddFarmland(Unit unit,Cabin cabin,List farmlandIds) + + public static async ETTask AddFarmland(Unit unit, Cabin cabin, List farmlandIds) { try { - C2M_CabinAddFarmland msg = new C2M_CabinAddFarmland() { CabinId = cabin.Id,FarmlandIds = farmlandIds}; + C2M_CabinAddFarmland msg = new C2M_CabinAddFarmland() { CabinId = cabin.Id, FarmlandIds = farmlandIds }; M2C_CabinAddFarmland resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_CabinAddFarmland; foreach (var v in resp.FarmlandIds) { @@ -69,12 +68,8 @@ namespace ET if (farmland != null) { farmland.SetCabinId(cabin.Id); - } } - - - return resp.Error; } @@ -84,12 +79,12 @@ namespace ET throw; } } - - public static async ETTask CabinSeed(Unit unit,Farmland farmland,int cropCfgId) + + public static async ETTask CabinSeed(Unit unit, Farmland farmland, int cropCfgId) { try { - C2M_CabinSeed msg = new C2M_CabinSeed() { CropCfgId = cropCfgId,FarmlandId = farmland.Id}; + C2M_CabinSeed msg = new C2M_CabinSeed() { CropCfgId = cropCfgId, FarmlandId = farmland.Id }; M2C_CabinSeed resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_CabinSeed; if (resp.Error == ErrorCode.ERR_Success) { @@ -108,5 +103,29 @@ namespace ET throw; } } + + public static async ETTask CabinUpdateFarmlands(Unit unit, Cabin cabin, ListfarmlandIds) + { + try + { + C2M_CabinUpdateFarmlands msg = new C2M_CabinUpdateFarmlands() { CabinId = cabin.Id, FarmlandIds = farmlandIds }; + M2C_CabinUpdateFarmlands resp = await unit.ZoneScene().GetComponent().Session.Call(msg) as M2C_CabinUpdateFarmlands; + if (resp.Error == ErrorCode.ERR_Success) + { + CabinOperate.CabinUpdateFarmlands(unit,cabin,farmlandIds); + } + else + { + Log.Error(resp.Error.ToString()); + } + + return resp.Error; + } + catch (Exception e) + { + Log.Error(e.ToString()); + throw; + } + } } } \ No newline at end of file diff --git a/Unity/Codes/Hotfix/Demo/Operate/CabinOperate.cs b/Unity/Codes/Hotfix/Demo/Operate/CabinOperate.cs index ca9b9c7..522ca4c 100644 --- a/Unity/Codes/Hotfix/Demo/Operate/CabinOperate.cs +++ b/Unity/Codes/Hotfix/Demo/Operate/CabinOperate.cs @@ -1,9 +1,32 @@ -namespace ET +using System.Collections.Generic; + +namespace ET { [FriendClass(typeof(People))] [FriendClass(typeof(Cabin))] public static class CabinOperate { - + public static void CabinUpdateFarmlands(Unit unit,Cabin cabin, List farmlandIds) + { + foreach (var v in cabin.FarmlandIds) + { + var farmland = unit.GetGrandChild(v); + if (farmland != null) + { + farmland.SetCabinId(0); + } + } + + foreach (var v in farmlandIds) + { + var farmland = unit.GetGrandChild(v); + if (farmland != null) + { + farmland.SetCabinId(cabin.Id); + } + } + + cabin.FarmlandIds = farmlandIds; + } } } \ No newline at end of file diff --git a/Unity/Codes/Model/Generate/Message/OuterMessage.cs b/Unity/Codes/Model/Generate/Message/OuterMessage.cs index 2790caf..dfd9358 100644 --- a/Unity/Codes/Model/Generate/Message/OuterMessage.cs +++ b/Unity/Codes/Model/Generate/Message/OuterMessage.cs @@ -2937,4 +2937,35 @@ namespace ET } + [ResponseType(nameof(M2C_CabinUpdateFarmlands))] + [Message(OuterOpcode.C2M_CabinUpdateFarmlands)] + [ProtoContract] + public partial class C2M_CabinUpdateFarmlands: Object, IActorLocationRequest + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(1)] + public List FarmlandIds = new List(); + + [ProtoMember(2)] + public long CabinId { get; set; } + + } + + [Message(OuterOpcode.M2C_CabinUpdateFarmlands)] + [ProtoContract] + public partial class M2C_CabinUpdateFarmlands: Object, IActorLocationResponse + { + [ProtoMember(90)] + public int RpcId { get; set; } + + [ProtoMember(91)] + public int Error { get; set; } + + [ProtoMember(92)] + public string Message { get; set; } + + } + } diff --git a/Unity/Codes/Model/Generate/Message/OuterOpcode.cs b/Unity/Codes/Model/Generate/Message/OuterOpcode.cs index 5d81e7c..90191d7 100644 --- a/Unity/Codes/Model/Generate/Message/OuterOpcode.cs +++ b/Unity/Codes/Model/Generate/Message/OuterOpcode.cs @@ -175,5 +175,7 @@ namespace ET public const ushort M2C_CabinAddFarmland = 10172; public const ushort C2M_CabinSeed = 10173; public const ushort M2C_CabinSeed = 10174; + public const ushort C2M_CabinUpdateFarmlands = 10175; + public const ushort M2C_CabinUpdateFarmlands = 10176; } }