Просмотр исходного кода

合并master修改

# Conflicts:
#	Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs
#	Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorHandleHelper.cs
tanghai 2 лет назад
Родитель
Сommit
2cf3e99c33

+ 27 - 27
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs

@@ -3,36 +3,36 @@
 
 namespace ET.Server
 {
-	[MessageHandler(SceneType.Gate)]
-	public class C2G_LoginGateHandler : AMRpcHandler<C2G_LoginGate, G2C_LoginGate>
-	{
-		protected override async ETTask Run(Session session, C2G_LoginGate request, G2C_LoginGate response)
-		{
-			Scene scene = session.DomainScene();
-			string account = scene.GetComponent<GateSessionKeyComponent>().Get(request.Key);
-			if (account == null)
-			{
-				response.Error = ErrorCore.ERR_ConnectGateKeyError;
-				response.Message = "Gate key验证失败!";
-				return;
-			}
+    [MessageHandler(SceneType.Gate)]
+    public class C2G_LoginGateHandler : AMRpcHandler<C2G_LoginGate, G2C_LoginGate>
+    {
+        protected override async ETTask Run(Session session, C2G_LoginGate request, G2C_LoginGate response)
+        {
+            Scene scene = session.DomainScene();
+            string account = scene.GetComponent<GateSessionKeyComponent>().Get(request.Key);
+            if (account == null)
+            {
+                response.Error = ErrorCore.ERR_ConnectGateKeyError;
+                response.Message = "Gate key验证失败!";
+                return;
+            }
 			
-			session.RemoveComponent<SessionAcceptTimeoutComponent>();
+            session.RemoveComponent<SessionAcceptTimeoutComponent>();
 
-			PlayerComponent playerComponent = scene.GetComponent<PlayerComponent>();
-			Player player = playerComponent.AddChild<Player, string>(account);
-			PlayerSessionComponent playerSessionComponent = player.AddComponent<PlayerSessionComponent>();
-			playerSessionComponent.Session = session;
-			playerSessionComponent.AddComponent<MailBoxComponent, MailboxType>(MailboxType.GateSession);
-			await playerSessionComponent.AddLocation(LocationType.GateSession);
+            PlayerComponent playerComponent = scene.GetComponent<PlayerComponent>();
+            Player player = playerComponent.AddChild<Player, string>(account);
+            PlayerSessionComponent playerSessionComponent = player.AddComponent<PlayerSessionComponent>();
+            playerSessionComponent.Session = session;
+            playerSessionComponent.AddComponent<MailBoxComponent, MailboxType>(MailboxType.GateSession);
+            await playerSessionComponent.AddLocation(LocationType.GateSession);
 			
-			player.AddComponent<MailBoxComponent, MailboxType>(MailboxType.UnOrderMessageDispatcher);
-			await player.AddLocation(LocationType.Player);
+            player.AddComponent<MailBoxComponent, MailboxType>(MailboxType.UnOrderMessageDispatcher);
+            await player.AddLocation(LocationType.Player);
 			
-			session.AddComponent<SessionPlayerComponent>().Player = player;
+            session.AddComponent<SessionPlayerComponent>().Player = player;
 
-			response.PlayerId = player.Id;
-			await ETTask.CompletedTask;
-		}
-	}
+            response.PlayerId = player.Id;
+            await ETTask.CompletedTask;
+        }
+    }
 }

+ 1 - 3
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorHandleHelper.cs

@@ -36,7 +36,7 @@ namespace ET.Server
             int fromProcess = instanceIdStruct.Process;
             instanceIdStruct.Process = Options.Instance.Process;
             long realActorId = instanceIdStruct.ToLong();
-            
+
             Entity entity = Root.Instance.Get(realActorId);
             if (entity == null)
             {
@@ -100,8 +100,6 @@ namespace ET.Server
                 return;
             }
             
-            OpcodeHelper.LogMsg(entity.DomainScene(), iActorMessage);
-            
             MailBoxComponent mailBoxComponent = entity.GetComponent<MailBoxComponent>();
             if (mailBoxComponent == null)
             {

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorMessageDispatcherComponentSystem.cs

@@ -104,7 +104,7 @@ namespace ET.Server
             SceneType sceneType = entity.DomainScene().SceneType;
             foreach (ActorMessageDispatcherInfo actorMessageDispatcherInfo in list)
             {
-                if (actorMessageDispatcherInfo.SceneType != sceneType)
+                if (!actorMessageDispatcherInfo.SceneType.HasSameFlag(sceneType))
                 {
                     continue;
                 }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Message/MessageDispatcherComponentSystem.cs

@@ -97,7 +97,7 @@ namespace ET
             SceneType sceneType = session.DomainScene().SceneType;
             foreach (MessageDispatcherInfo ev in actions)
             {
-                if (ev.SceneType != sceneType)
+                if (!ev.SceneType.HasSameFlag(sceneType))
                 {
                     continue;
                 }

+ 4 - 1
Unity/Assets/Scripts/Codes/Model/Server/Module/Actor/ActorMessageHandlerAttribute.cs

@@ -1,5 +1,8 @@
-namespace ET.Server
+using System;
+
+namespace ET.Server
 {
+    [AttributeUsage(AttributeTargets.Class)]
     public class ActorMessageHandlerAttribute: BaseAttribute
     {
         public SceneType SceneType { get; }

+ 4 - 1
Unity/Assets/Scripts/Codes/Model/Share/Module/Message/MessageHandlerAttribute.cs

@@ -1,5 +1,8 @@
-namespace ET
+using System;
+
+namespace ET
 {
+    [AttributeUsage(AttributeTargets.Class)]
     public class MessageHandlerAttribute: BaseAttribute
     {
         public SceneType SceneType { get; }

+ 4 - 1
Unity/Assets/Scripts/Codes/Model/Share/Module/Numeric/NumericWatcherAttribute.cs

@@ -1,5 +1,8 @@
-namespace ET
+using System;
+
+namespace ET
 {
+	[AttributeUsage(AttributeTargets.Class)]
 	public class NumericWatcherAttribute : BaseAttribute
 	{
 		public SceneType SceneType { get; }

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Share/Module/Numeric/NumericWatcherComponent.cs

@@ -59,7 +59,7 @@ namespace ET
             SceneType unitDomainSceneType = unit.DomainScene().SceneType;
             foreach (NumericWatcherInfo numericWatcher in list)
             {
-                if (numericWatcher.SceneType != unitDomainSceneType)
+                if (!numericWatcher.SceneType.HasSameFlag(unitDomainSceneType))
                 {
                     continue;
                 }

+ 12 - 0
Unity/Assets/Scripts/Core/Module/Entity/SceneType.cs

@@ -31,4 +31,16 @@ namespace ET
 		
 		All = ulong.MaxValue,
 	}
+
+	public static class SceneTypeHelper
+	{
+		public static bool HasSameFlag(this SceneType a, SceneType b)
+		{
+			if (((ulong) a & (ulong) b) == 0)
+			{
+				return false;
+			}
+			return true;
+		}
+	}
 }

+ 2 - 2
Unity/Assets/Scripts/Core/Module/EventSystem/EventSystem.cs

@@ -609,7 +609,7 @@ namespace ET
             
             foreach (EventInfo eventInfo in iEvents)
             {
-                if (((ulong)scene.SceneType & (ulong)eventInfo.SceneType) == 0)
+                if (!scene.SceneType.HasSameFlag(eventInfo.SceneType))
                 {
                     continue;
                 }
@@ -644,7 +644,7 @@ namespace ET
             SceneType sceneType = scene.SceneType;
             foreach (EventInfo eventInfo in iEvents)
             {
-                if (((ulong)sceneType & (ulong)eventInfo.SceneType) == 0)
+                if (!sceneType.HasSameFlag(eventInfo.SceneType))
                 {
                     continue;
                 }

+ 1 - 1
Unity/Assets/Scripts/Core/Module/EventSystem/ObjectSystemAttribute.cs

@@ -2,7 +2,7 @@
 
 namespace ET
 {
-	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
+	[AttributeUsage(AttributeTargets.Class)]
 	public class ObjectSystemAttribute: BaseAttribute
 	{
 	}