blob: 6e97ac873a01f1a66720937e4e5f813daf060c21 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
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();
}
}
|