tanghai 6 лет назад
Родитель
Сommit
92fcff88a5
33 измененных файлов с 130 добавлено и 280 удалено
  1. 0 1
      Config/StartConfig/127.0.0.1.txt
  2. 0 2
      Config/StartConfig/Benchmark.txt
  3. 0 2
      Config/StartConfig/BenchmarkWebsocket.txt
  4. 0 1
      Config/StartConfig/LocalAllServer.txt
  5. 0 1
      Config/StartConfig/LocalAllServerWebsocket.txt
  6. 0 2
      Server/App/Program.cs
  7. 28 0
      Server/Hotfix/Module/Actor/MailBoxComponentSystem.cs
  8. 0 80
      Server/Hotfix/Module/Actor/MailboxDispatcherComponentSystem.cs
  9. 0 29
      Server/Hotfix/Module/Actor/MailboxGateSessionHandler.cs
  10. 0 24
      Server/Hotfix/Module/Actor/MailboxMessageDispatcherHandler.cs
  11. 2 3
      Server/Hotfix/Module/Demo/C2G_EnterMapHandler.cs
  12. 1 1
      Server/Hotfix/Module/Demo/C2R_LoginHandler.cs
  13. 1 1
      Server/Hotfix/Module/Demo/G2M_CreateUnitHandler.cs
  14. 1 1
      Server/Hotfix/Module/Demo/UnitPathComponentSystem.cs
  15. 2 2
      Server/Hotfix/Module/Message/InnerMessageDispatcherHelper.cs
  16. 9 26
      Server/Hotfix/Module/Message/NetInnerComponentSystem.cs
  17. 2 3
      Server/Hotfix/Module/Message/OuterMessageDispatcher.cs
  18. 2 0
      Server/Hotfix/Module/Scene/SceneFactory.cs
  19. 0 7
      Server/Model/Module/Actor/IMailboxHandler.cs
  20. 0 14
      Server/Model/Module/Actor/MailboxDispatcherComponent.cs
  21. 0 12
      Server/Model/Module/Actor/MailboxHandlerAttribute.cs
  22. 46 54
      Unity/Assets/Hotfix/Base/Object/EventSystem.cs
  23. 27 6
      Unity/Assets/Model/Base/Object/EventSystem.cs
  24. 1 1
      Unity/Assets/Model/Component/SceneChangeComponent.cs
  25. 1 2
      Unity/Assets/Model/Module/Actor/IActorMessage.cs
  26. 0 1
      Unity/Assets/Model/Module/AssetsBundle/ResourcesComponent.cs
  27. BIN
      Unity/Assets/Res/Code/Hotfix.pdb.bytes
  28. 1 1
      Unity/Assets/Res/Config/GlobalProto.txt
  29. 6 3
      Unity/ProjectSettings/ProjectSettings.asset
  30. 0 0
      Unity/Unity.Editor.csproj
  31. 0 0
      Unity/Unity.Hotfix.csproj
  32. 0 0
      Unity/Unity.Model.csproj
  33. 0 0
      Unity/Unity.ThirdParty.csproj

+ 0 - 1
Config/StartConfig/127.0.0.1.txt

@@ -1 +0,0 @@
-{ "_t" : "StartConfig", "_id" : NumberLong(1), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20001" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10001", "Address2" : "127.0.0.1:10001" }], "List" : [{ "_id" : NumberLong(1), "C" : [{ "_t" : "SceneConfig", "_id" : NumberLong(1), "SceneType" : 2, "Name" : "Realm" }], "List" : [] }, { "_id" : NumberLong(2), "C" : [{ "_t" : "SceneConfig", "_id" : NumberLong(1), "SceneType" : 5, "Name" : "Location" }], "List" : [] }, { "_id" : NumberLong(3), "C" : [{ "_t" : "SceneConfig", "_id" : NumberLong(1), "SceneType" : 3, "Name" : "Gate" }], "List" : [] }] }

+ 0 - 2
Config/StartConfig/Benchmark.txt

@@ -1,2 +0,0 @@
-{ "_t" : "StartConfig", "C" : [{ "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }, { "_t" : "InnerConfig", "Address" : "127.0.0.1:20000" }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "C" : [{ "_t" : "ClientConfig", "Address" : "127.0.0.1:10002" }], "AppId" : 2, "AppType" : "Benchmark", "ServerIP" : "*" }

+ 0 - 2
Config/StartConfig/BenchmarkWebsocket.txt

@@ -1,2 +0,0 @@
-{ "_t" : "StartConfig", "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20000" }, { "_t" : "OuterConfig", "Address" : "http://*:8080/", "Address2" : "ws://127.0.0.1:8080" }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "C" : [{ "_t" : "ClientConfig", "Address" : "ws://127.0.0.1:8080" }], "AppId" : 2, "AppType" : "BenchmarkWebsocketClient", "ServerIP" : "*" }

+ 0 - 1
Config/StartConfig/LocalAllServer.txt

@@ -1 +0,0 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "C" : [{ "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }, { "_t" : "InnerConfig", "Address" : "127.0.0.1:20002" }, { "_t" : "HttpConfig", "Url" : "http://*:8080/", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : "mongodb://172.16.100.40:27017/", "DBName" : "ET" }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" }

+ 0 - 1
Config/StartConfig/LocalAllServerWebsocket.txt

@@ -1 +0,0 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "C" : [{ "_t" : "OuterConfig", "Address" : "http://*:8080/", "Address2" : "ws://127.0.0.1:8080" }, { "_t" : "InnerConfig", "Address" : "127.0.0.1:20000" }, { "_t" : "HttpConfig", "Url" : "http://*:8080/", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : null, "DBName" : null }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" }

+ 0 - 2
Server/App/Program.cs

@@ -51,8 +51,6 @@ namespace ETModel
 				Game.Scene.AddComponent<ActorLocationSenderComponent>();
 				// 访问location server的组件
 				Game.Scene.AddComponent<LocationProxyComponent>();
-				// 这两个组件是处理actor消息使用的
-				Game.Scene.AddComponent<MailboxDispatcherComponent>();
 				Game.Scene.AddComponent<ActorMessageDispatcherComponent>();
 				// 数值订阅组件
 				Game.Scene.AddComponent<NumericWatcherComponent>();

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

@@ -20,4 +20,32 @@ namespace ETHotfix
 			self.MailboxType = mailboxType;
 		}
 	}
+	
+	public static class MailBoxComponentSystem
+	{
+		public static async ETTask Handle(this MailBoxComponent self, Session session, IActorMessage message)
+		{
+			switch (self.MailboxType)
+			{
+				case MailboxType.GateSession:
+					IActorMessage iActorMessage = message as IActorMessage;
+					// 发送给客户端
+					Session clientSession = self.Parent as Session;
+					iActorMessage.ActorId = 0;
+					clientSession.Send(iActorMessage);
+					break;
+				case MailboxType.MessageDispatcher:
+					await ActorMessageDispatcherComponent.Instance.Handle(self.Parent, session, message);
+					break;
+				case MailboxType.UnOrderMessageDispatcher:
+					self.HandleInner(session, message).Coroutine();
+					break;
+			}
+		}
+
+		private static async ETVoid HandleInner(this MailBoxComponent self, Session session, IActorMessage message)
+		{
+			await ActorMessageDispatcherComponent.Instance.Handle(self.Parent, session, message);
+		}
+	}
 }

+ 0 - 80
Server/Hotfix/Module/Actor/MailboxDispatcherComponentSystem.cs

@@ -1,80 +0,0 @@
-using System;
-using System.Collections.Generic;
-using ETModel;
-
-namespace ETHotfix
-{
-	[ObjectSystem]
-	public class MailboxDispatcherComponentAwakeSystem: AwakeSystem<MailboxDispatcherComponent>
-	{
-		public override void Awake(MailboxDispatcherComponent self)
-		{
-			self.Awake();
-		}
-	}
-
-	[ObjectSystem]
-	public class MailboxDispatcherComponentLoadSystem: LoadSystem<MailboxDispatcherComponent>
-	{
-		public override void Load(MailboxDispatcherComponent self)
-		{
-			self.Load();
-		}
-	}
-	
-	[ObjectSystem]
-	public class MailboxDispatcherComponentDestroySystem: DestroySystem<MailboxDispatcherComponent>
-	{
-		public override void Destroy(MailboxDispatcherComponent self)
-		{
-			self.MailboxHandlers.Clear();
-		}
-	}
-
-	public static class MailboxDispatcherComponentHelper
-	{
-		public static void Awake(this MailboxDispatcherComponent self)
-		{
-			MailboxDispatcherComponent.Instance = self;
-			self.Load();
-		}
-
-		public static void Load(this MailboxDispatcherComponent self)
-		{
-			self.MailboxHandlers.Clear();
-
-			HashSet<Type> types = Game.EventSystem.GetTypes(typeof(MailboxHandlerAttribute));
-			foreach (Type type in types)
-			{
-				object[] attrs = type.GetCustomAttributes(typeof(MailboxHandlerAttribute), false);
-				if (attrs.Length == 0)
-				{
-					continue;
-				}
-
-				MailboxHandlerAttribute mailboxHandlerAttribute = (MailboxHandlerAttribute) attrs[0];
-
-				object obj = Activator.CreateInstance(type);
-
-				if (!(obj is IMailboxHandler iMailboxHandler))
-				{
-					throw new Exception($"actor handler not inherit IEntityActorHandler: {obj.GetType().FullName}");
-				}
-
-				self.MailboxHandlers.Add((int)mailboxHandlerAttribute.MailboxType, iMailboxHandler);
-			}
-		}
-
-		/// <summary>
-		/// 根据mailbox类型做不同的处理
-		/// </summary>
-		public static async ETTask Handle(
-				this MailboxDispatcherComponent self, Entity entity, MailboxType mailboxType, Session session, object message)
-		{
-			if (self.MailboxHandlers.TryGetValue((int) mailboxType, out IMailboxHandler iMailboxHandler))
-			{
-				await iMailboxHandler.Handle(session, entity, message);
-			}
-		}
-	}
-}

+ 0 - 29
Server/Hotfix/Module/Actor/MailboxGateSessionHandler.cs

@@ -1,29 +0,0 @@
-using System;
-using ETModel;
-
-namespace ETHotfix
-{
-	/// <summary>
-	/// gate session类型的Mailbox,收到的actor消息直接转发给客户端
-	/// </summary>
-	[MailboxHandler(MailboxType.GateSession)]
-	public class MailboxGateSessionHandler : IMailboxHandler
-	{
-		public async ETTask Handle(Session session, Entity entity, object actorMessage)
-		{
-			try
-			{
-				IActorMessage iActorMessage = actorMessage as IActorMessage;
-				// 发送给客户端
-				Session clientSession = entity as Session;
-				iActorMessage.ActorId = 0;
-				clientSession.Send(iActorMessage);
-				await ETTask.CompletedTask;
-			}
-			catch (Exception e)
-			{
-				Log.Error(e);
-			}
-		}
-	}
-}

+ 0 - 24
Server/Hotfix/Module/Actor/MailboxMessageDispatcherHandler.cs

@@ -1,24 +0,0 @@
-using System;
-using ETModel;
-
-namespace ETHotfix
-{
-	/// <summary>
-	/// 消息分发类型的Mailbox,对mailbox中的消息进行分发处理
-	/// </summary>
-	[MailboxHandler(MailboxType.MessageDispatcher)]
-	public class MailboxMessageDispatcherHandler : IMailboxHandler
-	{
-		public async ETTask Handle(Session session, Entity entity, object actorMessage)
-		{
-			try
-			{
-				await ActorMessageDispatcherComponent.Instance.Handle(entity, session, actorMessage);
-			}
-			catch (Exception e)
-			{
-				Log.Error(e);
-			}
-		}
-	}
-}

+ 2 - 3
Server/Hotfix/Module/Demo/C2G_EnterMapHandler.cs

@@ -10,10 +10,9 @@ namespace ETHotfix
 		{
 			Player player = session.GetComponent<SessionPlayerComponent>().Player;
 			// 在map服务器上创建战斗Unit
-			long mapInstanceId = StartConfigComponent.Instance.GetByName("Map").SceneInstanceId;
+			long mapInstanceId = StartConfigComponent.Instance.GetByName("Map1").SceneInstanceId;
 			M2G_CreateUnit createUnit = (M2G_CreateUnit)await ActorMessageSenderComponent.Instance.Call(
-				mapInstanceId, 
-				new G2M_CreateUnit() { PlayerId = player.Id, GateSessionId = session.InstanceId });
+				mapInstanceId, new G2M_CreateUnit() { PlayerId = player.Id, GateSessionId = session.InstanceId });
 			player.UnitId = createUnit.UnitId;
 			response.UnitId = createUnit.UnitId;
 			reply();

+ 1 - 1
Server/Hotfix/Module/Demo/C2R_LoginHandler.cs

@@ -17,7 +17,7 @@ namespace ETHotfix
 			G2R_GetLoginKey g2RGetLoginKey = (G2R_GetLoginKey) await ActorMessageSenderComponent.Instance.Call(
 				config.SceneInstanceId, new R2G_GetLoginKey() {Account = request.Account});
 
-			string outerAddress = config.GetComponent<OuterConfig>().Address2;
+			string outerAddress = config.GetParent<StartConfig>().GetComponent<OuterConfig>().Address2;
 
 			response.Address = outerAddress;
 			response.Key = g2RGetLoginKey.Key;

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

@@ -24,7 +24,7 @@ namespace ETHotfix
 			
 			// 广播创建的unit
 			M2C_CreateUnits createUnits = new M2C_CreateUnits();
-			Unit[] units = Game.Scene.GetComponent<UnitComponent>().GetAll();
+			Unit[] units = scene.GetComponent<UnitComponent>().GetAll();
 			foreach (Unit u in units)
 			{
 				UnitInfo unitInfo = new UnitInfo();

+ 1 - 1
Server/Hotfix/Module/Demo/UnitPathComponentSystem.cs

@@ -39,7 +39,7 @@ namespace ETHotfix
             Unit unit = self.GetParent<Unit>();
             
             
-            PathfindingComponent pathfindingComponent = Game.Scene.GetComponent<PathfindingComponent>();
+            PathfindingComponent pathfindingComponent = self.Domain.GetComponent<PathfindingComponent>();
             self.ABPath = EntityFactory.Create<ABPathWrap, Vector3, Vector3>(self.Domain, unit.Position, new Vector3(target.x, target.y, target.z));
             pathfindingComponent.Search(self.ABPath);
             Log.Debug($"find result: {self.ABPath.Result.ListToString()}");

+ 2 - 2
Server/Hotfix/Module/Message/InnerMessageDispatcherHelper.cs

@@ -43,7 +43,7 @@
 					return;
 				}
 				
-				await MailboxDispatcherComponent.Instance.Handle(entity, mailBoxComponent.MailboxType, ss, iActorRequest);
+				await mailBoxComponent.Handle(ss, iActorRequest);
 			}
 		}
 
@@ -68,7 +68,7 @@
 				}
 				
 				Session ss = NetInnerComponent.Instance.Get(replyId);
-				await MailboxDispatcherComponent.Instance.Handle(entity, mailBoxComponent.MailboxType, ss, iActorMessage);
+				await mailBoxComponent.Handle(ss, iActorMessage);
 			}
 		}
     }

+ 9 - 26
Server/Hotfix/Module/Message/NetInnerComponentSystem.cs

@@ -1,5 +1,4 @@
-using System.Net;
-using ETModel;
+using ETModel;
 
 namespace ETHotfix
 {
@@ -8,7 +7,10 @@ namespace ETHotfix
 	{
 		public override void Awake(NetInnerComponent self)
 		{
-			self.Awake();
+			NetInnerComponent.Instance = self;
+			self.Awake(NetworkProtocol.TCP, Packet.PacketSizeLength4);
+			self.MessagePacker = new MongoPacker();
+			self.MessageDispatcher = new InnerMessageDispatcher();
 		}
 	}
 
@@ -17,7 +19,10 @@ namespace ETHotfix
 	{
 		public override void Awake(NetInnerComponent self, string a)
 		{
-			self.Awake(a);
+			NetInnerComponent.Instance = self;
+			self.Awake(NetworkProtocol.TCP, a, Packet.PacketSizeLength4);
+			self.MessagePacker = new MongoPacker();
+			self.MessageDispatcher = new InnerMessageDispatcher();
 		}
 	}
 	
@@ -39,26 +44,4 @@ namespace ETHotfix
 			self.Update();
 		}
 	}
-
-	public static class NetInnerComponentHelper
-	{
-		public static void Awake(this NetInnerComponent self)
-		{
-			self.Awake(NetworkProtocol.TCP, Packet.PacketSizeLength4);
-			self.MessagePacker = new MongoPacker();
-			self.MessageDispatcher = new InnerMessageDispatcher();
-		}
-
-		public static void Awake(this NetInnerComponent self, string address)
-		{
-			self.Awake(NetworkProtocol.TCP, address, Packet.PacketSizeLength4);
-			self.MessagePacker = new MongoPacker();
-			self.MessageDispatcher = new InnerMessageDispatcher();
-		}
-
-		public static void Update(this NetInnerComponent self)
-		{
-			self.Update();
-		}
-	}
 }

+ 2 - 3
Server/Hotfix/Module/Message/OuterMessageDispatcher.cs

@@ -11,18 +11,16 @@ namespace ETHotfix
 		
 		public async ETVoid DispatchAsync(Session session, ushort opcode, object message)
 		{
-			long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
-			
 			// 根据消息接口判断是不是Actor消息,不同的接口做不同的处理
 			switch (message)
 			{
 				case IActorLocationRequest actorLocationRequest: // gate session收到actor rpc消息,先向actor 发送rpc请求,再将请求结果返回客户端
 				{
+					long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
 					int rpcId = actorLocationRequest.RpcId; // 这里要保存客户端的rpcId
 					long instanceId = session.InstanceId;
 					IResponse response = await ActorLocationSenderComponent.Instance.Call(unitId, actorLocationRequest);
 					response.RpcId = rpcId;
-
 					// session可能已经断开了,所以这里需要判断
 					if (session.InstanceId == instanceId)
 					{
@@ -32,6 +30,7 @@ namespace ETHotfix
 				}
 				case IActorLocationMessage actorLocationMessage:
 				{
+					long unitId = session.GetComponent<SessionPlayerComponent>().Player.UnitId;
 					ActorLocationSenderComponent.Instance.Send(unitId, actorLocationMessage);
 					break;
 				}

+ 2 - 0
Server/Hotfix/Module/Scene/SceneFactory.cs

@@ -21,10 +21,12 @@ namespace ETHotfix
                 case SceneType.Realm:
                     break;
                 case SceneType.Gate:
+                    scene.AddComponent<PlayerComponent>();
                     scene.AddComponent<GateSessionKeyComponent>();
                     break;
                 case SceneType.Map:
                     scene.AddComponent<UnitComponent>();
+                    scene.AddComponent<PathfindingComponent>();
                     break;
                 case SceneType.Location:
                     scene.AddComponent<LocationComponent>();

+ 0 - 7
Server/Model/Module/Actor/IMailboxHandler.cs

@@ -1,7 +0,0 @@
-namespace ETModel
-{
-	public interface IMailboxHandler
-	{
-		ETTask Handle(Session session, Entity entity, object actorMessage);
-	}
-}

+ 0 - 14
Server/Model/Module/Actor/MailboxDispatcherComponent.cs

@@ -1,14 +0,0 @@
-using System.Collections.Generic;
-
-namespace ETModel
-{
-	/// <summary>
-	/// mailbox分发组件,不同类型的mailbox交给不同的MailboxHandle处理
-	/// </summary>
-	public class MailboxDispatcherComponent : Entity
-	{
-		public static MailboxDispatcherComponent Instance { get; set; }
-		
-		public readonly Dictionary<int, IMailboxHandler> MailboxHandlers = new Dictionary<int, IMailboxHandler>();
-	}
-}

+ 0 - 12
Server/Model/Module/Actor/MailboxHandlerAttribute.cs

@@ -1,12 +0,0 @@
-namespace ETModel
-{
-	public class MailboxHandlerAttribute : BaseAttribute
-	{
-		public MailboxType MailboxType { get; }
-
-		public MailboxHandlerAttribute(MailboxType mailboxType)
-		{
-			this.MailboxType = mailboxType;
-		}
-	}
-}

+ 46 - 54
Unity/Assets/Hotfix/Base/Object/EventSystem.cs

@@ -17,10 +17,8 @@ namespace ETHotfix
 	public sealed class EventSystem
 	{
 		private readonly Dictionary<long, Entity> allComponents = new Dictionary<long, Entity>();
-
-		private readonly Dictionary<DLLType, Assembly> assemblies = new Dictionary<DLLType, Assembly>();
 		
-		private readonly UnOrderMultiMapSet<Type, Type> types = new UnOrderMultiMapSet<Type, Type>();
+		private readonly List<Type> types = new List<Type>();
 
 		private readonly Dictionary<string, List<object>> allEvents = new Dictionary<string, List<object>>();
 
@@ -51,41 +49,31 @@ namespace ETHotfix
 		private Queue<long> lateUpdates = new Queue<long>();
 		private Queue<long> lateUpdates2 = new Queue<long>();
 
-		public void Add(DLLType dllType, Assembly assembly)
+		public EventSystem()
 		{
-			this.assemblies[dllType] = assembly;
 			this.types.Clear();
-			foreach (Assembly value in this.assemblies.Values)
+			
+			List<Type> ts = ETModel.Game.Hotfix.GetHotfixTypes();
+			
+			foreach (Type type in ts)
 			{
-				foreach (Type type in value.GetTypes())
-				{
-					if (type.IsAbstract)
-					{
-						continue;
-					}
-
-					object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), true);
-					if (objects.Length == 0)
-					{
-						continue;
-					}
-
-					BaseAttribute baseAttribute = (BaseAttribute) objects[0];
-					this.types.Add(baseAttribute.AttributeType, type);
-				}
+				// ILRuntime无法判断是否有Attribute
+				//if (type.GetCustomAttributes(typeof (Attribute), false).Length == 0)
+				//{
+				//	continue;
+				//}
+				this.types.Add(type);	
 			}
-
-			this.awakeSystems.Clear();
-			this.lateUpdateSystems.Clear();
-			this.updateSystems.Clear();
-			this.startSystems.Clear();
-			this.loadSystems.Clear();
-			this.changeSystems.Clear();
-			this.destroySystems.Clear();
-			this.deserializeSystems.Clear();
 			
-			foreach (Type type in this.GetTypes(typeof(ObjectSystemAttribute)))
+			foreach (Type type in types)
 			{
+				object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), false);
+
+				if (attrs.Length == 0)
+				{
+					continue;
+				}
+
 				object obj = Activator.CreateInstance(type);
 
 				switch (obj)
@@ -118,7 +106,7 @@ namespace ETHotfix
 			}
 
 			this.allEvents.Clear();
-			foreach (Type type in types[typeof(EventAttribute)])
+			foreach (Type type in types)
 			{
 				object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);
 
@@ -132,11 +120,34 @@ namespace ETHotfix
 						Log.Error($"{obj.GetType().Name} 没有继承IEvent");
 					}
 					this.RegisterEvent(aEventAttribute.Type, iEvent);
+
+					// hotfix的事件也要注册到mono层,hotfix可以订阅mono层的事件
+					Action<List<object>> action = list => { Handle(iEvent, list); };
+					ETModel.Game.EventSystem.RegisterEvent(aEventAttribute.Type, new EventProxy(action));
 				}
 			}
-			
+
 			this.Load();
 		}
+		
+		public static void Handle(IEvent iEvent, List<object> param)
+		{
+			switch (param.Count)
+			{
+				case 0:
+					iEvent.Handle();
+					break;
+				case 1:
+					iEvent.Handle(param[0]);
+					break;
+				case 2:
+					iEvent.Handle(param[0], param[1]);
+					break;
+				case 3:
+					iEvent.Handle(param[0], param[1], param[2]);
+					break;
+			}
+		}
 
 		public void RegisterEvent(string eventId, IEvent e)
 		{
@@ -146,29 +157,10 @@ namespace ETHotfix
 			}
 			this.allEvents[eventId].Add(e);
 		}
-
-		public Assembly Get(DLLType dllType)
-		{
-			return this.assemblies[dllType];
-		}
-		
-		public HashSet<Type> GetTypes(Type systemAttributeType)
-		{
-			if (!this.types.ContainsKey(systemAttributeType))
-			{
-				return new HashSet<Type>();
-			}
-			return this.types[systemAttributeType];
-		}
 		
 		public List<Type> GetTypes()
 		{
-			List<Type> allTypes = new List<Type>();
-			foreach (Assembly assembly in this.assemblies.Values)
-			{
-				allTypes.AddRange(assembly.GetTypes());
-			}
-			return allTypes;
+			return this.types;
 		}
 
 		public void RegisterSystem(Entity component, bool isRegister = true)

+ 27 - 6
Unity/Assets/Model/Base/Object/EventSystem.cs

@@ -637,11 +637,18 @@ namespace ETModel
 			{
 				return;
 			}
-			foreach (AEvent<A> aEvent in iEvents)
+			foreach (object obj in iEvents)
 			{
 				try
 				{
-					aEvent?.Run(a);
+					if (obj is AEvent<A> aEvent)
+					{
+						aEvent.Run(a);
+					}
+					else if (obj is EventProxy eventProxy)
+					{
+						 eventProxy.Handle(a);
+					}
 				}
 				catch (Exception e)
 				{
@@ -657,11 +664,18 @@ namespace ETModel
 			{
 				return;
 			}
-			foreach (AEvent<A, B> aEvent in iEvents)
+			foreach (object obj in iEvents)
 			{
 				try
 				{
-					aEvent.Run(a, b);
+					if (obj is AEvent<A, B> aEvent)
+					{
+						aEvent.Run(a, b);
+					}
+					else if (obj is EventProxy eventProxy)
+					{
+						eventProxy.Handle(a, b);
+					}
 				}
 				catch (Exception e)
 				{
@@ -677,11 +691,18 @@ namespace ETModel
 			{
 				return;
 			}
-			foreach (AEvent<A, B, C> aEvent in iEvents)
+			foreach (object obj in iEvents)
 			{
 				try
 				{
-					aEvent.Run(a, b, c);
+					if (obj is AEvent<A, B, C> aEvent)
+					{
+						aEvent.Run(a, b, c);
+					}
+					else if (obj is EventProxy eventProxy)
+					{
+						eventProxy.Handle(a, b, c);
+					}
 				}
 				catch (Exception e)
 				{

+ 1 - 1
Unity/Assets/Model/Component/SceneChangeComponent.cs

@@ -36,7 +36,7 @@ namespace ETModel
             this.tcs = new ETTaskCompletionSource();
             // 加载map
             this.loadMapOperation = SceneManager.LoadSceneAsync(sceneName);
-            this.loadMapOperation.allowSceneActivation = false;
+            //this.loadMapOperation.allowSceneActivation = false;
             return this.tcs.Task;
         }
 

+ 1 - 2
Unity/Assets/Model/Module/Actor/IActorMessage.cs

@@ -6,9 +6,8 @@
 		long ActorId { get; set; }
 	}
 
-	public interface IActorRequest : IRequest
+	public interface IActorRequest : IActorMessage, IRequest
 	{
-		long ActorId { get; set; }
 	}
 
 	public interface IActorResponse : IResponse

+ 0 - 1
Unity/Assets/Model/Module/AssetsBundle/ResourcesComponent.cs

@@ -303,7 +303,6 @@ namespace ETModel
 				}
 
 				abInfo = EntityFactory.CreateWithParent<ABInfo, string, AssetBundle>(this, assetBundleName, null);
-				abInfo.Parent = this;
 				this.bundles[assetBundleName] = abInfo;
 #endif
 				return;

BIN
Unity/Assets/Res/Code/Hotfix.pdb.bytes


+ 1 - 1
Unity/Assets/Res/Config/GlobalProto.txt

@@ -1 +1 @@
-{"AssetBundleServerUrl":"http://127.0.0.1:8080/","Address":"127.0.0.1:10002"}
+{"AssetBundleServerUrl":"http://127.0.0.1:8080/","Address":"127.0.0.1:10001"}

+ 6 - 3
Unity/ProjectSettings/ProjectSettings.asset

@@ -3,7 +3,7 @@
 --- !u!129 &1
 PlayerSettings:
   m_ObjectHideFlags: 0
-  serializedVersion: 15
+  serializedVersion: 18
   productGUID: 1eb5b450436966b49a962ffe89a9d776
   AndroidProfiler: 0
   AndroidFilterTouchesWhenObscured: 0
@@ -52,8 +52,8 @@ PlayerSettings:
   m_StackTraceTypes: 010000000100000001000000010000000100000001000000
   iosShowActivityIndicatorOnLoading: -1
   androidShowActivityIndicatorOnLoading: -1
-  iosAppInBackgroundBehavior: 0
   displayResolutionDialog: 1
+  iosUseCustomAppBackgroundBehavior: 0
   iosAllowHTTPDownload: 1
   allowedAutorotateToPortrait: 1
   allowedAutorotateToPortraitUpsideDown: 1
@@ -143,6 +143,9 @@ PlayerSettings:
     oculus:
       sharedDepthBuffer: 0
       dashSupport: 0
+      lowOverheadMode: 0
+      protectedContext: 0
+      v2Signing: 0
     enable360StereoCapture: 0
   protectGraphicsMemory: 0
   enableFrameTimingStats: 0
@@ -664,7 +667,7 @@ PlayerSettings:
   webGLLinkerTarget: 1
   webGLThreadsSupport: 0
   scriptingDefineSymbols:
-    1: NET452;ILRuntime
+    1: NET452
     4: NET452;ILRuntime
     7: NET452;ILRuntime
     13: NET452;ILRuntime

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
Unity/Unity.Editor.csproj


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
Unity/Unity.Hotfix.csproj


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
Unity/Unity.Model.csproj


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
Unity/Unity.ThirdParty.csproj


Некоторые файлы не были показаны из-за большого количества измененных файлов