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

再次修改下GetComponentSys

tanghai 2 лет назад
Родитель
Сommit
a63de36dbd

+ 2 - 2
Unity/Assets/Scripts/Core/Entity/Entity.cs

@@ -653,7 +653,7 @@ namespace ET
             }
 
             // 如果有IGetComponent接口,则触发GetComponentSystem
-            if (this is IGetComponent)
+            if (this is IGetComponentSys)
             {
                 EntitySystemSingleton.Instance.GetComponentSys(this, typeof(K));
             }
@@ -676,7 +676,7 @@ namespace ET
 
             // 如果有IGetComponent接口,则触发GetComponentSystem
             // 这个要在tryget之前调用,因为有可能components没有,但是执行GetComponentSystem后又有了
-            if (this is IGetComponent)
+            if (this is IGetComponentSys)
             {
                 EntitySystemSingleton.Instance.GetComponentSys(this, type);
             }

+ 2 - 2
Unity/Assets/Scripts/Core/Entity/EntitySystemSingleton.cs

@@ -94,13 +94,13 @@ namespace ET
         // GetComponentSystem
         public void GetComponentSys(Entity entity, Type type)
         {
-            List<object> iGetSystem = this.TypeSystems.GetSystems(entity.GetType(), typeof (IGetComponentSystem));
+            List<object> iGetSystem = this.TypeSystems.GetSystems(entity.GetType(), typeof (IGetComponentSysSystem));
             if (iGetSystem == null)
             {
                 return;
             }
 
-            foreach (IGetComponentSystem getSystem in iGetSystem)
+            foreach (IGetComponentSysSystem getSystem in iGetSystem)
             {
                 if (getSystem == null)
                 {

+ 5 - 5
Unity/Assets/Scripts/Core/Entity/IGetComponentSystem.cs → Unity/Assets/Scripts/Core/Entity/IGetComponentSysSystem.cs

@@ -6,26 +6,26 @@ namespace ET
 	// 是否变化可以通过判断该组件是否GetComponent,Get了就记录该组件
 	// 这样可以只保存Unit变化过的组件
 	// 再比如传送也可以做此类优化
-	public interface IGetComponent
+	public interface IGetComponentSys
 	{
 	}
 	
-	public interface IGetComponentSystem: ISystemType
+	public interface IGetComponentSysSystem: ISystemType
 	{
 		void Run(Entity o, Type type);
 	}
 
 	[EntitySystem]
-	public abstract class GetComponentSystem<T> : IGetComponentSystem where T: Entity, IGetComponent
+	public abstract class GetComponentSysSystem<T> : IGetComponentSysSystem where T: Entity, IGetComponentSys
 	{
-		void IGetComponentSystem.Run(Entity o, Type type)
+		void IGetComponentSysSystem.Run(Entity o, Type type)
 		{
 			this.GetComponentSys((T)o, type);
 		}
 
 		Type ISystemType.SystemType()
 		{
-			return typeof(IGetComponentSystem);
+			return typeof(IGetComponentSysSystem);
 		}
 
 		int ISystemType.GetInstanceQueueIndex()