fix FaceSpaceCenter requirement
This commit is contained in:
@@ -14,20 +14,40 @@ namespace EscapeRoomEngine.Engine.Runtime.Requirements
|
||||
|
||||
candidates.RemoveAll(candidate =>
|
||||
{
|
||||
var bottomLeft = candidate.BottomLeft;
|
||||
var center = new Vector2(bottomLeft.x, bottomLeft.z) +
|
||||
new Vector2(candidate.size.x / 2f, candidate.size.y / 2f);
|
||||
var orientation = candidate.orientation;
|
||||
var center = candidate.GeometricCenter;
|
||||
var xRel = center.x / width;
|
||||
var zRel = center.y / length;
|
||||
var zRel = center.z / length;
|
||||
bool keep;
|
||||
|
||||
// check the space diagonals
|
||||
if (Mathf.Approximately(xRel, zRel))
|
||||
{
|
||||
keep = Mathf.Approximately(xRel, 0.5f) ||
|
||||
(xRel < 0.5f
|
||||
? orientation is Orientation.East or Orientation.North // on bottom left diagonal of space
|
||||
: orientation is Orientation.West or Orientation.South); // on top right diagonal of space
|
||||
}
|
||||
else if (Mathf.Approximately(xRel, 1 - zRel))
|
||||
{
|
||||
keep = xRel < 0.5f
|
||||
? orientation is Orientation.East or Orientation.South // on top left diagonal of space
|
||||
: orientation is Orientation.West or Orientation.North; // on bottom right diagonal of space
|
||||
}
|
||||
else
|
||||
{
|
||||
// check the areas between the diagonals
|
||||
keep = orientation ==
|
||||
(zRel > xRel
|
||||
? zRel > 1 - xRel
|
||||
? Orientation.South
|
||||
: Orientation.East
|
||||
: zRel > 1 - xRel
|
||||
? Orientation.West
|
||||
: Orientation.North);
|
||||
}
|
||||
|
||||
return candidate.orientation !=
|
||||
(zRel > xRel
|
||||
? zRel > 1 - xRel
|
||||
? Orientation.South
|
||||
: Orientation.East
|
||||
: zRel > 1 - xRel
|
||||
? Orientation.West
|
||||
: Orientation.North);
|
||||
return !keep;
|
||||
});
|
||||
|
||||
return candidates;
|
||||
|
||||
Reference in New Issue
Block a user