мельком глянул,времени и мозгов нет чтоб запустить,переписать и потестить, но судя по всему после строчки
идет проверка на клетки вокруг ивента,т.е. в случаях загораживания прохода ивент не появляется.Код:if (NoPassageBlock === true) {
НО при этом НЕ в проходах ивенты продолжают появляться,так эти проверки никак не влияют на случаи расположения ивента НЕ в проходах.
поэтому кроме того что возвращаем "тру" (return true) а не "фальш" для появления ивентов в проходах
также добавляем пару строк после последней проверки, чтобы в осталньых случаях возвращалась "Ложь"Код:if (NoPassageBlock === true) {
// check passability to the left
if (this.isWallRoofOrRubble(x - 1, y) === false && this.isWallRoofOrRubble(x - 1, y + 1) === true
&& this.isWallRoofOrRubble(x - 1, y - 1) === true) {
return true;
}
// check passability to the right
if (this.isWallRoofOrRubble(x + 1, y) === false && this.isWallRoofOrRubble(x + 1, y + 1) === true
&& this.isWallRoofOrRubble(x + 1, y - 1) === true) {
return true;
}
// check passability up
if (this.isWallRoofOrRubble(x, y - 1) === false && this.isWallRoofOrRubble(x + 1, y - 1) === true
&& this.isWallRoofOrRubble(x - 1, y - 1) === true) {
return true;
}
// check passability down
if (this.isWallRoofOrRubble(x, y + 1) === false && this.isWallRoofOrRubble(x + 1, y + 1) === true
&& this.isWallRoofOrRubble(x - 1, y + 1) === true) {
return true;
}
}
получится что-то типа этого.Код:(else {return false;}
повторяю - не запускал,не разбирался, не тестил, просто предположениеКод:if (NoPassageBlock === true) {
// check passability to the left
if (this.isWallRoofOrRubble(x - 1, y) === false && this.isWallRoofOrRubble(x - 1, y + 1) === true
&& this.isWallRoofOrRubble(x - 1, y - 1) === true) {
return true;
}
// check passability to the right
if (this.isWallRoofOrRubble(x + 1, y) === false && this.isWallRoofOrRubble(x + 1, y + 1) === true
&& this.isWallRoofOrRubble(x + 1, y - 1) === true) {
return true;
}
// check passability up
if (this.isWallRoofOrRubble(x, y - 1) === false && this.isWallRoofOrRubble(x + 1, y - 1) === true
&& this.isWallRoofOrRubble(x - 1, y - 1) === true) {
return true;
}
// check passability down
if (this.isWallRoofOrRubble(x, y + 1) === false && this.isWallRoofOrRubble(x + 1, y + 1) === true
&& this.isWallRoofOrRubble(x - 1, y + 1) === true) {
return true;
} else {
return false;
}
}