handle modules larger than 1x1, widen door size to allow walking around it
This commit is contained in:
@@ -9,14 +9,17 @@ namespace EscapeRoomEngine.Engine.Runtime.Requirements
|
||||
{
|
||||
protected override List<Placement> FilterCandidates(List<Placement> candidates, Module module, Space space)
|
||||
{
|
||||
float width = space.rrPlacement.size.x - 1;
|
||||
float length = space.rrPlacement.size.y - 1;
|
||||
float width = space.rrPlacement.size.x;
|
||||
float length = space.rrPlacement.size.y;
|
||||
|
||||
candidates.RemoveAll(candidate =>
|
||||
{
|
||||
var xRel = candidate.position.x / width;
|
||||
var zRel = candidate.position.z / length;
|
||||
|
||||
var bottomLeft = candidate.BottomLeft;
|
||||
var center = new Vector2(bottomLeft.x, bottomLeft.z) +
|
||||
new Vector2(candidate.size.x / 2f, candidate.size.y / 2f);
|
||||
var xRel = center.x / width;
|
||||
var zRel = center.y / length;
|
||||
|
||||
return candidate.orientation !=
|
||||
(zRel > xRel
|
||||
? zRel > 1 - xRel
|
||||
|
||||
@@ -9,10 +9,22 @@ namespace EscapeRoomEngine.Engine.Runtime.Requirements
|
||||
{
|
||||
protected override List<Placement> FilterCandidates(List<Placement> candidates, Module module, Space space)
|
||||
{
|
||||
space.AllModules.ForEach(other =>
|
||||
{
|
||||
candidates.RemoveAll(candidate => candidate.position.Equals(other.SrPosition));
|
||||
});
|
||||
space.AllModules.ForEach(other => // for all other module ...
|
||||
other.srPlacement.ForEachPosition(otherPosition => // ... positions ...
|
||||
candidates.RemoveAll(candidate => // ... remove every candidate that ...
|
||||
{
|
||||
var remove = false;
|
||||
|
||||
candidate.ForEachPosition(position => // ... anywhere inside its bounds ...
|
||||
{
|
||||
if (!remove)
|
||||
{
|
||||
remove = position.Equals(otherPosition); // ... overlaps with other modules' position
|
||||
}
|
||||
});
|
||||
|
||||
return remove;
|
||||
})));
|
||||
|
||||
return candidates;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,17 @@ namespace EscapeRoomEngine.Engine.Runtime.Requirements
|
||||
|
||||
candidates.RemoveAll(candidate =>
|
||||
{
|
||||
var position = candidate.position;
|
||||
return position.x > 0 && position.x < right && position.z > 0 && position.z < top;
|
||||
var keep = false;
|
||||
|
||||
candidate.ForEachPosition(position =>
|
||||
{
|
||||
if (!keep)
|
||||
{
|
||||
keep = position.x == 0 || position.x == right || position.z == 0 || position.z == top;
|
||||
}
|
||||
});
|
||||
|
||||
return !keep;
|
||||
});
|
||||
|
||||
return candidates;
|
||||
|
||||
@@ -18,11 +18,11 @@ namespace EscapeRoomEngine.Engine.Runtime.Requirements
|
||||
}
|
||||
|
||||
var placementCandidates = Candidates(
|
||||
space.rrPlacement.EveryPlacement,
|
||||
module.srPlacement.EveryPlacementInSpace(space),
|
||||
module.description.placementRequirements,
|
||||
module, space);
|
||||
|
||||
Logger.Log($"placement candidates: {string.Join(", ", placementCandidates.ToList().ConvertAll(c => c.PositionAndOrientation()))}", LogType.RequirementResolution);
|
||||
Logger.Log($"placement candidates: {string.Join(", ", placementCandidates.ToList().ConvertAll(c => c.ToStringShort()))}", LogType.RequirementResolution);
|
||||
|
||||
if (placementCandidates.Count > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user