diff --git a/Engine b/Engine index feb2a05..67d7f40 160000 --- a/Engine +++ b/Engine @@ -1 +1 @@ -Subproject commit feb2a05aa3e0683b62f7a306ab73df0def060dda +Subproject commit 67d7f401b832156e40e9bda11a4546cccd232707 diff --git a/Platforms/Desktop/KeyboardInputsBehaviour.cs b/Platforms/Desktop/KeyboardInputsBehaviour.cs index 7d48384..8d94fdb 100644 --- a/Platforms/Desktop/KeyboardInputsBehaviour.cs +++ b/Platforms/Desktop/KeyboardInputsBehaviour.cs @@ -72,8 +72,8 @@ public class KeyboardInputsBehaviour : Behaviour, IButtonInputs if (WasPressed(currentlyPressedKey)) continue; - action.InvokeSafe(this, currentlyPressedKey); - OnAnyButtonPressed?.InvokeSafe(this, currentlyPressedKey); + action.Invoke(this, currentlyPressedKey); + OnAnyButtonPressed?.Invoke(this, currentlyPressedKey); } for (int i = 0; i < cachePressedPreviouslyCount; i++) @@ -86,8 +86,8 @@ public class KeyboardInputsBehaviour : Behaviour, IButtonInputs if (IsPressed(previouslyPressedKey)) continue; - action.InvokeSafe(this, previouslyPressedKey); - OnAnyButtonReleased?.InvokeSafe(this, previouslyPressedKey); + action.Invoke(this, previouslyPressedKey); + OnAnyButtonReleased?.Invoke(this, previouslyPressedKey); } Array.Copy(cachePressedCurrently, cachePressedPreviously, cachePressedCurrentlyCount); diff --git a/Shared/Behaviours/MonoGameCamera2DBehaviour.cs b/Shared/Behaviours/MonoGameCamera2DBehaviour.cs index 12cb73a..a0dca2d 100644 --- a/Shared/Behaviours/MonoGameCamera2DBehaviour.cs +++ b/Shared/Behaviours/MonoGameCamera2DBehaviour.cs @@ -27,7 +27,7 @@ public class MonoGameCamera2DBehaviour(GraphicsDeviceManager Graphics) : Behavio return; _matrixTransform = value; - OnMatrixTransformChanged?.InvokeSafe(this); + OnMatrixTransformChanged?.Invoke(this); } } @@ -46,7 +46,7 @@ public class MonoGameCamera2DBehaviour(GraphicsDeviceManager Graphics) : Behavio return; _viewport = value; - OnViewportChanged?.InvokeSafe(this); + OnViewportChanged?.Invoke(this); } } @@ -61,7 +61,7 @@ public class MonoGameCamera2DBehaviour(GraphicsDeviceManager Graphics) : Behavio return; _zoom = newValue; - OnZoomChanged?.InvokeSafe(this); + OnZoomChanged?.Invoke(this); } } diff --git a/Shared/Behaviours/PongManagerBehaviour.cs b/Shared/Behaviours/PongManagerBehaviour.cs index 6c13025..aa83874 100644 --- a/Shared/Behaviours/PongManagerBehaviour.cs +++ b/Shared/Behaviours/PongManagerBehaviour.cs @@ -43,7 +43,7 @@ public class PongManagerBehaviour : Behaviour, INetworkEntity, public void ScoreToLeft() { ScoreLeft++; - OnScored?.InvokeSafe(this); + OnScored?.Invoke(this); CheckFinish(); } @@ -51,7 +51,7 @@ public class PongManagerBehaviour : Behaviour, INetworkEntity, public void ScoreToRight() { ScoreRight++; - OnScored?.InvokeSafe(this); + OnScored?.Invoke(this); CheckFinish(); } @@ -63,7 +63,7 @@ public class PongManagerBehaviour : Behaviour, INetworkEntity, ball.ResetBall(); ball.LaunchBall(GetBallLaunchDirection()); - OnReset?.InvokeSafe(this); + OnReset?.Invoke(this); } private void CheckFinish() @@ -73,7 +73,7 @@ public class PongManagerBehaviour : Behaviour, INetworkEntity, if (ScoreLeft > halfwayScore || ScoreRight > halfwayScore) { - OnFinished?.InvokeSafe(this); + OnFinished?.Invoke(this); return; } diff --git a/Shared/Behaviours/WallScoreBehaviour.cs b/Shared/Behaviours/WallScoreBehaviour.cs index c8f6ba6..4b4cc9f 100644 --- a/Shared/Behaviours/WallScoreBehaviour.cs +++ b/Shared/Behaviours/WallScoreBehaviour.cs @@ -14,6 +14,6 @@ public class WallScoreBehaviour(Action OnCollision) : Behaviour2D if (!BehaviourController.TryGetBehaviour(out ICollider2D? collider2D)) return; - collider2D.OnCollisionDetected += (_, _1) => OnCollision?.InvokeSafe(); + collider2D.OnCollisionDetected += (_, _1) => OnCollision?.Invoke(); } } diff --git a/Shared/GamePong.cs b/Shared/GamePong.cs index 7cf865a..ffa0997 100644 --- a/Shared/GamePong.cs +++ b/Shared/GamePong.cs @@ -179,13 +179,13 @@ public class GamePong : Game universe.Draw(); spriteBatch.Begin(SpriteSortMode.Deferred, transformMatrix: cameraBehaviour.MatrixTransform); - foreach (var displayable in displayableCollector) - displayable.Draw(spriteBatch); + for (int i = displayableCollector.Behaviours.Count - 1; i >= 0; i--) + displayableCollector.Behaviours[i].Draw(spriteBatch); spriteBatch.End(); shapeBatch.Begin(cameraBehaviour.MatrixTransform); - foreach (var displayableShape in displayableShapeCollector) - displayableShape.Draw(shapeBatch); + for (int i = displayableShapeCollector.Behaviours.Count - 1; i >= 0; i--) + displayableShapeCollector.Behaviours[i].Draw(shapeBatch); shapeBatch.End(); base.Draw(gameTime); diff --git a/Shared/Network/LiteNetLib/LiteNetLibCommunicatorBase.cs b/Shared/Network/LiteNetLib/LiteNetLibCommunicatorBase.cs index 2a8a97a..d70bd41 100644 --- a/Shared/Network/LiteNetLib/LiteNetLibCommunicatorBase.cs +++ b/Shared/Network/LiteNetLib/LiteNetLibCommunicatorBase.cs @@ -37,7 +37,7 @@ public abstract class LiteNetLibCommunicatorBase : UniverseObject, INetworkCommu return; foreach (Delegate @delegate in delegates) - @delegate.InvokeSafe(packet, peer.Id.ToString()); + @delegate.DynamicInvoke(packet, peer.Id.ToString()); } private void NetworkReceiveEvent(NetPeer peer, NetPacketReader reader, byte channel, DeliveryMethod deliveryMethod)