feat: Score Boundary

This commit is contained in:
Syntriax 2024-01-28 15:33:45 +03:00
parent fbe3087502
commit ca92b12833
1 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
using System;
using Syntriax.Engine.Core;
using Syntriax.Engine.Physics2D.Abstract;
namespace Pong.Behaviours;
public class ScoreBoundary(Action OnCollision) : BehaviourOverride
{
private Action OnCollision { get; } = OnCollision;
protected override void OnFirstActiveFrame()
{
if (!BehaviourController.TryGetBehaviour(out ICollider2D? collider2D))
return;
collider2D.OnCollisionDetected += (_, _1) => OnCollision?.Invoke();
}
}