chore: updated engine

This commit is contained in:
Syntriax 2025-04-13 13:18:35 +03:00
parent 67e46cdaf3
commit 51854a3e59
6 changed files with 10 additions and 24 deletions

2
Engine

@ -1 +1 @@
Subproject commit c135035d5b72730a71665de3c9f27611880f32c8
Subproject commit 9e4c74ed1d73eac40ed29fbdb1e5103c121844a9

View File

@ -17,14 +17,8 @@ public class BallBehaviour : Behaviour2D
protected override void OnFirstActiveFrame()
{
if (!BehaviourController.TryGetBehaviour(out IRigidBody2D? foundRigidBody))
throw new Exception($"{nameof(IRigidBody2D)} is missing on {HierarchyObject.Name}.");
if (!BehaviourController.TryGetBehaviour(out ICollider2D? foundCollider))
throw new Exception($"{nameof(ICollider2D)} is missing on {HierarchyObject.Name}.");
foundCollider.OnCollisionDetected += OnCollisionDetected;
rigidBody = foundRigidBody;
BehaviourController.GetRequiredBehaviour<ICollider2D>().OnCollisionDetected += OnCollisionDetected;
rigidBody = BehaviourController.GetRequiredBehaviour<IRigidBody2D>();
if (HierarchyObject.GameManager.TryFindBehaviour(out PongManagerBehaviour? pongManager))
{

View File

@ -14,12 +14,9 @@ public class CameraController : Behaviour
protected override void OnFirstActiveFrame()
{
if (BehaviourController.TryGetBehaviour(out MonoGameCamera2DBehaviour? foundCameraBehaviour))
cameraBehaviour = foundCameraBehaviour;
cameraBehaviour ??= BehaviourController.GetRequiredBehaviour<MonoGameCamera2DBehaviour>();
buttonInputs = GameManager.FindRequiredBehaviour<IButtonInputs<Keys>>();
cameraBehaviour ??= BehaviourController.AddBehaviour<MonoGameCamera2DBehaviour>();
buttonInputs = GameManager.FindBehaviour<IButtonInputs<Keys>>() ?? throw new("Unable to find inputs");
buttonInputs.RegisterOnPress(Keys.F, SwitchToFullScreen);
buttonInputs.RegisterOnPress(Keys.R, ResetCamera);
}

View File

@ -16,15 +16,10 @@ public class MovementBallBehaviour : Behaviour2D
protected override void OnFirstActiveFrame()
{
if (!BehaviourController.TryGetBehaviour(out IRigidBody2D? foundRigidBody))
throw new Exception($"{nameof(IRigidBody2D)} is missing on {HierarchyObject.Name}.");
if (!BehaviourController.TryGetBehaviour(out ICollider2D? foundCollider))
throw new Exception($"{nameof(ICollider2D)} is missing on {HierarchyObject.Name}.");
rigidBody = BehaviourController.GetRequiredBehaviour<IRigidBody2D>();
foundRigidBody.Velocity = StartDirection * Speed;
foundCollider.OnCollisionDetected += OnCollisionDetected;
rigidBody = foundRigidBody;
rigidBody.Velocity = StartDirection * Speed;
BehaviourController.GetRequiredBehaviour<ICollider2D>().OnCollisionDetected += OnCollisionDetected;
}
protected override void OnUpdate()

View File

@ -35,7 +35,7 @@ public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Sp
protected override void OnFirstActiveFrame()
{
inputs = GameManager.FindBehaviour<IButtonInputs<Keys>>() ?? throw new("Unable to find inputs");
inputs = GameManager.FindRequiredBehaviour<IButtonInputs<Keys>>();
inputs.RegisterOnPress(Up, OnUpPressed);
inputs.RegisterOnRelease(Up, OnUpReleased);

View File

@ -24,7 +24,7 @@ public class PongManagerBehaviour : Behaviour
protected override void OnFirstActiveFrame()
{
var buttonInputs = GameManager.FindBehaviour<IButtonInputs<Keys>>() ?? throw new("Unable to find inputs");
var buttonInputs = GameManager.FindRequiredBehaviour<IButtonInputs<Keys>>();
buttonInputs.RegisterOnRelease(Keys.Space, (_, _1) => Reset());
}