Merge pull request #825 from craftworkgames/new_collision_2023

Add constructor for CollisionComponent.cs
This commit is contained in:
Max Kopjev
2023-12-09 18:09:00 +01:00
committed by GitHub
@@ -27,7 +27,7 @@ namespace MonoGame.Extended.Collisions
private HashSet<(Layer, Layer)> _layerCollision = new();
/// <summary>
/// Creates a collision tree covering the specified area.
/// Creates component with default layer, which is a collision tree covering the specified area (using <see cref="QuadTree"/>.
/// </summary>
/// <param name="boundary">Boundary of the collision tree.</param>
public CollisionComponent(RectangleF boundary)
@@ -35,6 +35,17 @@ namespace MonoGame.Extended.Collisions
SetDefaultLayer(new Layer(new QuadTreeSpace(boundary)));
}
/// <summary>
/// Creates component with specifies default layer.
/// If layer is null, method creates component without default layer.
/// </summary>
/// <param name="layer">Default layer</param>
public CollisionComponent(Layer layer = null)
{
if (layer is not null)
SetDefaultLayer(layer);
}
/// <summary>
/// The main layer has the name from <see cref="DEFAULT_LAYER_NAME"/>.
/// The main layer collision with itself and all other layers.