Class DefaultGroupPlacementStrategy.Constraint
- Namespace
- RandomizerCore.Randomization
- Assembly
- RandomizerCore.dll
public record DefaultGroupPlacementStrategy.Constraint : IEquatable<DefaultGroupPlacementStrategy.Constraint>
- Inheritance
-
DefaultGroupPlacementStrategy.Constraint
- Implements
- Inherited Members
Constructors
Constraint()
protected Constraint()
Constraint(Func<IRandoItem, IRandoLocation, bool>, Action<IRandoItem, IRandoLocation>?, string?)
public Constraint(Func<IRandoItem, IRandoLocation, bool> Test, Action<IRandoItem, IRandoLocation>? Fail = null, string? Label = null)
Parameters
Test
Func<IRandoItem, IRandoLocation, bool>Fail
Action<IRandoItem, IRandoLocation>Label
string
Properties
Fail
Delegate for OnViolated(IRandoItem, IRandoLocation)
public Action<IRandoItem, IRandoLocation>? Fail { get; init; }
Property Value
Label
Optional identifying label
public string? Label { get; init; }
Property Value
Test
Delegate for IsSatisfied(IRandoItem, IRandoLocation)
public Func<IRandoItem, IRandoLocation, bool> Test { get; init; }
Property Value
Methods
IsSatisfied(IRandoItem, IRandoLocation)
Return false to indicate that the item cannot be placed with the location, unless no constraint-satisfying alternatives exist.
public bool IsSatisfied(IRandoItem ri, IRandoLocation rl)
Parameters
ri
IRandoItemrl
IRandoLocation
Returns
OnViolated(IRandoItem, IRandoLocation)
Called when the constraint is not satisfied, but no constraint-satisfying alternatives exist. Exit normally to accept the placement, or throw OutOfLocationsException to trigger a new attempt. Throw other exceptions to halt randomization.
public void OnViolated(IRandoItem ri, IRandoLocation rl)
Parameters
ri
IRandoItemrl
IRandoLocation