Defines CarImpactKind enum, CarImpact readonly struct carrying info about a single car collision (kind, involved cars, hit GameObject, point, normal, speed), and ICarImpactListener interface with OnCarImpact method.
using Machines.Player;
namespace Machines.Events;
/// <summary>
/// What a car impact was against.
/// </summary>
public enum CarImpactKind
{
/// <summary>
/// Hit static world geometry.
/// </summary>
Wall,
/// <summary>
/// The car hit another car.
/// </summary>
Car,
/// <summary>
/// Hit a pushable prop (non-blocking, but registers for shake/haptics).
/// </summary>
Prop
}
/// <summary>
/// Details of a single car impact
/// </summary>
public readonly struct CarImpact
{
/// <summary>
/// What was hit.
/// </summary>
public CarImpactKind Kind { get; init; }
/// <summary>
/// The car this impact is about.
/// </summary>
public Car Car { get; init; }
/// <summary>
/// The other car when <see cref="Kind"/> is <see cref="CarImpactKind.Car"/>, null otherwise.
/// </summary>
public Car OtherCar { get; init; }
/// <summary>
/// GameObject that was hit (wall, prop, or other car).
/// </summary>
public GameObject Other { get; init; }
/// <summary>
/// Contact point in world space.
/// </summary>
public Vector3 Point { get; init; }
/// <summary>
/// Contact surface normal.
/// </summary>
public Vector3 Normal { get; init; }
/// <summary>
/// Closing/relative speed at impact.
/// </summary>
public float Speed { get; init; }
}
/// <summary>
/// Fired once per discrete car impact (wall, car, or prop).
/// </summary>
public interface ICarImpactListener : ISceneEvent<ICarImpactListener>
{
void OnCarImpact( CarImpact impact );
}