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

去掉ChangeSystem跟StartSystem,没什么作用

tanghai 4 лет назад
Родитель
Сommit
b215869f73

+ 2 - 9
Server/Hotfix/Module/Console/ConsoleComponentSystem.cs

@@ -11,6 +11,8 @@ namespace ET
         public override void Awake(ConsoleComponent self)
         public override void Awake(ConsoleComponent self)
         {
         {
             self.Load();
             self.Load();
+            
+            self.Start().Coroutine();
         }
         }
     }
     }
 
 
@@ -22,15 +24,6 @@ namespace ET
             self.Load();
             self.Load();
         }
         }
     }
     }
-    
-    [ObjectSystem]
-    public class ConsoleComponentStartSystem: StartSystem<ConsoleComponent>
-    {
-        public override void Start(ConsoleComponent self)
-        {
-            self.Start().Coroutine();
-        }
-    }
 
 
     public static class ConsoleComponentSystem
     public static class ConsoleComponentSystem
     {
     {

+ 3 - 7
Unity/Assets/HotfixView/Demo/UI/UILoading/UILoadingComponentSystem.cs

@@ -8,17 +8,13 @@ namespace ET
         public override void Awake(UILoadingComponent self)
         public override void Awake(UILoadingComponent self)
         {
         {
             self.text = self.GetParent<UI>().GameObject.Get<GameObject>("Text").GetComponent<Text>();
             self.text = self.GetParent<UI>().GameObject.Get<GameObject>("Text").GetComponent<Text>();
+            self.StartAsync().Coroutine();
         }
         }
     }
     }
 
 
-    public class UiLoadingComponentStartSystem : StartSystem<UILoadingComponent>
+    public static class UiLoadingComponentSystem
     {
     {
-        public override void Start(UILoadingComponent self)
-        {
-            StartAsync(self).Coroutine();
-        }
-		
-        public async ETVoid StartAsync(UILoadingComponent self)
+        public static async ETVoid StartAsync(this UILoadingComponent self)
         {
         {
             long instanceId = self.InstanceId;
             long instanceId = self.InstanceId;
             while (true)
             while (true)

+ 0 - 10
Unity/Assets/Model/Core/LogType.cs

@@ -1,10 +0,0 @@
-namespace ET
-{
-	public enum LogType
-	{
-		Warning,
-		Info,
-		Debug,
-		Error,
-	}
-}

+ 0 - 11
Unity/Assets/Model/Core/LogType.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 59ae157db487546adb23bcf4289701a1
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 23
Unity/Assets/Model/Core/MultiMapComponent.cs

@@ -1,23 +0,0 @@
-/**
- * 封装MultiMap,用于重用
- */
-
-namespace ET
-{
-    public class MultiMapComponent<T, K>: Entity
-    {
-        public MultiMap<T, K> MultiMap = new MultiMap<T, K>();
-
-        public override void Dispose()
-        {
-            if (this.IsDisposed)
-            {
-                return;
-            }
-
-            base.Dispose();
-
-            this.MultiMap.Clear();
-        }
-    }
-}

+ 0 - 11
Unity/Assets/Model/Core/MultiMapComponent.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 5255e91aeb9e14d9d8dad8cd7d1f0659
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 1 - 77
Unity/Assets/Model/Core/Object/EventSystem.cs

@@ -28,8 +28,6 @@ namespace ET
 
 
 		private readonly UnOrderMultiMap<Type, IAwakeSystem> awakeSystems = new UnOrderMultiMap<Type, IAwakeSystem>();
 		private readonly UnOrderMultiMap<Type, IAwakeSystem> awakeSystems = new UnOrderMultiMap<Type, IAwakeSystem>();
 
 
-		private readonly UnOrderMultiMap<Type, IStartSystem> startSystems = new UnOrderMultiMap<Type, IStartSystem>();
-
 		private readonly UnOrderMultiMap<Type, IDestroySystem> destroySystems = new UnOrderMultiMap<Type, IDestroySystem>();
 		private readonly UnOrderMultiMap<Type, IDestroySystem> destroySystems = new UnOrderMultiMap<Type, IDestroySystem>();
 
 
 		private readonly UnOrderMultiMap<Type, ILoadSystem> loadSystems = new UnOrderMultiMap<Type, ILoadSystem>();
 		private readonly UnOrderMultiMap<Type, ILoadSystem> loadSystems = new UnOrderMultiMap<Type, ILoadSystem>();
@@ -37,8 +35,6 @@ namespace ET
 		private readonly UnOrderMultiMap<Type, IUpdateSystem> updateSystems = new UnOrderMultiMap<Type, IUpdateSystem>();
 		private readonly UnOrderMultiMap<Type, IUpdateSystem> updateSystems = new UnOrderMultiMap<Type, IUpdateSystem>();
 
 
 		private readonly UnOrderMultiMap<Type, ILateUpdateSystem> lateUpdateSystems = new UnOrderMultiMap<Type, ILateUpdateSystem>();
 		private readonly UnOrderMultiMap<Type, ILateUpdateSystem> lateUpdateSystems = new UnOrderMultiMap<Type, ILateUpdateSystem>();
-
-		private readonly UnOrderMultiMap<Type, IChangeSystem> changeSystems = new UnOrderMultiMap<Type, IChangeSystem>();
 		
 		
 		private readonly UnOrderMultiMap<Type, IDeserializeSystem> deserializeSystems = new UnOrderMultiMap<Type, IDeserializeSystem>();
 		private readonly UnOrderMultiMap<Type, IDeserializeSystem> deserializeSystems = new UnOrderMultiMap<Type, IDeserializeSystem>();
 		
 		
@@ -87,9 +83,7 @@ namespace ET
 			this.awakeSystems.Clear();
 			this.awakeSystems.Clear();
 			this.lateUpdateSystems.Clear();
 			this.lateUpdateSystems.Clear();
 			this.updateSystems.Clear();
 			this.updateSystems.Clear();
-			this.startSystems.Clear();
 			this.loadSystems.Clear();
 			this.loadSystems.Clear();
-			this.changeSystems.Clear();
 			this.destroySystems.Clear();
 			this.destroySystems.Clear();
 			this.deserializeSystems.Clear();
 			this.deserializeSystems.Clear();
 			
 			
@@ -107,18 +101,12 @@ namespace ET
 					case ILateUpdateSystem lateUpdateSystem:
 					case ILateUpdateSystem lateUpdateSystem:
 						this.lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem);
 						this.lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem);
 						break;
 						break;
-					case IStartSystem startSystem:
-						this.startSystems.Add(startSystem.Type(), startSystem);
-						break;
 					case IDestroySystem destroySystem:
 					case IDestroySystem destroySystem:
 						this.destroySystems.Add(destroySystem.Type(), destroySystem);
 						this.destroySystems.Add(destroySystem.Type(), destroySystem);
 						break;
 						break;
 					case ILoadSystem loadSystem:
 					case ILoadSystem loadSystem:
 						this.loadSystems.Add(loadSystem.Type(), loadSystem);
 						this.loadSystems.Add(loadSystem.Type(), loadSystem);
 						break;
 						break;
-					case IChangeSystem changeSystem:
-						this.changeSystems.Add(changeSystem.Type(), changeSystem);
-						break;
 					case IDeserializeSystem deserializeSystem:
 					case IDeserializeSystem deserializeSystem:
 						this.deserializeSystems.Add(deserializeSystem.Type(), deserializeSystem);
 						this.deserializeSystems.Add(deserializeSystem.Type(), deserializeSystem);
 						break;
 						break;
@@ -195,11 +183,6 @@ namespace ET
 				this.updates.Enqueue(component.InstanceId);
 				this.updates.Enqueue(component.InstanceId);
 			}
 			}
 
 
-			if (this.startSystems.ContainsKey(type))
-			{
-				this.starts.Enqueue(component.InstanceId);
-			}
-
 			if (this.lateUpdateSystems.ContainsKey(type))
 			if (this.lateUpdateSystems.ContainsKey(type))
 			{
 			{
 				this.lateUpdates.Enqueue(component.InstanceId);
 				this.lateUpdates.Enqueue(component.InstanceId);
@@ -409,33 +392,7 @@ namespace ET
             }
             }
         }
         }
 
 
-        public void Change(Entity component)
-		{
-			List<IChangeSystem> iChangeSystems = this.changeSystems[component.GetType()];
-			if (iChangeSystems == null)
-			{
-				return;
-			}
-
-			foreach (IChangeSystem iChangeSystem in iChangeSystems)
-			{
-				if (iChangeSystem == null)
-				{
-					continue;
-				}
-
-				try
-				{
-					iChangeSystem.Run(component);
-				}
-				catch (Exception e)
-				{
-					Log.Error(e);
-				}
-			}
-		}
-
-		public void Load()
+        public void Load()
 		{
 		{
 			while (this.loaders.Count > 0)
 			while (this.loaders.Count > 0)
 			{
 			{
@@ -474,37 +431,6 @@ namespace ET
 			ObjectHelper.Swap(ref this.loaders, ref this.loaders2);
 			ObjectHelper.Swap(ref this.loaders, ref this.loaders2);
 		}
 		}
 
 
-		private void Start()
-		{
-			while (this.starts.Count > 0)
-			{
-				long instanceId = this.starts.Dequeue();
-				Entity component;
-				if (!this.allComponents.TryGetValue(instanceId, out component))
-				{
-					continue;
-				}
-
-				List<IStartSystem> iStartSystems = this.startSystems[component.GetType()];
-				if (iStartSystems == null)
-				{
-					continue;
-				}
-				
-				foreach (IStartSystem iStartSystem in iStartSystems)
-				{
-					try
-					{
-						iStartSystem.Run(component);
-					}
-					catch (Exception e)
-					{
-						Log.Error(e);
-					}
-				}
-			}
-		}
-
 		public void Destroy(Entity component)
 		public void Destroy(Entity component)
 		{
 		{
 			List<IDestroySystem> iDestroySystems = this.destroySystems[component.GetType()];
 			List<IDestroySystem> iDestroySystems = this.destroySystems[component.GetType()];
@@ -533,8 +459,6 @@ namespace ET
 		
 		
 		public void Update()
 		public void Update()
 		{
 		{
-			this.Start();
-			
 			while (this.updates.Count > 0)
 			while (this.updates.Count > 0)
 			{
 			{
 				long instanceId = this.updates.Dequeue();
 				long instanceId = this.updates.Dequeue();

+ 0 - 26
Unity/Assets/Model/Core/Object/IChangeSystem.cs

@@ -1,26 +0,0 @@
-using System;
-
-namespace ET
-{
-	public interface IChangeSystem
-	{
-		Type Type();
-		void Run(object o);
-	}
-
-	[ObjectSystem]
-	public abstract class ChangeSystem<T> : IChangeSystem
-	{
-		public void Run(object o)
-		{
-			this.Change((T)o);
-		}
-
-		public Type Type()
-		{
-			return typeof(T);
-		}
-
-		public abstract void Change(T self);
-	}
-}

+ 0 - 12
Unity/Assets/Model/Core/Object/IChangeSystem.cs.meta

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

+ 0 - 26
Unity/Assets/Model/Core/Object/IStartSystem.cs

@@ -1,26 +0,0 @@
-using System;
-
-namespace ET
-{
-	public interface IStartSystem
-	{
-		Type Type();
-		void Run(object o);
-	}
-
-	[ObjectSystem]
-	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 - 3
Unity/Assets/Model/Core/Object/IStartSystem.cs.meta

@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: 5a6304f22c9f47b4b5992372e8080252
-timeCreated: 1504145679

+ 12 - 61
Unity/Assets/Model/Core/UnOrderMultiMapSet.cs

@@ -7,19 +7,15 @@ using System.Collections.Generic;
 
 
 namespace ET
 namespace ET
 {
 {
-    public class UnOrderMultiMapSet<T, K>
+    public class UnOrderMultiMapSet<T, K>: Dictionary<T, HashSet<K>>
     {
     {
-        private readonly Dictionary<T, HashSet<K>> dictionary = new Dictionary<T, HashSet<K>>();
-
         // 重用HashSet
         // 重用HashSet
-        private readonly Queue<HashSet<K>> queue = new Queue<HashSet<K>>();
-        
-        public HashSet<K> this[T t]
+        public new HashSet<K> this[T t]
         {
         {
             get
             get
             {
             {
                 HashSet<K> set;
                 HashSet<K> set;
-                if (!this.dictionary.TryGetValue(t, out set))
+                if (!this.TryGetValue(t, out set))
                 {
                 {
                     set = new HashSet<K>();
                     set = new HashSet<K>();
                 }
                 }
@@ -29,17 +25,17 @@ namespace ET
         
         
         public Dictionary<T, HashSet<K>> GetDictionary()
         public Dictionary<T, HashSet<K>> GetDictionary()
         {
         {
-            return this.dictionary;
+            return this;
         }
         }
         
         
         public void Add(T t, K k)
         public void Add(T t, K k)
         {
         {
             HashSet<K> set;
             HashSet<K> set;
-            this.dictionary.TryGetValue(t, out set);
+            this.TryGetValue(t, out set);
             if (set == null)
             if (set == null)
             {
             {
-                set = this.FetchList();
-                this.dictionary[t] = set;
+                set = new HashSet<K>();
+                base[t] = set;
             }
             }
             set.Add(k);
             set.Add(k);
         }
         }
@@ -47,7 +43,7 @@ namespace ET
         public bool Remove(T t, K k)
         public bool Remove(T t, K k)
         {
         {
             HashSet<K> set;
             HashSet<K> set;
-            this.dictionary.TryGetValue(t, out set);
+            this.TryGetValue(t, out set);
             if (set == null)
             if (set == null)
             {
             {
                 return false;
                 return false;
@@ -58,73 +54,28 @@ namespace ET
             }
             }
             if (set.Count == 0)
             if (set.Count == 0)
             {
             {
-                this.RecycleList(set);
-                this.dictionary.Remove(t);
+                this.Remove(t);
             }
             }
             return true;
             return true;
         }
         }
 
 
-        public bool Remove(T t)
-        {
-            HashSet<K> set = null;
-            this.dictionary.TryGetValue(t, out set);
-            if (set != null)
-            {
-                this.RecycleList(set);
-            }
-            return this.dictionary.Remove(t);
-        }
-        
-                
-        private HashSet<K> FetchList()
-        {
-            if (this.queue.Count > 0)
-            {
-                HashSet<K> set = this.queue.Dequeue();
-                set.Clear();
-                return set;
-            }
-            return new HashSet<K>();
-        }
-        
-        private void RecycleList(HashSet<K> set)
-        {
-            // 防止暴涨
-            if (this.queue.Count > 100)
-            {
-                return;
-            }
-            set.Clear();
-            this.queue.Enqueue(set);
-        }
-
         public bool Contains(T t, K k)
         public bool Contains(T t, K k)
         {
         {
             HashSet<K> set;
             HashSet<K> set;
-            this.dictionary.TryGetValue(t, out set);
+            this.TryGetValue(t, out set);
             if (set == null)
             if (set == null)
             {
             {
                 return false;
                 return false;
             }
             }
             return set.Contains(k);
             return set.Contains(k);
         }
         }
-        
-        public bool ContainsKey(T t)
-        {
-            return this.dictionary.ContainsKey(t);
-        }
-
-        public void Clear()
-        {
-            dictionary.Clear();
-        }
 
 
-        public int Count
+        public new int Count
         {
         {
             get
             get
             {
             {
                 int count = 0;
                 int count = 0;
-                foreach (KeyValuePair<T,HashSet<K>> kv in this.dictionary)
+                foreach (KeyValuePair<T,HashSet<K>> kv in this)
                 {
                 {
                     count += kv.Value.Count;
                     count += kv.Value.Count;
                 }
                 }

+ 2 - 2
Unity/Unity.Mono.csproj

@@ -55,10 +55,12 @@
      <Compile Include="Assets\Mono\Core\Helper\NetworkHelper.cs" />
      <Compile Include="Assets\Mono\Core\Helper\NetworkHelper.cs" />
      <Compile Include="Assets\Mono\MonoBehaviour\Init.cs" />
      <Compile Include="Assets\Mono\MonoBehaviour\Init.cs" />
      <Compile Include="Assets\Mono\Core\Async\ETCancellationToken.cs" />
      <Compile Include="Assets\Mono\Core\Async\ETCancellationToken.cs" />
+     <Compile Include="Assets\Mono\Core\Helper\ProcessHelper.cs" />
      <Compile Include="Assets\Mono\MonoBehaviour\ReferenceCollector.cs" />
      <Compile Include="Assets\Mono\MonoBehaviour\ReferenceCollector.cs" />
      <Compile Include="Assets\Mono\Core\Helper\EnumHelper.cs" />
      <Compile Include="Assets\Mono\Core\Helper\EnumHelper.cs" />
      <Compile Include="Assets\Mono\Core\Async\ETTask.cs" />
      <Compile Include="Assets\Mono\Core\Async\ETTask.cs" />
      <Compile Include="Assets\Mono\Core\Helper\FileHelper.cs" />
      <Compile Include="Assets\Mono\Core\Helper\FileHelper.cs" />
+     <Compile Include="Assets\Mono\Core\ThreadSynchronizationContext.cs" />
      <Compile Include="Assets\Mono\Core\Async\AsyncETVoidMethodBuilder.cs" />
      <Compile Include="Assets\Mono\Core\Async\AsyncETVoidMethodBuilder.cs" />
      <Compile Include="Assets\Mono\Core\Async\AsyncMethodBuilderAttribute.cs" />
      <Compile Include="Assets\Mono\Core\Async\AsyncMethodBuilderAttribute.cs" />
      <Compile Include="Assets\Mono\MonoBehaviour\UILayerScript.cs" />
      <Compile Include="Assets\Mono\MonoBehaviour\UILayerScript.cs" />
@@ -78,8 +80,6 @@
      <Compile Include="Assets\Mono\MonoBehaviour\CanvasConfig.cs" />
      <Compile Include="Assets\Mono\MonoBehaviour\CanvasConfig.cs" />
      <Compile Include="Assets\Mono\Core\Helper\StringHelper.cs" />
      <Compile Include="Assets\Mono\Core\Helper\StringHelper.cs" />
      <Compile Include="Assets\Mono\Core\Async\ETTaskHelper.cs" />
      <Compile Include="Assets\Mono\Core\Async\ETTaskHelper.cs" />
-     <Compile Include="Assets\Mono\Core\ThreadSynchronizationContext.cs" />
-     <Compile Include="Assets\Mono\Core\Helper\ProcessHelper.cs" />
      <None Include="Assets\Mono\Unity.Mono.asmdef" />
      <None Include="Assets\Mono\Unity.Mono.asmdef" />
  <Reference Include="UnityEngine">
  <Reference Include="UnityEngine">
  <HintPath>/Applications/Unity/Hub/Editor/2020.3.11f1c1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.dll</HintPath>
  <HintPath>/Applications/Unity/Hub/Editor/2020.3.11f1c1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.dll</HintPath>