diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs index a3481de..f96a52f 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs @@ -1133,14 +1133,17 @@ if (IsDebug) { DebugDraw(); - var arr = _components.ToArray(); - for (int i = 0; i < arr.Length; i++) + if (_components.Count > 0) { - if (IsDestroyed) return; - var temp = arr[i].Value; - if (temp != null && temp.ActivityInstance == this && temp.Enable) + var arr = _components.ToArray(); + for (int i = 0; i < arr.Length; i++) { - temp.DebugDraw(); + if (IsDestroyed) return; + var temp = arr[i].Value; + if (temp != null && temp.ActivityInstance == this && temp.Enable) + { + temp.DebugDraw(); + } } } } diff --git a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs index e577646..36167b1 100644 --- a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs +++ b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs @@ -271,33 +271,33 @@ return; } - //先调用更新 - var externalForces = _forceList.ToArray(); - for (var i = 0; i < externalForces.Length; i++) - { - var force = externalForces[i]; - if (force.Enable) - { - force.PhysicsProcess(delta); - //自动销毁 - if (CheckAutoDestroy(force)) - { - _forceList.Remove(force); - externalForces[i] = null; - } - } - } - //外力总和 var finallyEf = new Vector2(); //旋转速率总和 var rotationSpeed = 0f; - foreach (var force in externalForces) + + //先调用更新 + if (_forceList.Count > 0) { - if (force != null && force.Enable) + var externalForces = _forceList.ToArray(); + for (var i = 0; i < externalForces.Length; i++) { - finallyEf += force.Velocity; - rotationSpeed += force.RotationSpeed; + var force = externalForces[i]; + if (force.Enable) + { + force.PhysicsProcess(delta); + //自动销毁 + if (CheckAutoDestroy(force)) + { + _forceList.Remove(force); + externalForces[i] = null; + } + else + { + finallyEf += force.Velocity; + rotationSpeed += force.RotationSpeed; + } + } } } diff --git a/DungeonShooting_Godot/src/framework/coroutine/ProxyCoroutineHandler.cs b/DungeonShooting_Godot/src/framework/coroutine/ProxyCoroutineHandler.cs index 5592d76..97abea5 100644 --- a/DungeonShooting_Godot/src/framework/coroutine/ProxyCoroutineHandler.cs +++ b/DungeonShooting_Godot/src/framework/coroutine/ProxyCoroutineHandler.cs @@ -15,6 +15,10 @@ /// public static void ProxyUpdateCoroutine(ref List coroutineList, float delta) { + if (coroutineList.Count == 0) + { + return; + } var pairs = coroutineList.ToArray(); for (var i = 0; i < pairs.Length; i++) {