summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended.Collisions/Layers/Layer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/MonoGame.Extended/source/MonoGame.Extended.Collisions/Layers/Layer.cs')
-rw-r--r--Plugins/MonoGame.Extended/source/MonoGame.Extended.Collisions/Layers/Layer.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Collisions/Layers/Layer.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Collisions/Layers/Layer.cs
new file mode 100644
index 0000000..6e97ac8
--- /dev/null
+++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Collisions/Layers/Layer.cs
@@ -0,0 +1,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();
+ }
+}