Эх сурвалжийг харах

客户端hotfix层Proto2CS生成嵌套结构需要增加TypeName字段

tanghai 7 жил өмнө
parent
commit
094eae93c4

+ 1 - 1
Client-Server.sln.DotSettings.user

@@ -12,7 +12,7 @@
 	<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EnforceWhileStatementBraces/@EntryIndexedValue">HINT</s:String>
 	<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Unity/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Unity"&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;DISABLED&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;IMPLICIT_WHEN_INITIALIZER_HAS_TYPE&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;IMPLICIT_EXCEPT_SIMPLE_TYPES&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSMakeAutoPropertyGetOnly&gt;True&lt;/CSMakeAutoPropertyGetOnly&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;RemoveCodeRedundancies&gt;True&lt;/RemoveCodeRedundancies&gt;&lt;CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeArgumentsStyle="True" ArrangeCodeBodyStyle="True" /&gt;&lt;/Profile&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">Unity</s:String>
-	<s:String x:Key="/Default/Housekeeping/Layout/DialogWindows/RefactoringWizardWindow/Location/@EntryValue">-41,-251</s:String>
+	<s:String x:Key="/Default/Housekeeping/Layout/DialogWindows/RefactoringWizardWindow/Location/@EntryValue">-164,-76</s:String>
 	<s:Int64 x:Key="/Default/Environment/SearchAndNavigation/DefaultOccurrencesGroupingIndex/@EntryValue">0</s:Int64>
 	<s:String x:Key="/Default/Profiling/Configurations/=1/@EntryIndexedValue">&lt;data&gt;&lt;HostParameters type="LocalHostParameters" /&gt;&lt;Argument type="StandaloneArgument"&gt;&lt;Arguments IsNull="False"&gt;&lt;/Arguments&gt;&lt;FileName IsNull="False"&gt;&lt;/FileName&gt;&lt;WorkingDirectory IsNull="False"&gt;&lt;/WorkingDirectory&gt;&lt;Scope&gt;&lt;ProcessFilters /&gt;&lt;/Scope&gt;&lt;/Argument&gt;&lt;Info type="TimelineInfo" /&gt;&lt;HostOptions type="HostOptions"&gt;&lt;HostTempPath IsNull="False"&gt;&lt;/HostTempPath&gt;&lt;/HostOptions&gt;&lt;/data&gt;</s:String>
 	</wpf:ResourceDictionary>

+ 13 - 0
Proto/HotfixMessage.proto

@@ -33,4 +33,17 @@ message C2M_TestActorRequest // IActorRequest
 message M2C_TestActorResponse // IActorResponse
 {
 	required string Info = 1;
+}
+
+message PlayerInfo // IMessage
+{
+}
+
+message C2G_PlayerInfo // IRequest
+{
+}
+
+message G2C_PlayerInfo // IResponse
+{
+	repeated PlayerInfo PlayerInfos = 1;
 }

+ 125 - 0
Server/Model/Module/Message/HotfixMessage.cs

@@ -0,0 +1,125 @@
+using ProtoBuf;
+using ETModel;
+using System.Collections.Generic;
+using MongoDB.Bson.Serialization.Attributes;
+namespace ETModel
+{
+	[Message(HotfixOpcode.C2R_Login)]
+	[ProtoContract]
+	public partial class C2R_Login: IRequest
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public string Account;
+
+		[ProtoMember(2, IsRequired = true)]
+		public string Password;
+
+	}
+
+	[Message(HotfixOpcode.R2C_Login)]
+	[ProtoContract]
+	public partial class R2C_Login: IResponse
+	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+		[ProtoMember(1, IsRequired = true)]
+		public string Address;
+
+		[ProtoMember(2, IsRequired = true)]
+		public long Key;
+
+	}
+
+	[Message(HotfixOpcode.C2G_LoginGate)]
+	[ProtoContract]
+	public partial class C2G_LoginGate: IRequest
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public long Key;
+
+	}
+
+	[Message(HotfixOpcode.G2C_LoginGate)]
+	[ProtoContract]
+	public partial class G2C_LoginGate: IResponse
+	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+		[ProtoMember(1, IsRequired = true)]
+		public long PlayerId;
+
+	}
+
+	[Message(HotfixOpcode.G2C_TestHotfixMessage)]
+	[ProtoContract]
+	public partial class G2C_TestHotfixMessage: IMessage
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public string Info;
+
+	}
+
+	[Message(HotfixOpcode.C2M_TestActorRequest)]
+	[ProtoContract]
+	public partial class C2M_TestActorRequest: MessageObject, IActorRequest
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public string Info;
+
+	}
+
+	[Message(HotfixOpcode.M2C_TestActorResponse)]
+	[ProtoContract]
+	public partial class M2C_TestActorResponse: MessageObject, IActorResponse
+	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+		[ProtoMember(1, IsRequired = true)]
+		public string Info;
+
+	}
+
+	[Message(HotfixOpcode.PlayerInfo)]
+	[ProtoContract]
+	public partial class PlayerInfo: IMessage
+	{
+	}
+
+	[Message(HotfixOpcode.C2G_PlayerInfo)]
+	[ProtoContract]
+	public partial class C2G_PlayerInfo: IRequest
+	{
+	}
+
+	[Message(HotfixOpcode.G2C_PlayerInfo)]
+	[ProtoContract]
+	public partial class G2C_PlayerInfo: IResponse
+	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+		[ProtoMember(1)]
+		public List<PlayerInfo> PlayerInfos = new List<PlayerInfo>();
+
+	}
+
+}
+namespace ETModel
+{
+	[BsonKnownTypes(typeof(C2M_TestActorRequest))]
+	[BsonKnownTypes(typeof(M2C_TestActorResponse))]
+	public partial class MessageObject {}
+
+}
+namespace ETModel
+{
+	public partial class MessageObject {}
+
+}

+ 16 - 0
Server/Model/Module/Message/HotfixOpcode.cs

@@ -0,0 +1,16 @@
+namespace ETModel
+{
+	public static partial class HotfixOpcode
+	{
+		 public const ushort C2R_Login = 10001;
+		 public const ushort R2C_Login = 10002;
+		 public const ushort C2G_LoginGate = 10003;
+		 public const ushort G2C_LoginGate = 10004;
+		 public const ushort G2C_TestHotfixMessage = 10005;
+		 public const ushort C2M_TestActorRequest = 10006;
+		 public const ushort M2C_TestActorResponse = 10007;
+		 public const ushort PlayerInfo = 10008;
+		 public const ushort C2G_PlayerInfo = 10009;
+		 public const ushort G2C_PlayerInfo = 10010;
+	}
+}

+ 0 - 2
Server/Model/Module/Message/InnerMessage.cs

@@ -384,11 +384,9 @@ namespace ETModel
 	}
 
 }
-#if SERVER
 namespace ETModel
 {
 }
-#endif
 namespace ETModel
 {
 }

+ 188 - 0
Server/Model/Module/Message/OuterMessage.cs

@@ -0,0 +1,188 @@
+using ProtoBuf;
+using ETModel;
+using System.Collections.Generic;
+using MongoDB.Bson.Serialization.Attributes;
+namespace ETModel
+{
+	[Message(OuterOpcode.Actor_Test)]
+	[ProtoContract]
+	public partial class Actor_Test: MessageObject, IActorMessage
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public string Info;
+
+	}
+
+	[Message(OuterOpcode.Actor_TestRequest)]
+	[ProtoContract]
+	public partial class Actor_TestRequest: MessageObject, IActorRequest
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public string request;
+
+	}
+
+	[Message(OuterOpcode.Actor_TestResponse)]
+	[ProtoContract]
+	public partial class Actor_TestResponse: MessageObject, IActorResponse
+	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+		[ProtoMember(1, IsRequired = true)]
+		public string response;
+
+	}
+
+	[Message(OuterOpcode.Actor_TransferRequest)]
+	[ProtoContract]
+	public partial class Actor_TransferRequest: MessageObject, IActorRequest
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public int MapIndex;
+
+	}
+
+	[Message(OuterOpcode.Actor_TransferResponse)]
+	[ProtoContract]
+	public partial class Actor_TransferResponse: MessageObject, IActorResponse
+	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+	}
+
+	[Message(OuterOpcode.C2G_EnterMap)]
+	[ProtoContract]
+	public partial class C2G_EnterMap: IRequest
+	{
+	}
+
+	[Message(OuterOpcode.G2C_EnterMap)]
+	[ProtoContract]
+	public partial class G2C_EnterMap: IResponse
+	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+		[ProtoMember(1, IsRequired = true)]
+		public long UnitId;
+
+		[ProtoMember(2, IsRequired = true)]
+		public int Count;
+
+	}
+
+	[Message(OuterOpcode.UnitInfo)]
+	[ProtoContract]
+	public partial class UnitInfo
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public long UnitId;
+
+		[ProtoMember(2, IsRequired = true)]
+		public int X;
+
+		[ProtoMember(3, IsRequired = true)]
+		public int Z;
+
+	}
+
+	[Message(OuterOpcode.Actor_CreateUnits)]
+	[ProtoContract]
+	public partial class Actor_CreateUnits: MessageObject, IActorMessage
+	{
+		[ProtoMember(1)]
+		public List<UnitInfo> Units = new List<UnitInfo>();
+
+	}
+
+	[Message(OuterOpcode.FrameMessageInfo)]
+	[ProtoContract]
+	public partial class FrameMessageInfo
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public long Id;
+
+		[ProtoMember(2, IsRequired = true)]
+		public MessageObject Message;
+
+	}
+
+	[Message(OuterOpcode.Frame_ClickMap)]
+	[ProtoContract]
+	public partial class Frame_ClickMap: MessageObject, IFrameMessage
+	{
+		[ProtoMember(92, IsRequired = true)]
+		public long Id { get; set; }
+		[ProtoMember(1, IsRequired = true)]
+		public int X;
+
+		[ProtoMember(2, IsRequired = true)]
+		public int Z;
+
+	}
+
+	[Message(OuterOpcode.C2M_Reload)]
+	[ProtoContract]
+	public partial class C2M_Reload: IRequest
+	{
+		[ProtoMember(1, IsRequired = true)]
+		public AppType AppType;
+
+	}
+
+	[Message(OuterOpcode.M2C_Reload)]
+	[ProtoContract]
+	public partial class M2C_Reload: IResponse
+	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+	}
+
+	[Message(OuterOpcode.C2R_Ping)]
+	[ProtoContract]
+	public partial class C2R_Ping: IRequest
+	{
+	}
+
+	[Message(OuterOpcode.R2C_Ping)]
+	[ProtoContract]
+	public partial class R2C_Ping: IResponse
+	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+	}
+
+}
+namespace ETModel
+{
+	[BsonKnownTypes(typeof(Actor_Test))]
+	[BsonKnownTypes(typeof(Actor_TestRequest))]
+	[BsonKnownTypes(typeof(Actor_TestResponse))]
+	[BsonKnownTypes(typeof(Actor_TransferRequest))]
+	[BsonKnownTypes(typeof(Actor_TransferResponse))]
+	[BsonKnownTypes(typeof(Actor_CreateUnits))]
+	[BsonKnownTypes(typeof(Frame_ClickMap))]
+	public partial class MessageObject {}
+
+}
+namespace ETModel
+{
+	[ProtoInclude(OuterOpcode.Actor_Test, typeof(Actor_Test))]
+	[ProtoInclude(OuterOpcode.Actor_TestRequest, typeof(Actor_TestRequest))]
+	[ProtoInclude(OuterOpcode.Actor_TestResponse, typeof(Actor_TestResponse))]
+	[ProtoInclude(OuterOpcode.Actor_TransferRequest, typeof(Actor_TransferRequest))]
+	[ProtoInclude(OuterOpcode.Actor_TransferResponse, typeof(Actor_TransferResponse))]
+	[ProtoInclude(OuterOpcode.Actor_CreateUnits, typeof(Actor_CreateUnits))]
+	[ProtoInclude(OuterOpcode.Frame_ClickMap, typeof(Frame_ClickMap))]
+	public partial class MessageObject {}
+
+}

+ 21 - 0
Server/Model/Module/Message/OuterOpcode.cs

@@ -0,0 +1,21 @@
+namespace ETModel
+{
+	public static partial class OuterOpcode
+	{
+		 public const ushort Actor_Test = 101;
+		 public const ushort Actor_TestRequest = 102;
+		 public const ushort Actor_TestResponse = 103;
+		 public const ushort Actor_TransferRequest = 104;
+		 public const ushort Actor_TransferResponse = 105;
+		 public const ushort C2G_EnterMap = 106;
+		 public const ushort G2C_EnterMap = 107;
+		 public const ushort UnitInfo = 108;
+		 public const ushort Actor_CreateUnits = 109;
+		 public const ushort FrameMessageInfo = 110;
+		 public const ushort Frame_ClickMap = 111;
+		 public const ushort C2M_Reload = 112;
+		 public const ushort M2C_Reload = 113;
+		 public const ushort C2R_Ping = 114;
+		 public const ushort R2C_Ping = 115;
+	}
+}

+ 0 - 4
Server/Model/Server.Model.csproj

@@ -94,8 +94,6 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\Network\TCP\TService.cs" Link="Module\Message\Network\TCP\TService.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\Opcode.cs" Link="Module\Message\Opcode.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\OpcodeTypeComponent.cs" Link="Module\Message\OpcodeTypeComponent.cs" />
-    <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\OuterMessage.cs" Link="Module\Message\OuterMessage.cs" />
-    <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\OuterOpcode.cs" Link="Module\Message\OuterOpcode.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\ProtobufPacker.cs" Link="Module\Message\ProtobufPacker.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\RpcException.cs" Link="Module\Message\RpcException.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Message\Session.cs" Link="Module\Message\Session.cs" />
@@ -106,8 +104,6 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Numeric\NumericWatcherAttribute.cs" Link="Module\Numeric\NumericWatcherAttribute.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Module\Numeric\NumericWatcherComponent.cs" Link="Module\Numeric\NumericWatcherComponent.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Other\AppType.cs" Link="Other\AppType.cs" />
-    <Compile Include="..\..\Unity\Hotfix\Module\Message\HotfixMessage.cs" Link="Module\Message\HotfixMessage.cs" />
-    <Compile Include="..\..\Unity\Hotfix\Module\Message\HotfixOpcode.cs" Link="Module\Message\HotfixOpcode.cs" />
   </ItemGroup>
 
   <ItemGroup>

+ 36 - 39
Unity/Assets/Editor/Proto2CsEditor/Proto2CSEditor.cs

@@ -23,9 +23,9 @@ namespace MyEditor
 	public class Proto2CSEditor : EditorWindow
 	{
 		private const string protoPath = @"..\Proto\";
-		private const string innerOutPath = @"..\Server\Model\Module\Message\";
-		private const string outerOutPath = @"Assets\Scripts\Module\Message\";
-		private const string hotfixOutPath = @"Hotfix\Module\Message\";
+		private const string serverMessagePath = @"..\Server\Model\Module\Message\";
+		private const string clientMessagePath = @"Assets\Scripts\Module\Message\";
+		private const string hotfixMessagePath = @"Hotfix\Module\Message\";
 		private static readonly char[] splitChars = { ' ', '\t' };
 		private static readonly List<OpcodeInfo> msgOpcode = new List<OpcodeInfo>();
 		private static MultiMap<string, string> parentMsg = new MultiMap<string, string>();
@@ -34,21 +34,28 @@ namespace MyEditor
 		public static void AllProto2CS()
 		{
 			msgOpcode.Clear();
-			Proto2CS("ETModel", "OuterMessage.proto", outerOutPath, "OuterOpcode", 100, HeadFlag.Proto | HeadFlag.Bson);
-			GenerateOpcode("OuterOpcode", outerOutPath);
+			Proto2CS("ETModel", "OuterMessage.proto", clientMessagePath, "OuterOpcode", 100, HeadFlag.Proto | HeadFlag.Bson);
+			GenerateOpcode("OuterOpcode", clientMessagePath);
+
+			Proto2CS("ETModel", "OuterMessage.proto", serverMessagePath, "OuterOpcode", 100, HeadFlag.Proto | HeadFlag.Bson, false);
+			GenerateOpcode("OuterOpcode", serverMessagePath);
 
 			msgOpcode.Clear();
-			Proto2CS("ETModel", "InnerMessage.proto", innerOutPath, "InnerOpcode", 1000, HeadFlag.Bson);
-			GenerateOpcode("InnerOpcode", innerOutPath);
+			Proto2CS("ETHotfix", "HotfixMessage.proto", hotfixMessagePath, "HotfixOpcode", 10000, HeadFlag.Bson);
+			GenerateOpcode("HotfixOpcode", hotfixMessagePath);
 
 			msgOpcode.Clear();
-			Proto2CS("ETHotfix", "HotfixMessage.proto", hotfixOutPath, "HotfixOpcode", 10000, HeadFlag.Bson);
-			GenerateOpcode("HotfixOpcode", hotfixOutPath);
-			
+			Proto2CS("ETModel", "HotfixMessage.proto", serverMessagePath, "HotfixOpcode", 10000, HeadFlag.Bson, false);
+			GenerateOpcode("HotfixOpcode", serverMessagePath);
+
+			msgOpcode.Clear();
+			Proto2CS("ETModel", "InnerMessage.proto", serverMessagePath, "InnerOpcode", 1000, HeadFlag.Bson, false);
+			GenerateOpcode("InnerOpcode", serverMessagePath);
+
 			AssetDatabase.Refresh();
 		}
 		
-		public static void Proto2CS(string ns, string protoName, string outputPath, string opcodeClassName, int startOpcode, HeadFlag flag)
+		public static void Proto2CS(string ns, string protoName, string outputPath, string opcodeClassName, int startOpcode, HeadFlag flag, bool isClient = true)
 		{
 			msgOpcode.Clear();
 			parentMsg = new MultiMap<string, string>();
@@ -60,11 +67,6 @@ namespace MyEditor
 			StringBuilder sb = new StringBuilder();
 			sb.Append("using ProtoBuf;\n");
 			sb.Append("using ETModel;\n");
-			if (ns == "ETHotfix")
-			{
-				sb.Append("using ETHotfix;\n");
-			}
-
 			sb.Append("using System.Collections.Generic;\n");
 			sb.Append("using MongoDB.Bson.Serialization.Attributes;\n");
 			sb.Append($"namespace {ns}\n");
@@ -150,7 +152,7 @@ namespace MyEditor
 
 				if (newline.StartsWith("repeated"))
 				{
-					Repeated(sb, newline);
+					Repeated(sb, ns, newline, isClient);
 				}
 
 				if (isMsgStart && newline == "}")
@@ -161,15 +163,18 @@ namespace MyEditor
 			}
 			sb.Append("}\n");
 
-			GenerateHead(sb, flag, opcodeClassName);
+			if (!isClient)
+			{
+				GenerateHead(sb, ns, flag, opcodeClassName);
+			}
 
 			File.WriteAllText(csPath, sb.ToString());
 		}
 
-		private static void GenerateHead(StringBuilder sb, HeadFlag flag, string opcodeClassName)
+		private static void GenerateHead(StringBuilder sb, string ns, HeadFlag flag, string opcodeClassName)
 		{
-			sb.AppendLine("#if SERVER");
-			sb.AppendLine("namespace ETModel\n{");
+			sb.AppendLine($"namespace {ns}");
+			sb.AppendLine("{");
 			foreach (string parentClass in parentMsg.GetDictionary().Keys)
 			{
 				if ((flag & HeadFlag.Bson) != 0)
@@ -181,22 +186,6 @@ namespace MyEditor
 				}
 
 
-				sb.Append($"\tpublic partial class {parentClass} {{}}\n\n");
-			}
-			sb.AppendLine("}");
-			sb.AppendLine("#endif");
-
-			sb.AppendLine("namespace ETModel\n{");
-			foreach (string parentClass in parentMsg.GetDictionary().Keys)
-			{
-				if ((flag & HeadFlag.Proto) != 0)
-				{
-					foreach (string s in parentMsg.GetAll(parentClass))
-					{
-						sb.Append($"\t[ProtoInclude({opcodeClassName}.{s}, typeof({s}))]\n");
-					}
-				}
-
 				sb.Append($"\tpublic partial class {parentClass} {{}}\n\n");
 			}
 			sb.AppendLine("}");
@@ -220,7 +209,7 @@ namespace MyEditor
 			File.WriteAllText(csPath, sb.ToString());
 		}
 
-		private static void Repeated(StringBuilder sb, string newline)
+		private static void Repeated(StringBuilder sb, string ns, string newline, bool isClient)
 		{
 			try
 			{
@@ -231,7 +220,15 @@ namespace MyEditor
 				type = ConvertType(type);
 				string name = ss[2];
 				int order = int.Parse(ss[4]);
-				sb.Append($"\t\t[ProtoMember({order})]\n");
+				if (isClient)
+				{
+					sb.Append($"\t\t[ProtoMember({order}, TypeName = \"{ns}.{type}\")]\n");
+				}
+				else
+				{
+					sb.Append($"\t\t[ProtoMember({order})]\n");
+				}
+
 				sb.Append($"\t\tpublic List<{type}> {name} = new List<{type}>();\n\n");
 			}
 			catch (Exception e)

+ 1 - 27
Unity/Assets/Scripts/Module/Message/OuterMessage.cs

@@ -95,7 +95,7 @@ namespace ETModel
 	[ProtoContract]
 	public partial class Actor_CreateUnits: MessageObject, IActorMessage
 	{
-		[ProtoMember(1)]
+		[ProtoMember(1, TypeName = "ETModel.UnitInfo")]
 		public List<UnitInfo> Units = new List<UnitInfo>();
 
 	}
@@ -162,29 +162,3 @@ namespace ETModel
 	}
 
 }
-#if SERVER
-namespace ETModel
-{
-	[BsonKnownTypes(typeof(Actor_Test))]
-	[BsonKnownTypes(typeof(Actor_TestRequest))]
-	[BsonKnownTypes(typeof(Actor_TestResponse))]
-	[BsonKnownTypes(typeof(Actor_TransferRequest))]
-	[BsonKnownTypes(typeof(Actor_TransferResponse))]
-	[BsonKnownTypes(typeof(Actor_CreateUnits))]
-	[BsonKnownTypes(typeof(Frame_ClickMap))]
-	public partial class MessageObject {}
-
-}
-#endif
-namespace ETModel
-{
-	[ProtoInclude(OuterOpcode.Actor_Test, typeof(Actor_Test))]
-	[ProtoInclude(OuterOpcode.Actor_TestRequest, typeof(Actor_TestRequest))]
-	[ProtoInclude(OuterOpcode.Actor_TestResponse, typeof(Actor_TestResponse))]
-	[ProtoInclude(OuterOpcode.Actor_TransferRequest, typeof(Actor_TransferRequest))]
-	[ProtoInclude(OuterOpcode.Actor_TransferResponse, typeof(Actor_TransferResponse))]
-	[ProtoInclude(OuterOpcode.Actor_CreateUnits, typeof(Actor_CreateUnits))]
-	[ProtoInclude(OuterOpcode.Frame_ClickMap, typeof(Frame_ClickMap))]
-	public partial class MessageObject {}
-
-}

+ 23 - 13
Unity/Hotfix/Module/Message/HotfixMessage.cs

@@ -1,6 +1,5 @@
 using ProtoBuf;
 using ETModel;
-using ETHotfix;
 using System.Collections.Generic;
 using MongoDB.Bson.Serialization.Attributes;
 namespace ETHotfix
@@ -86,18 +85,29 @@ namespace ETHotfix
 
 	}
 
-}
-#if SERVER
-namespace ETModel
-{
-	[BsonKnownTypes(typeof(C2M_TestActorRequest))]
-	[BsonKnownTypes(typeof(M2C_TestActorResponse))]
-	public partial class MessageObject {}
+	[Message(HotfixOpcode.PlayerInfo)]
+	[ProtoContract]
+	public partial class PlayerInfo: IMessage
+	{
+	}
 
-}
-#endif
-namespace ETModel
-{
-	public partial class MessageObject {}
+	[Message(HotfixOpcode.C2G_PlayerInfo)]
+	[ProtoContract]
+	public partial class C2G_PlayerInfo: IRequest
+	{
+	}
+
+	[Message(HotfixOpcode.G2C_PlayerInfo)]
+	[ProtoContract]
+	public partial class G2C_PlayerInfo: IResponse
+	{
+		[ProtoMember(90, IsRequired = true)]
+		public int Error { get; set; }
+		[ProtoMember(91, IsRequired = true)]
+		public string Message { get; set; }
+		[ProtoMember(1, TypeName = "ETHotfix.PlayerInfo")]
+		public List<PlayerInfo> PlayerInfos = new List<PlayerInfo>();
+
+	}
 
 }

+ 3 - 0
Unity/Hotfix/Module/Message/HotfixOpcode.cs

@@ -9,5 +9,8 @@ namespace ETModel
 		 public const ushort G2C_TestHotfixMessage = 10005;
 		 public const ushort C2M_TestActorRequest = 10006;
 		 public const ushort M2C_TestActorResponse = 10007;
+		 public const ushort PlayerInfo = 10008;
+		 public const ushort C2G_PlayerInfo = 10009;
+		 public const ushort G2C_PlayerInfo = 10010;
 	}
 }

+ 1 - 1
Unity/Hotfix/Module/Message/IMessage.cs

@@ -2,7 +2,7 @@
 
 namespace ETHotfix
 {
-	public class MessageObject
+	public partial class MessageObject
 	{
 	}
 

+ 11 - 1
Unity/Hotfix/Module/Message/OpcodeTypeComponent.cs

@@ -1,5 +1,6 @@
 using System;
 using ETModel;
+using ProtoBuf;
 
 namespace ETHotfix
 {
@@ -33,8 +34,17 @@ namespace ETHotfix
 					continue;
 				}
 				this.opcodeTypes.Add(messageAttribute.Opcode, type);
+			}
+
+			foreach (Type type in types)
+			{
+				object[] attrs = type.GetCustomAttributes(typeof(ProtoContractAttribute), false);
+				if (attrs.Length == 0)
+				{
+					continue;
+				}
 
-				ProtoBuf.PType.RegisterType(type.FullName, type);
+				PType.RegisterType(type.FullName, type);
 			}
 		}