Ball/IBallHittable.cs

Interface for objects that can be struck by the ball in a Breakout-style game. Declares OnBallHit which is called when the ball hits the object and returns whether the ball should bounce normally.

using Sandbox;

namespace Breakout;

/// <summary>
/// Implemented by anything the ball can strike (blocks and the paddle). OnBallHit returns true if
/// the ball should bounce off normally, or false if the target already set the ball's direction
/// itself or wants to let it pass through.
/// </summary>
public interface IBallHittable
{
	/// <summary>
	/// Called when the ball hits this object. Return true to let the ball bounce normally, or false if this object handled the ball's direction itself.
	/// </summary>
	bool OnBallHit( Ball ball, Vector3 hitNormal, Vector3 hitPoint );
}