rework dimensions and orientation into Placement, optimise requirements to work on previous candidates, use vec3 for positions
This commit is contained in:
@@ -7,22 +7,18 @@ namespace EscapeRoomEngine.Engine.Runtime.Requirements
|
||||
[CreateAssetMenu(menuName = "Requirements/Place Along Space Edges")]
|
||||
public class PlaceAlongSpaceEdges : PlacementRequirement
|
||||
{
|
||||
protected override IEnumerable<Vector2Int> GenerateCandidates(Module module, Space space)
|
||||
protected override List<Placement> FilterCandidates(List<Placement> candidates, Module module, Space space)
|
||||
{
|
||||
var edgePositions = new HashSet<Vector2Int>();
|
||||
var right = space.rrPlacement.size.x - 1;
|
||||
var top = space.rrPlacement.size.y - 1;
|
||||
|
||||
for (var x = 0; x < space.rrDimensions.width; x++)
|
||||
candidates.RemoveAll(candidate =>
|
||||
{
|
||||
edgePositions.Add(new Vector2Int(x, 0));
|
||||
edgePositions.Add(new Vector2Int(x, space.rrDimensions.length - 1));
|
||||
}
|
||||
for (var z = 0; z < space.rrDimensions.length; z++)
|
||||
{
|
||||
edgePositions.Add(new Vector2Int(0, z));
|
||||
edgePositions.Add(new Vector2Int(space.rrDimensions.width - 1, z));
|
||||
}
|
||||
var position = candidate.position;
|
||||
return position.x > 0 && position.x < right && position.z > 0 && position.z < top;
|
||||
});
|
||||
|
||||
return edgePositions;
|
||||
return candidates;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user