using System;
namespace MonoGame.Extended.Collisions.Layers;
///
/// Layer is a group of collision's actors.
///
public class Layer
{
///
/// If this property equals true, layer always will reset collision space.
///
public bool IsDynamic { get; set; } = true;
///
/// The space, which contain actors.
///
public readonly ISpaceAlgorithm Space;
///
/// Constructor for layer
///
/// A space algorithm for actors
/// is null
public Layer(ISpaceAlgorithm spaceAlgorithm)
{
Space = spaceAlgorithm ?? throw new ArgumentNullException(nameof(spaceAlgorithm));
}
///
/// Restructure a inner collection, if layer is dynamic, because actors can change own position
///
public virtual void Reset()
{
if (IsDynamic)
Space.Reset();
}
}