Add constructor for CollisionComponent.cs

This commit is contained in:
Gandifil
2023-12-09 20:05:15 +03:00
parent 102cba574d
commit 0367e93bd0
@@ -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.