diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/object/ObjectOrientation.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/object/ObjectOrientation.kt index d8b24ecb..8397fba3 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/object/ObjectOrientation.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/object/ObjectOrientation.kt @@ -35,6 +35,8 @@ import ru.dbotthepony.kstarbound.defs.tile.isEmptyTile import ru.dbotthepony.kstarbound.util.AssetPathStack import ru.dbotthepony.kstarbound.world.Direction import ru.dbotthepony.kstarbound.world.World +import ru.dbotthepony.kstarbound.world.entities.tile.WorldObject +import java.util.function.Predicate import kotlin.math.PI data class ObjectOrientation( @@ -64,12 +66,18 @@ data class ObjectOrientation( if (occupySpaces.isEmpty()) return true - return occupySpaces.all { + var valid = occupySpaces.all { val cell = world.chunkMap.getCell(it + position) //if (!cell.foreground.material.isEmptyTile) println("not empty tile: ${it + position}, space $it, pos $position") //if (cell.dungeonId in world.protectedDungeonIDs) println("position is protected: ${it + position}") cell.foreground.material.isEmptyTile && (ignoreProtectedDungeons || cell.dungeonId !in world.protectedDungeonIDs) } + + if (valid) { + valid = !world.entityIndex.any(AABB.ofPoints(occupySpaces), Predicate { it is WorldObject && occupySpaces.any { s -> s in it.occupySpaces } }) + } + + return valid } fun anchorsValid(world: World<*, *>, position: Vector2i, considerNullAsValid: Boolean = false): Boolean {