浏览代码

1.增加DesdroySystem
2.规范化文件命名

tanghai 7 年之前
父节点
当前提交
d5d9a96c6b
共有 34 个文件被更改,包括 526 次插入312 次删除
  1. 6 5
      Server/Model/Server.Model.csproj
  2. 3 0
      Unity/Assets/Scripts/Base/Object/Component.cs
  3. 104 38
      Unity/Assets/Scripts/Base/Object/EventSystem.cs
  4. 10 10
      Unity/Assets/Scripts/Base/Object/IAwakeSystem.cs
  5. 0 0
      Unity/Assets/Scripts/Base/Object/IAwakeSystem.cs.meta
  6. 25 0
      Unity/Assets/Scripts/Base/Object/IDestroySystem.cs
  7. 12 0
      Unity/Assets/Scripts/Base/Object/IDestroySystem.cs.meta
  8. 0 25
      Unity/Assets/Scripts/Base/Object/ILateUpdate.cs
  9. 25 0
      Unity/Assets/Scripts/Base/Object/ILateUpdateSystem.cs
  10. 0 0
      Unity/Assets/Scripts/Base/Object/ILateUpdateSystem.cs.meta
  11. 0 25
      Unity/Assets/Scripts/Base/Object/ILoad.cs
  12. 25 0
      Unity/Assets/Scripts/Base/Object/ILoadSystem.cs
  13. 0 0
      Unity/Assets/Scripts/Base/Object/ILoadSystem.cs.meta
  14. 0 25
      Unity/Assets/Scripts/Base/Object/IStart.cs
  15. 25 0
      Unity/Assets/Scripts/Base/Object/IStartSystem.cs
  16. 0 0
      Unity/Assets/Scripts/Base/Object/IStartSystem.cs.meta
  17. 0 25
      Unity/Assets/Scripts/Base/Object/IUpdate.cs
  18. 25 0
      Unity/Assets/Scripts/Base/Object/IUpdateSystem.cs
  19. 0 0
      Unity/Assets/Scripts/Base/Object/IUpdateSystem.cs.meta
  20. 11 0
      Unity/Assets/Scripts/Module/Message/SessionCallbackComponent.cs
  21. 4 0
      Unity/Hotfix/Base/Object/Component.cs
  22. 104 38
      Unity/Hotfix/Base/Object/EventSystem.cs
  23. 10 11
      Unity/Hotfix/Base/Object/IAwakeSystem.cs
  24. 25 0
      Unity/Hotfix/Base/Object/IDestroySystem.cs
  25. 0 25
      Unity/Hotfix/Base/Object/ILateUpdate.cs
  26. 25 0
      Unity/Hotfix/Base/Object/ILateUpdateSystem.cs
  27. 0 25
      Unity/Hotfix/Base/Object/ILoad.cs
  28. 25 0
      Unity/Hotfix/Base/Object/ILoadSystem.cs
  29. 0 25
      Unity/Hotfix/Base/Object/IStart.cs
  30. 25 0
      Unity/Hotfix/Base/Object/IStartSystem.cs
  31. 0 25
      Unity/Hotfix/Base/Object/IUpdate.cs
  32. 25 0
      Unity/Hotfix/Base/Object/IUpdateSystem.cs
  33. 6 5
      Unity/Hotfix/Unity.Hotfix.csproj
  34. 6 5
      Unity/Unity.csproj

+ 6 - 5
Server/Model/Server.Model.csproj

@@ -45,12 +45,13 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ComponentFactory.cs" Link="Base\Object\ComponentFactory.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\Entity.cs" Link="Base\Object\Entity.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\EventSystem.cs" Link="Base\Object\EventSystem.cs" />
-    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\IAwake.cs" Link="Base\Object\IAwake.cs" />
-    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ILateUpdate.cs" Link="Base\Object\ILateUpdate.cs" />
-    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ILoad.cs" Link="Base\Object\ILoad.cs" />
+    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\IAwakeSystem.cs" Link="Base\Object\IAwakeSystem.cs" />
+    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\IDestroySystem.cs" Link="Base\Object\IDestroySystem.cs" />
+    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ILateUpdateSystem.cs" Link="Base\Object\ILateUpdateSystem.cs" />
+    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ILoadSystem.cs" Link="Base\Object\ILoadSystem.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ISerializeToEntity.cs" Link="Base\Object\ISerializeToEntity.cs" />
-    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\IStart.cs" Link="Base\Object\IStart.cs" />
-    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\IUpdate.cs" Link="Base\Object\IUpdate.cs" />
+    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\IStartSystem.cs" Link="Base\Object\IStartSystem.cs" />
+    <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\IUpdateSystem.cs" Link="Base\Object\IUpdateSystem.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\Object.cs" Link="Base\Object\Object.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ObjectPool.cs" Link="Base\Object\ObjectPool.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ObjectSystemAttribute.cs" Link="Base\Object\ObjectSystemAttribute.cs" />

+ 3 - 0
Unity/Assets/Scripts/Base/Object/Component.cs

@@ -92,6 +92,9 @@ namespace ETModel
 			{
 				Game.ObjectPool.Recycle(this);
 			}
+
+			// 触发Desdroy事件
+			Game.EventSystem.Desdroy(this);
 		}
 	}
 }

+ 104 - 38
Unity/Assets/Scripts/Base/Object/EventSystem.cs

@@ -20,15 +20,17 @@ namespace ETModel
 
 		private readonly Dictionary<string, List<IEvent>> allEvents = new Dictionary<string, List<IEvent>>();
 
-		private readonly UnOrderMultiMap<Type, AAwakeSystem> awakeEvents = new UnOrderMultiMap<Type, AAwakeSystem>();
+		private readonly UnOrderMultiMap<Type, IAwakeSystem> awakeEvents = new UnOrderMultiMap<Type, IAwakeSystem>();
 
-		private readonly UnOrderMultiMap<Type, AStartSystem> startEvents = new UnOrderMultiMap<Type, AStartSystem>();
+		private readonly UnOrderMultiMap<Type, IStartSystem> startEvents = new UnOrderMultiMap<Type, IStartSystem>();
 
-		private readonly UnOrderMultiMap<Type, ALoadSystem> loadEvents = new UnOrderMultiMap<Type, ALoadSystem>();
+		private readonly UnOrderMultiMap<Type, IDestroySystem> desdroyEvents = new UnOrderMultiMap<Type, IDestroySystem>();
 
-		private readonly UnOrderMultiMap<Type, AUpdateSystem> updateEvents = new UnOrderMultiMap<Type, AUpdateSystem>();
+		private readonly UnOrderMultiMap<Type, ILoadSystem> loadEvents = new UnOrderMultiMap<Type, ILoadSystem>();
 
-		private readonly UnOrderMultiMap<Type, ALateUpdateSystem> lateUpdateEvents = new UnOrderMultiMap<Type, ALateUpdateSystem>();
+		private readonly UnOrderMultiMap<Type, IUpdateSystem> updateEvents = new UnOrderMultiMap<Type, IUpdateSystem>();
+
+		private readonly UnOrderMultiMap<Type, ILateUpdateSystem> lateUpdateEvents = new UnOrderMultiMap<Type, ILateUpdateSystem>();
 
 		private Queue<long> updates = new Queue<long>();
 		private Queue<long> updates2 = new Queue<long>();
@@ -63,34 +65,40 @@ namespace ETModel
 
 				object obj = Activator.CreateInstance(type);
 
-				AAwakeSystem objectSystem = obj as AAwakeSystem;
+				IAwakeSystem objectSystem = obj as IAwakeSystem;
 				if (objectSystem != null)
 				{
 					this.awakeEvents.Add(objectSystem.Type(), objectSystem);
 				}
 
-				AUpdateSystem aUpdateSystem = obj as AUpdateSystem;
-				if (aUpdateSystem != null)
+				IUpdateSystem updateSystem = obj as IUpdateSystem;
+				if (updateSystem != null)
+				{
+					this.updateEvents.Add(updateSystem.Type(), updateSystem);
+				}
+
+				ILateUpdateSystem lateUpdateSystem = obj as ILateUpdateSystem;
+				if (lateUpdateSystem != null)
 				{
-					this.updateEvents.Add(aUpdateSystem.Type(), aUpdateSystem);
+					this.lateUpdateEvents.Add(lateUpdateSystem.Type(), lateUpdateSystem);
 				}
 
-				ALateUpdateSystem aLateUpdateSystem = obj as ALateUpdateSystem;
-				if (aLateUpdateSystem != null)
+				IStartSystem startSystem = obj as IStartSystem;
+				if (startSystem != null)
 				{
-					this.lateUpdateEvents.Add(aLateUpdateSystem.Type(), aLateUpdateSystem);
+					this.startEvents.Add(startSystem.Type(), startSystem);
 				}
 
-				AStartSystem aStartSystem = obj as AStartSystem;
-				if (aStartSystem != null)
+				IDestroySystem destroySystem = obj as IDestroySystem;
+				if (destroySystem != null)
 				{
-					this.startEvents.Add(aStartSystem.Type(), aStartSystem);
+					this.desdroyEvents.Add(destroySystem.Type(), destroySystem);
 				}
 
-				ALoadSystem aLoadSystem = obj as ALoadSystem;
-				if (aLoadSystem != null)
+				ILoadSystem loadSystem = obj as ILoadSystem;
+				if (loadSystem != null)
 				{
-					this.loadEvents.Add(aLoadSystem.Type(), aLoadSystem);
+					this.loadEvents.Add(loadSystem.Type(), loadSystem);
 				}
 			}
 
@@ -175,13 +183,13 @@ namespace ETModel
 
 		public void Awake(Component component)
 		{
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
+			List<IAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
 			}
 
-			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
+			foreach (IAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
 				if (aAwakeSystem == null)
 				{
@@ -193,19 +201,27 @@ namespace ETModel
 				{
 					continue;
 				}
-				iAwake.Run(component);
+
+				try
+				{
+					iAwake.Run(component);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
+				}
 			}
 		}
 
 		public void Awake<P1>(Component component, P1 p1)
 		{
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
+			List<IAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
 			}
 
-			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
+			foreach (IAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
 				if (aAwakeSystem == null)
 				{
@@ -217,19 +233,27 @@ namespace ETModel
 				{
 					continue;
 				}
-				iAwake.Run(component, p1);
+
+				try
+				{
+					iAwake.Run(component, p1);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
+				}
 			}
 		}
 
 		public void Awake<P1, P2>(Component component, P1 p1, P2 p2)
 		{
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
+			List<IAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
 			}
 
-			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
+			foreach (IAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
 				if (aAwakeSystem == null)
 				{
@@ -241,19 +265,27 @@ namespace ETModel
 				{
 					continue;
 				}
-				iAwake.Run(component, p1, p2);
+
+				try
+				{
+					iAwake.Run(component, p1, p2);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
+				}
 			}
 		}
 
 		public void Awake<P1, P2, P3>(Component component, P1 p1, P2 p2, P3 p3)
 		{
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
+			List<IAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
 			}
 
-			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
+			foreach (IAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
 				if (aAwakeSystem == null)
 				{
@@ -265,7 +297,15 @@ namespace ETModel
 				{
 					continue;
 				}
-				iAwake.Run(component, p1, p2, p3);
+
+				try
+				{
+					iAwake.Run(component, p1, p2, p3);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
+				}
 			}
 		}
 
@@ -284,7 +324,7 @@ namespace ETModel
 					continue;
 				}
 				
-				List<ALoadSystem> aLoadSystems = this.loadEvents[component.GetType()];
+				List<ILoadSystem> aLoadSystems = this.loadEvents[component.GetType()];
 				if (aLoadSystems == null)
 				{
 					continue;
@@ -292,7 +332,7 @@ namespace ETModel
 
 				this.loaders2.Enqueue(instanceId);
 
-				foreach (ALoadSystem aLoadSystem in aLoadSystems)
+				foreach (ILoadSystem aLoadSystem in aLoadSystems)
 				{
 					try
 					{
@@ -319,13 +359,13 @@ namespace ETModel
 					continue;
 				}
 
-				List<AStartSystem> aStartSystems = this.startEvents[component.GetType()];
+				List<IStartSystem> aStartSystems = this.startEvents[component.GetType()];
 				if (aStartSystems == null)
 				{
 					continue;
 				}
 				
-				foreach (AStartSystem aStartSystem in aStartSystems)
+				foreach (IStartSystem aStartSystem in aStartSystems)
 				{
 					try
 					{
@@ -339,6 +379,32 @@ namespace ETModel
 			}
 		}
 
+		public void Desdroy(Component component)
+		{
+			List<IDestroySystem> iDestroySystems = this.desdroyEvents[component.GetType()];
+			if (iDestroySystems == null)
+			{
+				return;
+			}
+
+			foreach (IDestroySystem aDestroySystem in iDestroySystems)
+			{
+				if (aDestroySystem == null)
+				{
+					continue;
+				}
+
+				try
+				{
+					aDestroySystem.Run(component);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
+				}
+			}
+		}
+
 		public void Update()
 		{
 			this.Start();
@@ -356,7 +422,7 @@ namespace ETModel
 					continue;
 				}
 				
-				List<AUpdateSystem> aUpdateSystems = this.updateEvents[component.GetType()];
+				List<IUpdateSystem> aUpdateSystems = this.updateEvents[component.GetType()];
 				if (aUpdateSystems == null)
 				{
 					continue;
@@ -364,7 +430,7 @@ namespace ETModel
 
 				this.updates2.Enqueue(instanceId);
 
-				foreach (AUpdateSystem aUpdateSystem in aUpdateSystems)
+				foreach (IUpdateSystem aUpdateSystem in aUpdateSystems)
 				{
 					try
 					{
@@ -395,7 +461,7 @@ namespace ETModel
 					continue;
 				}
 
-				List<ALateUpdateSystem> aLateUpdateSystems = this.lateUpdateEvents[component.GetType()];
+				List<ILateUpdateSystem> aLateUpdateSystems = this.lateUpdateEvents[component.GetType()];
 				if (aLateUpdateSystems == null)
 				{
 					continue;
@@ -403,7 +469,7 @@ namespace ETModel
 
 				this.lateUpdates2.Enqueue(instanceId);
 
-				foreach (ALateUpdateSystem aLateUpdateSystem in aLateUpdateSystems)
+				foreach (ILateUpdateSystem aLateUpdateSystem in aLateUpdateSystems)
 				{
 					try
 					{

+ 10 - 10
Unity/Assets/Scripts/Base/Object/IAwake.cs → Unity/Assets/Scripts/Base/Object/IAwakeSystem.cs

@@ -2,9 +2,9 @@
 
 namespace ETModel
 {
-	public abstract class AAwakeSystem
+	public interface IAwakeSystem
 	{
-		public abstract Type Type();
+		Type Type();
 	}
 
 	public interface IAwake
@@ -27,9 +27,9 @@ namespace ETModel
 		void Run(object o, A a, B b, C c);
 	}
 
-	public abstract class AwakeSystem<T> : AAwakeSystem, IAwake
+	public abstract class AwakeSystem<T> : IAwakeSystem, IAwake
 	{
-		public override Type Type()
+		public Type Type()
 		{
 			return typeof(T);
 		}
@@ -42,9 +42,9 @@ namespace ETModel
 		public abstract void Awake(T self);
 	}
 
-	public abstract class AwakeSystem<T, A> : AAwakeSystem, IAwake<A>
+	public abstract class AwakeSystem<T, A> : IAwakeSystem, IAwake<A>
 	{
-		public override Type Type()
+		public Type Type()
 		{
 			return typeof(T);
 		}
@@ -57,9 +57,9 @@ namespace ETModel
 		public abstract void Awake(T self, A a);
 	}
 
-	public abstract class AwakeSystem<T, A, B> : AAwakeSystem, IAwake<A, B>
+	public abstract class AwakeSystem<T, A, B> : IAwakeSystem, IAwake<A, B>
 	{
-		public override Type Type()
+		public Type Type()
 		{
 			return typeof(T);
 		}
@@ -72,9 +72,9 @@ namespace ETModel
 		public abstract void Awake(T self, A a, B b);
 	}
 
-	public abstract class AwakeSystem<T, A, B, C> : AAwakeSystem, IAwake<A, B, C>
+	public abstract class AwakeSystem<T, A, B, C> : IAwakeSystem, IAwake<A, B, C>
 	{
-		public override Type Type()
+		public Type Type()
 		{
 			return typeof(T);
 		}

+ 0 - 0
Unity/Assets/Scripts/Base/Object/IAwake.cs.meta → Unity/Assets/Scripts/Base/Object/IAwakeSystem.cs.meta


+ 25 - 0
Unity/Assets/Scripts/Base/Object/IDestroySystem.cs

@@ -0,0 +1,25 @@
+using System;
+
+namespace ETModel
+{
+	public interface IDestroySystem
+	{
+		Type Type();
+		void Run(object o);
+	}
+
+	public abstract class DestroySystem<T> : IDestroySystem
+	{
+		public void Run(object o)
+		{
+			this.Destroy((T)o);
+		}
+
+		public Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Destroy(T self);
+	}
+}

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

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

+ 0 - 25
Unity/Assets/Scripts/Base/Object/ILateUpdate.cs

@@ -1,25 +0,0 @@
-using System;
-
-namespace ETModel
-{
-	public abstract class ALateUpdateSystem
-	{
-		public abstract Type Type();
-		public abstract void Run(object o);
-	}
-
-	public abstract class LateUpdateSystem<T> : ALateUpdateSystem
-	{
-		public override void Run(object o)
-		{
-			this.LateUpdate((T)o);
-		}
-
-		public override Type Type()
-		{
-			return typeof(T);
-		}
-
-		public abstract void LateUpdate(T self);
-	}
-}

+ 25 - 0
Unity/Assets/Scripts/Base/Object/ILateUpdateSystem.cs

@@ -0,0 +1,25 @@
+using System;
+
+namespace ETModel
+{
+	public interface ILateUpdateSystem
+	{
+		Type Type();
+		void Run(object o);
+	}
+
+	public abstract class LateUpdateSystem<T> : ILateUpdateSystem
+	{
+		public void Run(object o)
+		{
+			this.LateUpdate((T)o);
+		}
+
+		public Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void LateUpdate(T self);
+	}
+}

+ 0 - 0
Unity/Assets/Scripts/Base/Object/ILateUpdate.cs.meta → Unity/Assets/Scripts/Base/Object/ILateUpdateSystem.cs.meta


+ 0 - 25
Unity/Assets/Scripts/Base/Object/ILoad.cs

@@ -1,25 +0,0 @@
-using System;
-
-namespace ETModel
-{
-	public abstract class ALoadSystem
-	{
-		public abstract Type Type();
-		public abstract void Run(object o);
-	}
-
-	public abstract class LoadSystem<T> : ALoadSystem
-	{
-		public override void Run(object o)
-		{
-			this.Load((T)o);
-		}
-
-		public override Type Type()
-		{
-			return typeof(T);
-		}
-
-		public abstract void Load(T self);
-	}
-}

+ 25 - 0
Unity/Assets/Scripts/Base/Object/ILoadSystem.cs

@@ -0,0 +1,25 @@
+using System;
+
+namespace ETModel
+{
+	public interface ILoadSystem
+	{
+		Type Type();
+		void Run(object o);
+	}
+
+	public abstract class LoadSystem<T> : ILoadSystem
+	{
+		public void Run(object o)
+		{
+			this.Load((T)o);
+		}
+
+		public Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Load(T self);
+	}
+}

+ 0 - 0
Unity/Assets/Scripts/Base/Object/ILoad.cs.meta → Unity/Assets/Scripts/Base/Object/ILoadSystem.cs.meta


+ 0 - 25
Unity/Assets/Scripts/Base/Object/IStart.cs

@@ -1,25 +0,0 @@
-using System;
-
-namespace ETModel
-{
-	public abstract class AStartSystem
-	{
-		public abstract Type Type();
-		public abstract void Run(object o);
-	}
-
-	public abstract class StartSystem<T> : AStartSystem
-	{
-		public override void Run(object o)
-		{
-			this.Start((T)o);
-		}
-
-		public override Type Type()
-		{
-			return typeof(T);
-		}
-
-		public abstract void Start(T self);
-	}
-}

+ 25 - 0
Unity/Assets/Scripts/Base/Object/IStartSystem.cs

@@ -0,0 +1,25 @@
+using System;
+
+namespace ETModel
+{
+	public interface IStartSystem
+	{
+		Type Type();
+		void Run(object o);
+	}
+
+	public abstract class StartSystem<T> : IStartSystem
+	{
+		public void Run(object o)
+		{
+			this.Start((T)o);
+		}
+
+		public Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Start(T self);
+	}
+}

+ 0 - 0
Unity/Assets/Scripts/Base/Object/IStart.cs.meta → Unity/Assets/Scripts/Base/Object/IStartSystem.cs.meta


+ 0 - 25
Unity/Assets/Scripts/Base/Object/IUpdate.cs

@@ -1,25 +0,0 @@
-using System;
-
-namespace ETModel
-{
-	public abstract class AUpdateSystem
-	{
-		public abstract Type Type();
-		public abstract void Run(object o);
-	}
-
-	public abstract class UpdateSystem<T> : AUpdateSystem
-	{
-		public override void Run(object o)
-		{
-			this.Update((T)o);
-		}
-
-		public override Type Type()
-		{
-			return typeof(T);
-		}
-
-		public abstract void Update(T self);
-	}
-}

+ 25 - 0
Unity/Assets/Scripts/Base/Object/IUpdateSystem.cs

@@ -0,0 +1,25 @@
+using System;
+
+namespace ETModel
+{
+	public interface IUpdateSystem
+	{
+		Type Type();
+		void Run(object o);
+	}
+
+	public abstract class UpdateSystem<T> : IUpdateSystem
+	{
+		public void Run(object o)
+		{
+			this.Update((T)o);
+		}
+
+		public Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Update(T self);
+	}
+}

+ 0 - 0
Unity/Assets/Scripts/Base/Object/IUpdate.cs.meta → Unity/Assets/Scripts/Base/Object/IUpdateSystem.cs.meta


+ 11 - 0
Unity/Assets/Scripts/Module/Message/SessionCallbackComponent.cs

@@ -6,5 +6,16 @@ namespace ETModel
 	{
 		public Action<Session, Packet> MessageCallback;
 		public Action<Session> DisposeCallback;
+
+		public override void Dispose()
+		{
+			if (this.IsDisposed)
+			{
+				return;
+			}
+			base.Dispose();
+
+			this.DisposeCallback?.Invoke(this.GetParent<Session>());
+		}
 	}
 }

+ 4 - 0
Unity/Hotfix/Base/Object/Component.cs

@@ -93,6 +93,10 @@ namespace ETHotfix
 			{
 				Game.ObjectPool.Recycle(this);
 			}
+
+
+			// 触发Desdroy事件
+			Game.EventSystem.Desdroy(this);
 		}
 	}
 }

+ 104 - 38
Unity/Hotfix/Base/Object/EventSystem.cs

@@ -10,15 +10,17 @@ namespace ETHotfix
 
 		private readonly Dictionary<string, List<IEvent>> allEvents = new Dictionary<string, List<IEvent>>();
 
-		private readonly UnOrderMultiMap<Type, AAwakeSystem> awakeEvents = new UnOrderMultiMap<Type, AAwakeSystem>();
+		private readonly UnOrderMultiMap<Type, IAwakeSystem> awakeEvents = new UnOrderMultiMap<Type, IAwakeSystem>();
 
-		private readonly UnOrderMultiMap<Type, AStartSystem> startEvents = new UnOrderMultiMap<Type, AStartSystem>();
+		private readonly UnOrderMultiMap<Type, IStartSystem> startEvents = new UnOrderMultiMap<Type, IStartSystem>();
 
-		private readonly UnOrderMultiMap<Type, ALoadSystem> loadEvents = new UnOrderMultiMap<Type, ALoadSystem>();
+		private readonly UnOrderMultiMap<Type, IDestroySystem> desdroyEvents = new UnOrderMultiMap<Type, IDestroySystem>();
 
-		private readonly UnOrderMultiMap<Type, AUpdateSystem> updateEvents = new UnOrderMultiMap<Type, AUpdateSystem>();
+		private readonly UnOrderMultiMap<Type, ILoadSystem> loadEvents = new UnOrderMultiMap<Type, ILoadSystem>();
 
-		private readonly UnOrderMultiMap<Type, ALateUpdateSystem> lateUpdateEvents = new UnOrderMultiMap<Type, ALateUpdateSystem>();
+		private readonly UnOrderMultiMap<Type, IUpdateSystem> updateEvents = new UnOrderMultiMap<Type, IUpdateSystem>();
+
+		private readonly UnOrderMultiMap<Type, ILateUpdateSystem> lateUpdateEvents = new UnOrderMultiMap<Type, ILateUpdateSystem>();
 
 		private Queue<long> updates = new Queue<long>();
 		private Queue<long> updates2 = new Queue<long>();
@@ -45,34 +47,40 @@ namespace ETHotfix
 
 				object obj = Activator.CreateInstance(type);
 
-				AAwakeSystem objectSystem = obj as AAwakeSystem;
+				IAwakeSystem objectSystem = obj as IAwakeSystem;
 				if (objectSystem != null)
 				{
 					this.awakeEvents.Add(objectSystem.Type(), objectSystem);
 				}
 
-				AUpdateSystem aUpdateSystem = obj as AUpdateSystem;
-				if (aUpdateSystem != null)
+				IUpdateSystem updateSystem = obj as IUpdateSystem;
+				if (updateSystem != null)
+				{
+					this.updateEvents.Add(updateSystem.Type(), updateSystem);
+				}
+
+				ILateUpdateSystem lateUpdateSystem = obj as ILateUpdateSystem;
+				if (lateUpdateSystem != null)
 				{
-					this.updateEvents.Add(aUpdateSystem.Type(), aUpdateSystem);
+					this.lateUpdateEvents.Add(lateUpdateSystem.Type(), lateUpdateSystem);
 				}
 
-				ALateUpdateSystem aLateUpdateSystem = obj as ALateUpdateSystem;
-				if (aLateUpdateSystem != null)
+				IStartSystem startSystem = obj as IStartSystem;
+				if (startSystem != null)
 				{
-					this.lateUpdateEvents.Add(aLateUpdateSystem.Type(), aLateUpdateSystem);
+					this.startEvents.Add(startSystem.Type(), startSystem);
 				}
 
-				AStartSystem aStartSystem = obj as AStartSystem;
-				if (aStartSystem != null)
+				IDestroySystem destroySystem = obj as IDestroySystem;
+				if (destroySystem != null)
 				{
-					this.startEvents.Add(aStartSystem.Type(), aStartSystem);
+					this.desdroyEvents.Add(destroySystem.Type(), destroySystem);
 				}
 
-				ALoadSystem aLoadSystem = obj as ALoadSystem;
-				if (aLoadSystem != null)
+				ILoadSystem loadSystem = obj as ILoadSystem;
+				if (loadSystem != null)
 				{
-					this.loadEvents.Add(aLoadSystem.Type(), aLoadSystem);
+					this.loadEvents.Add(loadSystem.Type(), loadSystem);
 				}
 			}
 
@@ -163,13 +171,13 @@ namespace ETHotfix
 
 		public void Awake(Component component)
 		{
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
+			List<IAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
 			}
 
-			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
+			foreach (IAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
 				if (aAwakeSystem == null)
 				{
@@ -181,19 +189,27 @@ namespace ETHotfix
 				{
 					continue;
 				}
-				iAwake.Run(component);
+
+				try
+				{
+					iAwake.Run(component);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
+				}
 			}
 		}
 
 		public void Awake<P1>(Component component, P1 p1)
 		{
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
+			List<IAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
 			}
 			
-			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
+			foreach (IAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
 				if (aAwakeSystem == null)
 				{
@@ -205,19 +221,27 @@ namespace ETHotfix
 				{
 					continue;
 				}
-				iAwake.Run(component, p1);
+
+				try
+				{
+					iAwake.Run(component, p1);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
+				}
 			}
 		}
 
 		public void Awake<P1, P2>(Component component, P1 p1, P2 p2)
 		{
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
+			List<IAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
 			}
 
-			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
+			foreach (IAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
 				if (aAwakeSystem == null)
 				{
@@ -229,19 +253,27 @@ namespace ETHotfix
 				{
 					continue;
 				}
-				iAwake.Run(component, p1, p2);
+
+				try
+				{
+					iAwake.Run(component, p1, p2);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
+				}
 			}
 		}
 
 		public void Awake<P1, P2, P3>(Component component, P1 p1, P2 p2, P3 p3)
 		{
-			List<AAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
+			List<IAwakeSystem> iAwakeSystems = this.awakeEvents[component.GetType()];
 			if (iAwakeSystems == null)
 			{
 				return;
 			}
 
-			foreach (AAwakeSystem aAwakeSystem in iAwakeSystems)
+			foreach (IAwakeSystem aAwakeSystem in iAwakeSystems)
 			{
 				if (aAwakeSystem == null)
 				{
@@ -253,7 +285,15 @@ namespace ETHotfix
 				{
 					continue;
 				}
-				iAwake.Run(component, p1, p2, p3);
+
+				try
+				{
+					iAwake.Run(component, p1, p2, p3);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
+				}
 			}
 		}
 
@@ -272,7 +312,7 @@ namespace ETHotfix
 					continue;
 				}
 				
-				List<ALoadSystem> aLoadSystems = this.loadEvents[component.GetType()];
+				List<ILoadSystem> aLoadSystems = this.loadEvents[component.GetType()];
 				if (aLoadSystems == null)
 				{
 					continue;
@@ -280,7 +320,7 @@ namespace ETHotfix
 
 				this.loaders2.Enqueue(instanceId);
 
-				foreach (ALoadSystem aLoadSystem in aLoadSystems)
+				foreach (ILoadSystem aLoadSystem in aLoadSystems)
 				{
 					try
 					{
@@ -307,13 +347,13 @@ namespace ETHotfix
 					continue;
 				}
 
-				List<AStartSystem> aStartSystems = this.startEvents[component.GetType()];
+				List<IStartSystem> aStartSystems = this.startEvents[component.GetType()];
 				if (aStartSystems == null)
 				{
 					continue;
 				}
 
-				foreach (AStartSystem aStartSystem in aStartSystems)
+				foreach (IStartSystem aStartSystem in aStartSystems)
 				{
 					try
 					{
@@ -327,6 +367,32 @@ namespace ETHotfix
 			}
 		}
 
+		public void Desdroy(Component component)
+		{
+			List<IDestroySystem> iDestroySystems = this.desdroyEvents[component.GetType()];
+			if (iDestroySystems == null)
+			{
+				return;
+			}
+
+			foreach (IDestroySystem aDestroySystem in iDestroySystems)
+			{
+				if (aDestroySystem == null)
+				{
+					continue;
+				}
+
+				try
+				{
+					aDestroySystem.Run(component);
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
+				}
+			}
+		}
+
 		public void Update()
 		{
 			this.Start();
@@ -344,7 +410,7 @@ namespace ETHotfix
 					continue;
 				}
 				
-				List<AUpdateSystem> aUpdateSystems = this.updateEvents[component.GetType()];
+				List<IUpdateSystem> aUpdateSystems = this.updateEvents[component.GetType()];
 				if (aUpdateSystems == null)
 				{
 					continue;
@@ -352,7 +418,7 @@ namespace ETHotfix
 
 				this.updates2.Enqueue(instanceId);
 
-				foreach (AUpdateSystem aUpdateSystem in aUpdateSystems)
+				foreach (IUpdateSystem aUpdateSystem in aUpdateSystems)
 				{
 					try
 					{
@@ -383,7 +449,7 @@ namespace ETHotfix
 					continue;
 				}
 				
-				List<ALateUpdateSystem> aLateUpdateSystems = this.lateUpdateEvents[component.GetType()];
+				List<ILateUpdateSystem> aLateUpdateSystems = this.lateUpdateEvents[component.GetType()];
 				if (aLateUpdateSystems == null)
 				{
 					continue;
@@ -391,7 +457,7 @@ namespace ETHotfix
 
 				this.lateUpdates2.Enqueue(instanceId);
 
-				foreach (ALateUpdateSystem aLateUpdateSystem in aLateUpdateSystems)
+				foreach (ILateUpdateSystem aLateUpdateSystem in aLateUpdateSystems)
 				{
 					try
 					{

+ 10 - 11
Unity/Hotfix/Base/Object/IAwake.cs → Unity/Hotfix/Base/Object/IAwakeSystem.cs

@@ -1,11 +1,10 @@
 using System;
-using ETModel;
 
 namespace ETHotfix
 {
-	public abstract class AAwakeSystem
+	public interface IAwakeSystem
 	{
-		public abstract Type Type();
+		Type Type();
 	}
 
 	public interface IAwake
@@ -28,9 +27,9 @@ namespace ETHotfix
 		void Run(object o, A a, B b, C c);
 	}
 
-	public abstract class AwakeSystem<T> : AAwakeSystem, IAwake
+	public abstract class AwakeSystem<T> : IAwakeSystem, IAwake
 	{
-		public override Type Type()
+		public Type Type()
 		{
 			return typeof(T);
 		}
@@ -43,9 +42,9 @@ namespace ETHotfix
 		public abstract void Awake(T self);
 	}
 
-	public abstract class AwakeSystem<T, A> : AAwakeSystem, IAwake<A>
+	public abstract class AwakeSystem<T, A> : IAwakeSystem, IAwake<A>
 	{
-		public override Type Type()
+		public Type Type()
 		{
 			return typeof(T);
 		}
@@ -58,9 +57,9 @@ namespace ETHotfix
 		public abstract void Awake(T self, A a);
 	}
 
-	public abstract class AwakeSystem<T, A, B> : AAwakeSystem, IAwake<A, B>
+	public abstract class AwakeSystem<T, A, B> : IAwakeSystem, IAwake<A, B>
 	{
-		public override Type Type()
+		public Type Type()
 		{
 			return typeof(T);
 		}
@@ -73,9 +72,9 @@ namespace ETHotfix
 		public abstract void Awake(T self, A a, B b);
 	}
 
-	public abstract class AwakeSystem<T, A, B, C> : AAwakeSystem, IAwake<A, B, C>
+	public abstract class AwakeSystem<T, A, B, C> : IAwakeSystem, IAwake<A, B, C>
 	{
-		public override Type Type()
+		public Type Type()
 		{
 			return typeof(T);
 		}

+ 25 - 0
Unity/Hotfix/Base/Object/IDestroySystem.cs

@@ -0,0 +1,25 @@
+using System;
+
+namespace ETHotfix
+{
+	public interface IDestroySystem
+	{
+		Type Type();
+		void Run(object o);
+	}
+
+	public abstract class DestroySystem<T> : IDestroySystem
+	{
+		public void Run(object o)
+		{
+			this.Destroy((T)o);
+		}
+
+		public Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Destroy(T self);
+	}
+}

+ 0 - 25
Unity/Hotfix/Base/Object/ILateUpdate.cs

@@ -1,25 +0,0 @@
-using System;
-
-namespace ETHotfix
-{
-	public abstract class ALateUpdateSystem
-	{
-		public abstract Type Type();
-		public abstract void Run(object o);
-	}
-
-	public abstract class LateUpdateSystem<T> : ALateUpdateSystem
-	{
-		public override void Run(object o)
-		{
-			this.LateUpdate((T)o);
-		}
-
-		public override Type Type()
-		{
-			return typeof(T);
-		}
-
-		public abstract void LateUpdate(T self);
-	}
-}

+ 25 - 0
Unity/Hotfix/Base/Object/ILateUpdateSystem.cs

@@ -0,0 +1,25 @@
+using System;
+
+namespace ETHotfix
+{
+	public interface ILateUpdateSystem
+	{
+		Type Type();
+		void Run(object o);
+	}
+
+	public abstract class LateUpdateSystem<T> : ILateUpdateSystem
+	{
+		public void Run(object o)
+		{
+			this.LateUpdate((T)o);
+		}
+
+		public Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void LateUpdate(T self);
+	}
+}

+ 0 - 25
Unity/Hotfix/Base/Object/ILoad.cs

@@ -1,25 +0,0 @@
-using System;
-
-namespace ETHotfix
-{
-	public abstract class ALoadSystem
-	{
-		public abstract Type Type();
-		public abstract void Run(object o);
-	}
-
-	public abstract class LoadSystem<T> : ALoadSystem
-	{
-		public override void Run(object o)
-		{
-			this.Load((T)o);
-		}
-
-		public override Type Type()
-		{
-			return typeof(T);
-		}
-
-		public abstract void Load(T self);
-	}
-}

+ 25 - 0
Unity/Hotfix/Base/Object/ILoadSystem.cs

@@ -0,0 +1,25 @@
+using System;
+
+namespace ETHotfix
+{
+	public interface ILoadSystem
+	{
+		Type Type();
+		void Run(object o);
+	}
+
+	public abstract class LoadSystem<T> : ILoadSystem
+	{
+		public void Run(object o)
+		{
+			this.Load((T)o);
+		}
+
+		public Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Load(T self);
+	}
+}

+ 0 - 25
Unity/Hotfix/Base/Object/IStart.cs

@@ -1,25 +0,0 @@
-using System;
-
-namespace ETHotfix
-{
-	public abstract class AStartSystem
-	{
-		public abstract Type Type();
-		public abstract void Run(object o);
-	}
-
-	public abstract class StartSystem<T> : AStartSystem
-	{
-		public override void Run(object o)
-		{
-			this.Start((T)o);
-		}
-
-		public override Type Type()
-		{
-			return typeof(T);
-		}
-
-		public abstract void Start(T self);
-	}
-}

+ 25 - 0
Unity/Hotfix/Base/Object/IStartSystem.cs

@@ -0,0 +1,25 @@
+using System;
+
+namespace ETHotfix
+{
+	public interface IStartSystem
+	{
+		Type Type();
+		void Run(object o);
+	}
+
+	public abstract class StartSystem<T> : IStartSystem
+	{
+		public void Run(object o)
+		{
+			this.Start((T)o);
+		}
+
+		public Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Start(T self);
+	}
+}

+ 0 - 25
Unity/Hotfix/Base/Object/IUpdate.cs

@@ -1,25 +0,0 @@
-using System;
-
-namespace ETHotfix
-{
-	public abstract class AUpdateSystem
-	{
-		public abstract Type Type();
-		public abstract void Run(object o);
-	}
-
-	public abstract class UpdateSystem<T> : AUpdateSystem
-	{
-		public override void Run(object o)
-		{
-			this.Update((T)o);
-		}
-
-		public override Type Type()
-		{
-			return typeof(T);
-		}
-
-		public abstract void Update(T self);
-	}
-}

+ 25 - 0
Unity/Hotfix/Base/Object/IUpdateSystem.cs

@@ -0,0 +1,25 @@
+using System;
+
+namespace ETHotfix
+{
+	public interface IUpdateSystem
+	{
+		Type Type();
+		void Run(object o);
+	}
+
+	public abstract class UpdateSystem<T> : IUpdateSystem
+	{
+		public void Run(object o)
+		{
+			this.Update((T)o);
+		}
+
+		public Type Type()
+		{
+			return typeof(T);
+		}
+
+		public abstract void Update(T self);
+	}
+}

+ 6 - 5
Unity/Hotfix/Unity.Hotfix.csproj

@@ -56,7 +56,8 @@
     <Compile Include="Base\Helper\ExceptionHelper.cs" />
     <Compile Include="Base\Helper\JsonHelper.cs" />
     <Compile Include="Base\Helper\Log.cs" />
-    <Compile Include="Base\Object\IStart.cs" />
+    <Compile Include="Base\Object\IDestroySystem.cs" />
+    <Compile Include="Base\Object\IStartSystem.cs" />
     <Compile Include="Module\FrameSync\OperaComponent.cs" />
     <Compile Include="Entity\Config\UnitConfig.cs" />
     <Compile Include="Module\FrameSync\TestHotfixSubscribMonoEvent_LogString.cs" />
@@ -77,11 +78,11 @@
     <Compile Include="Base\Object\ComponentFactory.cs" />
     <Compile Include="Base\Object\Entity.cs" />
     <Compile Include="Base\Object\EntityType.cs" />
-    <Compile Include="Base\Object\IAwake.cs" />
-    <Compile Include="Base\Object\ILateUpdate.cs" />
-    <Compile Include="Base\Object\ILoad.cs" />
+    <Compile Include="Base\Object\IAwakeSystem.cs" />
+    <Compile Include="Base\Object\ILateUpdateSystem.cs" />
+    <Compile Include="Base\Object\ILoadSystem.cs" />
     <Compile Include="Base\Object\ISerializeToEntity.cs" />
-    <Compile Include="Base\Object\IUpdate.cs" />
+    <Compile Include="Base\Object\IUpdateSystem.cs" />
     <Compile Include="Base\Object\Object.cs" />
     <Compile Include="Base\Object\EventSystem.cs" />
     <Compile Include="Base\Object\ObjectPool.cs" />

+ 6 - 5
Unity/Unity.csproj

@@ -165,12 +165,13 @@
     <Compile Include="Assets\Scripts\Base\Object\EntityType.cs" />
     <Compile Include="Assets\Scripts\Base\Object\EventProxy.cs" />
     <Compile Include="Assets\Scripts\Base\Object\EventSystem.cs" />
-    <Compile Include="Assets\Scripts\Base\Object\IAwake.cs" />
-    <Compile Include="Assets\Scripts\Base\Object\ILateUpdate.cs" />
-    <Compile Include="Assets\Scripts\Base\Object\ILoad.cs" />
+    <Compile Include="Assets\Scripts\Base\Object\IAwakeSystem.cs" />
+    <Compile Include="Assets\Scripts\Base\Object\ILateUpdateSystem.cs" />
+    <Compile Include="Assets\Scripts\Base\Object\IDestroySystem.cs" />
+    <Compile Include="Assets\Scripts\Base\Object\ILoadSystem.cs" />
     <Compile Include="Assets\Scripts\Base\Object\ISerializeToEntity.cs" />
-    <Compile Include="Assets\Scripts\Base\Object\IStart.cs" />
-    <Compile Include="Assets\Scripts\Base\Object\IUpdate.cs" />
+    <Compile Include="Assets\Scripts\Base\Object\IStartSystem.cs" />
+    <Compile Include="Assets\Scripts\Base\Object\IUpdateSystem.cs" />
     <Compile Include="Assets\Scripts\Base\Object\Object.cs" />
     <Compile Include="Assets\Scripts\Base\Object\ObjectPool.cs" />
     <Compile Include="Assets\Scripts\Base\Object\ObjectSystemAttribute.cs" />