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

MapUnitActorTypeHandler.cs仔细看了一下貌似不太需要,OneFrameMessage直接统一放到ActorMessageHandle处理就行了

tanghai 7 лет назад
Родитель
Сommit
27b531a3cd

+ 0 - 28
Server/Hotfix/Module/Actor/MapUnitActorTypeHandler.cs

@@ -1,28 +0,0 @@
-using System.Threading.Tasks;
-using ETModel;
-
-namespace ETHotfix
-{
-	/// <summary>
-	/// 玩家收到帧同步消息交给帧同步组件处理
-	/// </summary>
-	[ActorTypeHandler(AppType.Map, ActorType.Unit)]
-	public class MapUnitActorTypeHandler : IActorTypeHandler
-    {
-        public async Task Handle(Session session, Entity entity, IActorMessage actorMessage)
-        {
-			if (actorMessage is OneFrameMessage aFrameMessage)
-            {
-				Game.Scene.GetComponent<ServerFrameComponent>().Add(aFrameMessage);
-
-				ActorResponse actorResponse = new ActorResponse
-				{
-					RpcId = actorMessage.RpcId
-				};
-				session.Reply(actorResponse);
-				return;
-            }
-            await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, actorMessage);
-        }
-    }
-}

+ 1 - 1
Server/Hotfix/Module/FrameSync/G2M_CreateUnitHandler.cs

@@ -13,7 +13,7 @@ namespace ETHotfix
 			{
 				Unit unit = ComponentFactory.Create<Unit>();
 
-				await unit.AddComponent<ActorComponent, string>(ActorType.Unit).AddLocation();
+				await unit.AddComponent<ActorComponent>().AddLocation();
 				unit.AddComponent<UnitGateComponent, long>(message.GateSessionId);
 				Game.Scene.GetComponent<UnitComponent>().Add(unit);
 				response.UnitId = unit.Id;

+ 15 - 0
Server/Hotfix/Module/FrameSync/OneFrameMessageHandler.cs

@@ -0,0 +1,15 @@
+using System.Threading.Tasks;
+using ETModel;
+
+namespace ETHotfix
+{
+	[ActorMessageHandler(AppType.Map)]
+	public class OneFrameMessageHandler: AMActorHandler<Unit, OneFrameMessage>
+    {
+	    protected override async Task Run(Unit entity, OneFrameMessage message)
+	    {
+		    Game.Scene.GetComponent<ServerFrameComponent>().Add(message);
+		    await Task.CompletedTask;
+	    }
+    }
+}

+ 0 - 1
Server/Model/Module/Actor/ActorType.cs

@@ -4,6 +4,5 @@
     {
 	    public const string Common = "Common";
 		public const string GateSession = "GateSession";
-	    public const string Unit = "Unit";
     }
 }