2024-01-28 15:33:45 +03:00
|
|
|
using System;
|
2024-01-31 12:51:23 +03:00
|
|
|
|
2024-01-28 15:33:45 +03:00
|
|
|
using Syntriax.Engine.Core;
|
|
|
|
using Syntriax.Engine.Physics2D.Abstract;
|
|
|
|
|
|
|
|
namespace Pong.Behaviours;
|
|
|
|
|
2024-01-31 12:17:43 +03:00
|
|
|
public class WallScoreBehaviour(Action OnCollision) : BehaviourOverride
|
2024-01-28 15:33:45 +03:00
|
|
|
{
|
|
|
|
private Action OnCollision { get; } = OnCollision;
|
|
|
|
|
|
|
|
protected override void OnFirstActiveFrame()
|
|
|
|
{
|
|
|
|
if (!BehaviourController.TryGetBehaviour(out ICollider2D? collider2D))
|
|
|
|
return;
|
|
|
|
|
|
|
|
collider2D.OnCollisionDetected += (_, _1) => OnCollision?.Invoke();
|
|
|
|
}
|
|
|
|
}
|