From acea7b2e728787a0d83bbf83c8c1f042d2c32e7e Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Mon, 3 Jun 2024 10:15:45 +0800 Subject: + plugins project --- .../MonoGame.Extended.Collisions/Layers/Layer.cs | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Plugins/MonoGame.Extended/source/MonoGame.Extended.Collisions/Layers/Layer.cs (limited to 'Plugins/MonoGame.Extended/source/MonoGame.Extended.Collisions/Layers/Layer.cs') 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; + +/// +/// 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(); + } +} -- cgit v1.1-26-g67d0