소스 검색

解决消息opcode冲突问题,

tanghai 8 년 전
부모
커밋
1ea16d76ae

+ 1 - 0
Server/Model/Entity/Message/InnerOpcode.cs

@@ -1,5 +1,6 @@
 namespace Model
 {
+	// 1-999
 	public static partial class Opcode
 	{
 		public const ushort ActorRequest = 1;

+ 5 - 5
Unity/Assets/Scripts/Base/Event/CrossIdType.cs

@@ -1,9 +1,9 @@
 namespace Model
 {
-    public static class CrossIdType
+    public enum CrossIdType
     {
-        public const int MessageDeserializeFinish = 0;
-        public const int SceneChange = 1;
-	    public const int FrameUpdate = 2;
-	}
+        MessageDeserializeFinish,
+        SceneChange,
+	    FrameUpdate,
+    }
 }

+ 1 - 0
Unity/Assets/Scripts/Base/Object/Entity.cs

@@ -7,6 +7,7 @@ using MongoDB.Bson.Serialization.Attributes;
 namespace Model
 {
 	[BsonIgnoreExtraElements]
+	[BsonKnownTypes(typeof(EntityDB))]
 	public class Entity : Disposer, ISupportInitialize
 	{
 		[BsonIgnore]

+ 16 - 0
Unity/Assets/Scripts/Base/Object/EntityDB.cs

@@ -0,0 +1,16 @@
+using MongoDB.Bson.Serialization.Attributes;
+
+namespace Model
+{
+	[BsonIgnoreExtraElements]
+	public class EntityDB: Entity
+	{
+		protected EntityDB()
+		{
+		}
+
+		protected EntityDB(long id): base(id)
+		{
+		}
+	}
+}

+ 12 - 0
Unity/Assets/Scripts/Base/Object/EntityDB.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 9af83b3a01cc1ed4ebc656d3dde3deeb
+timeCreated: 1506651030
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 8
Unity/Assets/Scripts/Component/CrossComponent.cs

@@ -36,11 +36,11 @@ namespace Model
 			Type[] types = DllHelper.GetHotfixTypes();
 			foreach (Type type in types)
 			{
-				object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);
+				object[] attrs = type.GetCustomAttributes(typeof(CrossEventAttribute), false);
 
 				foreach (object attr in attrs)
 				{
-					EventAttribute aEventAttribute = (EventAttribute)attr;
+					CrossEventAttribute aEventAttribute = (CrossEventAttribute)attr;
 					IInstanceMethod method = new ILInstanceMethod(type, "Run");
 					if (!this.allEvents.ContainsKey(aEventAttribute.Type))
 					{
@@ -72,10 +72,10 @@ namespace Model
 			}
 		}
 
-		public void Run<A>(int type, A a)
+		public void Run<A>(CrossIdType type, A a)
 		{
 			List<IInstanceMethod> iEvents = null;
-			if (!this.allEvents.TryGetValue(type, out iEvents))
+			if (!this.allEvents.TryGetValue((int)type, out iEvents))
 			{
 				return;
 			}
@@ -93,10 +93,10 @@ namespace Model
 			}
 		}
 
-		public void Run<A, B>(int type, A a, B b)
+		public void Run<A, B>(CrossIdType type, A a, B b)
 		{
 			List<IInstanceMethod> iEvents = null;
-			if (!this.allEvents.TryGetValue(type, out iEvents))
+			if (!this.allEvents.TryGetValue((int)type, out iEvents))
 			{
 				return;
 			}
@@ -114,10 +114,10 @@ namespace Model
 			}
 		}
 
-		public void Run<A, B, C>(int type, A a, B b, C c)
+		public void Run<A, B, C>(CrossIdType type, A a, B b, C c)
 		{
 			List<IInstanceMethod> iEvents = null;
-			if (!this.allEvents.TryGetValue(type, out iEvents))
+			if (!this.allEvents.TryGetValue((int)type, out iEvents))
 			{
 				return;
 			}

+ 2 - 1
Unity/Assets/Scripts/Entity/Message/Opcode.cs

@@ -1,8 +1,9 @@
 namespace Model
 {
+	// 1000开始
 	public static partial class Opcode
 	{
-		public const ushort FrameMessage = 1;
+		public const ushort FrameMessage = 1000;
 		public const ushort C2R_Login = 1001;
 		public const ushort R2C_Login = 1002;
 		public const ushort R2C_ServerLog = 1003;

+ 1 - 1
Unity/Hotfix/Event/SessionRecvMessage_Dispatch.cs

@@ -3,7 +3,7 @@
 namespace Hotfix
 {
 	// 订阅mono层的Session发出的事件
-	[CrossEvent(CrossIdType.MessageDeserializeFinish)]
+	[CrossEvent((int)CrossIdType.MessageDeserializeFinish)]
 	public class MessageDeserializeFinish_Dispatch
 	{
 		public void Run(MessageInfo messageInfo)

+ 13 - 1
Unity/ProjectSettings/QualitySettings.asset

@@ -4,7 +4,7 @@
 QualitySettings:
   m_ObjectHideFlags: 0
   serializedVersion: 5
-  m_CurrentQuality: 3
+  m_CurrentQuality: 0
   m_QualitySettings:
   - serializedVersion: 2
     name: Fastest
@@ -17,6 +17,7 @@ QualitySettings:
     shadowNearPlaneOffset: 2
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 0
     blendWeights: 1
     textureQuality: 1
     anisotropicTextures: 0
@@ -31,6 +32,7 @@ QualitySettings:
     particleRaycastBudget: 4
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
   - serializedVersion: 2
     name: Fast
@@ -43,6 +45,7 @@ QualitySettings:
     shadowNearPlaneOffset: 2
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 0
     blendWeights: 2
     textureQuality: 0
     anisotropicTextures: 0
@@ -57,6 +60,7 @@ QualitySettings:
     particleRaycastBudget: 16
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
   - serializedVersion: 2
     name: Simple
@@ -69,6 +73,7 @@ QualitySettings:
     shadowNearPlaneOffset: 2
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 0
     blendWeights: 2
     textureQuality: 0
     anisotropicTextures: 1
@@ -83,6 +88,7 @@ QualitySettings:
     particleRaycastBudget: 64
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
   - serializedVersion: 2
     name: Good
@@ -95,6 +101,7 @@ QualitySettings:
     shadowNearPlaneOffset: 2
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 1
     blendWeights: 2
     textureQuality: 0
     anisotropicTextures: 1
@@ -109,6 +116,7 @@ QualitySettings:
     particleRaycastBudget: 256
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
   - serializedVersion: 2
     name: Beautiful
@@ -121,6 +129,7 @@ QualitySettings:
     shadowNearPlaneOffset: 2
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 1
     blendWeights: 4
     textureQuality: 0
     anisotropicTextures: 2
@@ -135,6 +144,7 @@ QualitySettings:
     particleRaycastBudget: 1024
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
   - serializedVersion: 2
     name: Fantastic
@@ -147,6 +157,7 @@ QualitySettings:
     shadowNearPlaneOffset: 2
     shadowCascade2Split: 0.33333334
     shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
+    shadowmaskMode: 1
     blendWeights: 4
     textureQuality: 0
     anisotropicTextures: 2
@@ -161,6 +172,7 @@ QualitySettings:
     particleRaycastBudget: 4096
     asyncUploadTimeSlice: 2
     asyncUploadBufferSize: 4
+    resolutionScalingFixedDPIFactor: 1
     excludedTargetPlatforms: []
   m_PerPlatformDefaultQuality:
     Android: 2

+ 1 - 0
Unity/Unity.csproj

@@ -488,6 +488,7 @@
     <Compile Include="Assets\Scripts\Base\Object\ComponentFactory.cs" />
     <Compile Include="Assets\Scripts\Base\Object\Disposer.cs" />
     <Compile Include="Assets\Scripts\Base\Object\Entity.cs" />
+    <Compile Include="Assets\Scripts\Base\Object\EntityDB.cs" />
     <Compile Include="Assets\Scripts\Base\Object\EntityEventAttribute.cs" />
     <Compile Include="Assets\Scripts\Base\Object\EntityFactory.cs" />
     <Compile Include="Assets\Scripts\Base\Object\EntityType.cs" />