Browse Source

增加RollbackSystem,主要用于表现层在回滚后调用,处理表现层和解

tanghai 2 years ago
parent
commit
d85a0151b6
26 changed files with 251 additions and 103 deletions
  1. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/LSSceneChangeHelper.cs
  2. 16 19
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/RoomClientUpdaterSystem.cs
  3. 0 0
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/RoomClientUpdaterSystem.cs.meta
  4. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Match2Map_GetRoomHandler.cs
  5. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/RoomManagerComponentSystem.cs
  6. 7 5
      Unity/Assets/Scripts/Codes/Hotfix/Share/LockStep/RoomSystem.cs
  7. 4 4
      Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepOperaComponentSystem.cs
  8. 1 1
      Unity/Assets/Scripts/Codes/Model/Client/LockStep/RoomClientUpdater.cs
  9. 0 0
      Unity/Assets/Scripts/Codes/Model/Client/LockStep/RoomClientUpdater.cs.meta
  10. 1 1
      Unity/Assets/Scripts/Codes/Model/Share/TimerInvokeType.cs
  11. 0 8
      Unity/Assets/Scripts/Core/LockStep/ILSUpdateSystem.cs
  12. 0 0
      Unity/Assets/Scripts/Core/LockStep/ILSUpdateSystem.cs.meta
  13. 40 0
      Unity/Assets/Scripts/Core/LockStep/IRollbackSystem.cs
  14. 3 0
      Unity/Assets/Scripts/Core/LockStep/IRollbackSystem.cs.meta
  15. 82 9
      Unity/Assets/Scripts/Core/LockStep/LSSington.cs
  16. 0 0
      Unity/Assets/Scripts/Core/LockStep/LSUnit.cs
  17. 0 0
      Unity/Assets/Scripts/Core/LockStep/LSUnit.cs.meta
  18. 0 0
      Unity/Assets/Scripts/Core/LockStep/LSUnitComponent.cs
  19. 0 0
      Unity/Assets/Scripts/Core/LockStep/LSUnitComponent.cs.meta
  20. 1 18
      Unity/Assets/Scripts/Core/LockStep/LSUpdater.cs
  21. 1 1
      Unity/Assets/Scripts/Core/LockStep/LSWorld.cs
  22. 31 0
      Unity/Assets/Scripts/Core/LockStep/RollbackHelper.cs
  23. 3 0
      Unity/Assets/Scripts/Core/LockStep/RollbackHelper.cs.meta
  24. 0 8
      Unity/Assets/Scripts/Core/LockStep/UnitF.meta
  25. 18 0
      Unity/Assets/Scripts/Core/Module/Entity/Entity.cs
  26. 40 26
      Unity/Assets/Scripts/Core/Module/EventSystem/EventSystem.cs

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/LSSceneChangeHelper.cs

@@ -22,7 +22,7 @@ namespace ET.Client
             room.LSWorld = new LSWorld(SceneType.LockStepClient);
             room.Init(waitRoom2CStart.Message);
             
-            room.AddComponent<BattleSceneClientUpdater>();
+            room.AddComponent<RoomClientUpdater>();
 
             // 这个事件中可以订阅取消loading
             EventSystem.Instance.Publish(clientScene, new EventType.LockStepSceneInitFinish());

+ 16 - 19
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/BattleSceneClientUpdaterSystem.cs → Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/RoomClientUpdaterSystem.cs

@@ -3,41 +3,38 @@ using MongoDB.Bson;
 
 namespace ET.Client
 {
-    [FriendOf(typeof (BattleSceneClientUpdater))]
-    public static class BattleSceneClientUpdaterSystem
+    [FriendOf(typeof (RoomClientUpdater))]
+    public static class RoomClientUpdaterSystem
     {
         [FriendOf(typeof (Room))]
-        public class UpdateSystem: UpdateSystem<BattleSceneClientUpdater>
+        public class UpdateSystem: UpdateSystem<RoomClientUpdater>
         {
-            protected override void Update(BattleSceneClientUpdater self)
+            protected override void Update(RoomClientUpdater self)
             {
                 self.Update();
             }
         }
 
-        private static void Update(this BattleSceneClientUpdater self)
+        private static void Update(this RoomClientUpdater self)
         {
             Room room = self.GetParent<Room>();
-
             FrameBuffer frameBuffer = room.FrameBuffer;
-
             long timeNow = TimeHelper.ServerFrameTime();
-            if (timeNow < room.StartTime + frameBuffer.NowFrame * LSConstValue.UpdateInterval)
-            {
-                return;
-            }
 
-            if (frameBuffer.NowFrame > frameBuffer.RealFrame + frameBuffer.PredictionCount)
+            for (int i = 0; i < 5; ++i)
             {
-                return;
+                if (timeNow < room.StartTime + frameBuffer.NowFrame * LSConstValue.UpdateInterval)
+                {
+                    break;
+                }
+                
+                OneFrameMessages oneFrameMessages = GetOneFrameMessages(self, frameBuffer.NowFrame);
+                room.Update(oneFrameMessages);
+                ++frameBuffer.NowFrame;
             }
-            
-            OneFrameMessages oneFrameMessages = GetOneFrameMessages(self, frameBuffer.NowFrame);
-            room.Update(oneFrameMessages);
-            ++frameBuffer.NowFrame;
         }
 
-        private static OneFrameMessages GetOneFrameMessages(this BattleSceneClientUpdater self, int frame)
+        private static OneFrameMessages GetOneFrameMessages(this RoomClientUpdater self, int frame)
         {
             Room room = self.GetParent<Room>();
             FrameBuffer frameBuffer = room.FrameBuffer;
@@ -52,7 +49,7 @@ namespace ET.Client
         }
 
         // 获取预测一帧的消息
-        private static OneFrameMessages GetPredictionOneFrameMessage(this BattleSceneClientUpdater self, int frame)
+        private static OneFrameMessages GetPredictionOneFrameMessage(this RoomClientUpdater self, int frame)
         {
             Room room = self.GetParent<Room>();
             Scene clientScene = room.GetParent<Scene>();

+ 0 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/BattleSceneClientUpdaterSystem.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/RoomClientUpdaterSystem.cs.meta


+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/Match2Map_GetRoomHandler.cs

@@ -9,7 +9,7 @@ namespace ET.Server
 		protected override async ETTask Run(Scene scene, Match2Map_GetRoom request, Map2Match_GetRoom response)
 		{
 			RoomManagerComponent roomManagerComponent = scene.GetComponent<RoomManagerComponent>();
-			Room room = await roomManagerComponent.CreateBattleScene(request);
+			Room room = await roomManagerComponent.CreateServerRoom(request);
 			response.InstanceId = room.InstanceId;
 			await ETTask.CompletedTask;
 		}

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/RoomManagerComponentSystem.cs

@@ -5,7 +5,7 @@ namespace ET.Server
 
     public static class RoomManagerComponentSystem
     {
-        public static async ETTask<Room> CreateBattleScene(this RoomManagerComponent self, Match2Map_GetRoom request)
+        public static async ETTask<Room> CreateServerRoom(this RoomManagerComponent self, Match2Map_GetRoom request)
         {
             await ETTask.CompletedTask;
             

+ 7 - 5
Unity/Assets/Scripts/Codes/Hotfix/Share/LockStep/RoomSystem.cs

@@ -3,13 +3,13 @@ namespace ET
     [FriendOf(typeof(Room))]
     public static class RoomSystem
     {
-        public static void Init(this Room self, Room2C_Start room2CBattleStart)
+        public static void Init(this Room self, Room2C_Start room2CStart)
         {
-            self.StartTime = room2CBattleStart.StartTime;
+            self.StartTime = room2CStart.StartTime;
 
-            for (int i = 0; i < room2CBattleStart.UnitInfo.Count; ++i)
+            for (int i = 0; i < room2CStart.UnitInfo.Count; ++i)
             {
-                LockStepUnitInfo unitInfo = room2CBattleStart.UnitInfo[i];
+                LockStepUnitInfo unitInfo = room2CStart.UnitInfo[i];
                 LSUnitFactory.Init(self.LSWorld, unitInfo);
             }
         }
@@ -37,10 +37,12 @@ namespace ET
         // 回滚
         public static void Rollback(this Room self, int frame)
         {
-            Log.Debug($"Battle Scene roll back to {frame}");
+            Log.Debug($"Room Scene roll back to {frame}");
             self.LSWorld.Dispose();
             byte[] dataBuffer = self.FrameBuffer.GetDate(frame);
             self.LSWorld = MongoHelper.Deserialize<LSWorld>(dataBuffer);
+            
+            RollbackHelper.Rollback(self);
         }
     }
 }

+ 4 - 4
Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepOperaComponentSystem.cs

@@ -3,10 +3,10 @@ using UnityEngine;
 
 namespace ET.Client
 {
-    [FriendOf(typeof(BattleSceneClientUpdater))]
+    [FriendOf(typeof(RoomClientUpdater))]
     public static class LockStepOperaComponentSystem
     {
-        [FriendOf(typeof(BattleSceneClientUpdater))]
+        [FriendOf(typeof(RoomClientUpdater))]
         public class UpdateSystem: UpdateSystem<LockStepOperaComponent>
         {
             protected override void Update(LockStepOperaComponent self)
@@ -32,8 +32,8 @@ namespace ET.Client
                     v.x += 1;
                 }
 
-                BattleSceneClientUpdater battleSceneClientUpdater = self.GetParent<Room>().GetComponent<BattleSceneClientUpdater>();
-                battleSceneClientUpdater.InputInfo.V = v;
+                RoomClientUpdater roomClientUpdater = self.GetParent<Room>().GetComponent<RoomClientUpdater>();
+                roomClientUpdater.InputInfo.V = v;
             }
         }
     }

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Client/LockStep/BattleSceneClientUpdater.cs → Unity/Assets/Scripts/Codes/Model/Client/LockStep/RoomClientUpdater.cs

@@ -3,7 +3,7 @@ using TrueSync;
 namespace ET.Client
 {
     [ComponentOf(typeof(Room))]
-    public class BattleSceneClientUpdater: Entity, IAwake, IUpdate
+    public class RoomClientUpdater: Entity, IAwake, IUpdate
     {
         public LSInputInfo InputInfo = new LSInputInfo();
     }

+ 0 - 0
Unity/Assets/Scripts/Codes/Model/Client/LockStep/BattleSceneClientUpdater.cs.meta → Unity/Assets/Scripts/Codes/Model/Client/LockStep/RoomClientUpdater.cs.meta


+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Share/TimerInvokeType.cs

@@ -14,6 +14,6 @@
         public const int AITimer = 202;
         public const int SessionAcceptTimeout = 203;
         
-        public const int BattleSceneUpdate = 301;
+        public const int RoomUpdate = 301;
     }
 }

+ 0 - 8
Unity/Assets/Scripts/Core/LockStep/ILSUpdate.cs → Unity/Assets/Scripts/Core/LockStep/ILSUpdateSystem.cs

@@ -2,14 +2,6 @@ using System;
 
 namespace ET
 {
-    [UniqueId(-1, 1)]
-    public static class LSQueneUpdateIndex
-    {
-        public const int None = -1;
-        public const int LSUpdate = 0;
-        public const int Max = 1;
-    }
-    
     public interface ILSUpdate
     {
     }

+ 0 - 0
Unity/Assets/Scripts/Core/LockStep/ILSUpdate.cs.meta → Unity/Assets/Scripts/Core/LockStep/ILSUpdateSystem.cs.meta


+ 40 - 0
Unity/Assets/Scripts/Core/LockStep/IRollbackSystem.cs

@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+
+namespace ET
+{
+    public interface IRollback
+    {
+    }
+    
+    public interface IRollbackSystem: ISystemType
+    {
+        void Run(Entity o);
+    }
+    
+    [LSSystem]
+    public abstract class RollbackSystem<T> : IRollbackSystem where T: Entity, IRollback
+    {
+        void IRollbackSystem.Run(Entity o)
+        {
+            this.Rollback((T)o);
+        }
+
+        Type ISystemType.Type()
+        {
+            return typeof(T);
+        }
+
+        Type ISystemType.SystemType()
+        {
+            return typeof(IRollbackSystem);
+        }
+
+        int ISystemType.GetInstanceQueueIndex()
+        {
+            return InstanceQueueIndex.None;
+        }
+
+        protected abstract void Rollback(T self);
+    }
+}

+ 3 - 0
Unity/Assets/Scripts/Core/LockStep/IRollbackSystem.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: e654e53cfb1342b89b4f886681358d6b
+timeCreated: 1682304648

+ 82 - 9
Unity/Assets/Scripts/Core/LockStep/LSSington.cs

@@ -1,10 +1,19 @@
 using System;
+using System.Collections.Generic;
 
 namespace ET
 {
+    [UniqueId(-1, 1)]
+    public static class LSQueneUpdateIndex
+    {
+        public const int None = -1;
+        public const int LSUpdate = 0;
+        public const int Max = 1;
+    }
+    
     public class LSSington: Singleton<LSSington>, ISingletonAwake
     {
-        public TypeSystems TypeSystems = new TypeSystems(LSQueneUpdateIndex.Max);
+        private readonly TypeSystems typeSystems = new(LSQueneUpdateIndex.Max);
         
         public void Awake()
         {
@@ -12,15 +21,79 @@ namespace ET
             {
                 object obj = Activator.CreateInstance(type);
 
-                if (obj is ISystemType iSystemType)
+                if (obj is not ISystemType iSystemType)
+                {
+                    continue;
+                }
+
+                TypeSystems.OneTypeSystems oneTypeSystems = this.typeSystems.GetOrCreateOneTypeSystems(iSystemType.Type());
+                oneTypeSystems.Map.Add(iSystemType.SystemType(), obj);
+                int index = iSystemType.GetInstanceQueueIndex();
+                if (index > InstanceQueueIndex.None && index < InstanceQueueIndex.Max)
+                {
+                    oneTypeSystems.QueueFlag[index] = true;
+                }
+            }
+        }
+        
+        public TypeSystems.OneTypeSystems GetOneTypeSystems(Type type)
+        {
+            return this.typeSystems.GetOneTypeSystems(type);
+        }
+        
+        public void Rollback(Entity entity)
+        {
+            if (entity is not IRollback)
+            {
+                return;
+            }
+            
+            List<object> iRollbackSystems = this.typeSystems.GetSystems(entity.GetType(), typeof (IRollbackSystem));
+            if (iRollbackSystems == null)
+            {
+                return;
+            }
+
+            foreach (IRollbackSystem iRollbackSystem in iRollbackSystems)
+            {
+                if (iRollbackSystem == null)
+                {
+                    continue;
+                }
+
+                try
+                {
+                    iRollbackSystem.Run(entity);
+                }
+                catch (Exception e)
+                {
+                    Log.Error(e);
+                }
+            }
+        }
+
+        public void LSUpdate(LSEntity entity)
+        {
+            if (entity is not ILSUpdate)
+            {
+                return;
+            }
+            
+            List<object> iLSUpdateSystems = typeSystems.GetSystems(entity.GetType(), typeof (ILSUpdateSystem));
+            if (iLSUpdateSystems == null)
+            {
+                return;
+            }
+
+            foreach (ILSUpdateSystem iLSUpdateSystem in iLSUpdateSystems)
+            {
+                try
+                {
+                    iLSUpdateSystem.Run(entity);
+                }
+                catch (Exception e)
                 {
-                    TypeSystems.OneTypeSystems oneTypeSystems = this.TypeSystems.GetOrCreateOneTypeSystems(iSystemType.Type());
-                    oneTypeSystems.Map.Add(iSystemType.SystemType(), obj);
-                    int index = iSystemType.GetInstanceQueueIndex();
-                    if (index > InstanceQueueIndex.None && index < InstanceQueueIndex.Max)
-                    {
-                        oneTypeSystems.QueueFlag[index] = true;
-                    }
+                    Log.Error(e);
                 }
             }
         }

+ 0 - 0
Unity/Assets/Scripts/Core/LockStep/UnitF/LSUnit.cs → Unity/Assets/Scripts/Core/LockStep/LSUnit.cs


+ 0 - 0
Unity/Assets/Scripts/Core/LockStep/UnitF/LSUnit.cs.meta → Unity/Assets/Scripts/Core/LockStep/LSUnit.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Core/LockStep/UnitF/LSUnitComponent.cs → Unity/Assets/Scripts/Core/LockStep/LSUnitComponent.cs


+ 0 - 0
Unity/Assets/Scripts/Core/LockStep/UnitF/LSUnitComponent.cs.meta → Unity/Assets/Scripts/Core/LockStep/LSUnitComponent.cs.meta


+ 1 - 18
Unity/Assets/Scripts/Core/LockStep/LSUpdater.cs

@@ -22,7 +22,6 @@ namespace ET
                 this.updateIds.Add(this.addUpdateIds.Dequeue());
             }
 
-            TypeSystems typeSystems = LSSington.Instance.TypeSystems;
             foreach (long id in this.updateIds)
             {
                 LSEntity entity = this.Parent.Get(id);
@@ -32,23 +31,7 @@ namespace ET
                     continue;
                 }
                 
-                List<object> iLSUpdateSystems = typeSystems.GetSystems(entity.GetType(), typeof (ILSUpdateSystem));
-                if (iLSUpdateSystems == null)
-                {
-                    continue;
-                }
-
-                foreach (ILSUpdateSystem iLSUpdateSystem in iLSUpdateSystems)
-                {
-                    try
-                    {
-                        iLSUpdateSystem.Run(entity);
-                    }
-                    catch (Exception e)
-                    {
-                        Log.Error(e);
-                    }
-                }
+                LSSington.Instance.LSUpdate(entity);
             }
 
             while (this.removeUpdateIds.Count > 0)

+ 1 - 1
Unity/Assets/Scripts/Core/LockStep/LSWorld.cs

@@ -81,7 +81,7 @@ namespace ET
 
             Type type = entity.GetType();
 
-            TypeSystems.OneTypeSystems oneTypeSystems = LSSington.Instance.TypeSystems.GetOneTypeSystems(type);
+            TypeSystems.OneTypeSystems oneTypeSystems = LSSington.Instance.GetOneTypeSystems(type);
             if (oneTypeSystems == null)
             {
                 return;

+ 31 - 0
Unity/Assets/Scripts/Core/LockStep/RollbackHelper.cs

@@ -0,0 +1,31 @@
+namespace ET
+{
+    public static class RollbackHelper
+    {
+        public static void Rollback(Entity entity)
+        {
+            if (entity is LSEntity)
+            {
+                return;
+            }
+            
+            LSSington.Instance.Rollback(entity);
+            
+            if (entity.ComponentsCount() > 0)
+            {
+                foreach (Entity component in entity.Components.Values)
+                {
+                    Rollback(component);
+                }
+            }
+
+            if (entity.ChildrenCount() > 0)
+            {
+                foreach (Entity child in entity.Children.Values)
+                {
+                    Rollback(child);
+                }
+            }
+        }
+    }
+}

+ 3 - 0
Unity/Assets/Scripts/Core/LockStep/RollbackHelper.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 595d906817ce4666981a65ecd20bf8cb
+timeCreated: 1682306645

+ 0 - 8
Unity/Assets/Scripts/Core/LockStep/UnitF.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 24382ac4608a240bab02b86a21121719
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 18 - 0
Unity/Assets/Scripts/Core/Module/Entity/Entity.cs

@@ -407,6 +407,24 @@ namespace ET
             }
         }
 
+        public int ComponentsCount()
+        {
+            if (this.components == null)
+            {
+                return 0;
+            }
+            return this.components.Count;
+        }
+        
+        public int ChildrenCount()
+        {
+            if (this.children == null)
+            {
+                return 0;
+            }
+            return this.children.Count;
+        }
+
         public override void Dispose()
         {
             if (this.IsDisposed)

+ 40 - 26
Unity/Assets/Scripts/Core/Module/EventSystem/EventSystem.cs

@@ -243,6 +243,11 @@ namespace ET
 
         public void Deserialize(Entity component)
         {
+            if (component is not IDeserialize)
+            {
+                return;
+            }
+            
             List<object> iDeserializeSystems = this.typeSystems.GetSystems(component.GetType(), typeof (IDeserializeSystem));
             if (iDeserializeSystems == null)
             {
@@ -349,6 +354,11 @@ namespace ET
 
         public void Awake<P1>(Entity component, P1 p1)
         {
+            if (component is not IAwake<P1>)
+            {
+                return;
+            }
+            
             List<object> iAwakeSystems = this.typeSystems.GetSystems(component.GetType(), typeof (IAwakeSystem<P1>));
             if (iAwakeSystems == null)
             {
@@ -375,6 +385,11 @@ namespace ET
 
         public void Awake<P1, P2>(Entity component, P1 p1, P2 p2)
         {
+            if (component is not IAwake<P1, P2>)
+            {
+                return;
+            }
+            
             List<object> iAwakeSystems = this.typeSystems.GetSystems(component.GetType(), typeof (IAwakeSystem<P1, P2>));
             if (iAwakeSystems == null)
             {
@@ -401,39 +416,18 @@ namespace ET
 
         public void Awake<P1, P2, P3>(Entity component, P1 p1, P2 p2, P3 p3)
         {
-            List<object> iAwakeSystems = this.typeSystems.GetSystems(component.GetType(), typeof (IAwakeSystem<P1, P2, P3>));
-            if (iAwakeSystems == null)
+            if (component is not IAwake<P1, P2, P3>)
             {
                 return;
             }
-
-            foreach (IAwakeSystem<P1, P2, P3> aAwakeSystem in iAwakeSystems)
-            {
-                if (aAwakeSystem == null)
-                {
-                    continue;
-                }
-
-                try
-                {
-                    aAwakeSystem.Run(component, p1, p2, p3);
-                }
-                catch (Exception e)
-                {
-                    Log.Error(e);
-                }
-            }
-        }
-
-        public void Awake<P1, P2, P3, P4>(Entity component, P1 p1, P2 p2, P3 p3, P4 p4)
-        {
-            List<object> iAwakeSystems = this.typeSystems.GetSystems(component.GetType(), typeof (IAwakeSystem<P1, P2, P3, P4>));
+            
+            List<object> iAwakeSystems = this.typeSystems.GetSystems(component.GetType(), typeof (IAwakeSystem<P1, P2, P3>));
             if (iAwakeSystems == null)
             {
                 return;
             }
 
-            foreach (IAwakeSystem<P1, P2, P3, P4> aAwakeSystem in iAwakeSystems)
+            foreach (IAwakeSystem<P1, P2, P3> aAwakeSystem in iAwakeSystems)
             {
                 if (aAwakeSystem == null)
                 {
@@ -442,7 +436,7 @@ namespace ET
 
                 try
                 {
-                    aAwakeSystem.Run(component, p1, p2, p3, p4);
+                    aAwakeSystem.Run(component, p1, p2, p3);
                 }
                 catch (Exception e)
                 {
@@ -469,6 +463,11 @@ namespace ET
                     continue;
                 }
 
+                if (component is not ILoad)
+                {
+                    continue;
+                }
+
                 List<object> iLoadSystems = this.typeSystems.GetSystems(component.GetType(), typeof (ILoadSystem));
                 if (iLoadSystems == null)
                 {
@@ -493,6 +492,11 @@ namespace ET
 
         public void Destroy(Entity component)
         {
+            if (component is not IDestroy)
+            {
+                return;
+            }
+            
             List<object> iDestroySystems = this.typeSystems.GetSystems(component.GetType(), typeof (IDestroySystem));
             if (iDestroySystems == null)
             {
@@ -534,6 +538,11 @@ namespace ET
                 {
                     continue;
                 }
+                
+                if (component is not IUpdate)
+                {
+                    continue;
+                }
 
                 List<object> iUpdateSystems = this.typeSystems.GetSystems(component.GetType(), typeof (IUpdateSystem));
                 if (iUpdateSystems == null)
@@ -574,6 +583,11 @@ namespace ET
                 {
                     continue;
                 }
+                
+                if (component is not ILateUpdate)
+                {
+                    continue;
+                }
 
                 List<object> iLateUpdateSystems = this.typeSystems.GetSystems(component.GetType(), typeof (ILateUpdateSystem));
                 if (iLateUpdateSystems == null)