mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-21 01:39:32 +00:00
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using System;
|
|
|
|
namespace MonoGame.Extended.Collisions.Layers;
|
|
|
|
/// <summary>
|
|
/// Layer is a group of collision's actors.
|
|
/// </summary>
|
|
public class Layer
|
|
{
|
|
/// <summary>
|
|
/// If this property equals true, layer always will reset collision space.
|
|
/// </summary>
|
|
public bool IsDynamic { get; set; } = true;
|
|
|
|
|
|
/// <summary>
|
|
/// The space, which contain actors.
|
|
/// </summary>
|
|
public readonly ISpaceAlgorithm Space;
|
|
|
|
/// <summary>
|
|
/// Constructor for layer
|
|
/// </summary>
|
|
/// <param name="spaceAlgorithm">A space algorithm for actors</param>
|
|
/// <exception cref="ArgumentNullException"><paramref name="spaceAlgorithm"/> is null</exception>
|
|
public Layer(ISpaceAlgorithm spaceAlgorithm)
|
|
{
|
|
Space = spaceAlgorithm ?? throw new ArgumentNullException(nameof(spaceAlgorithm));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Restructure a inner collection, if layer is dynamic, because actors can change own position
|
|
/// </summary>
|
|
public virtual void Reset()
|
|
{
|
|
if (IsDynamic)
|
|
Space.Reset();
|
|
}
|
|
}
|