dropped item can be picked up (at a weird distance)

This commit is contained in:
minjaesong
2021-10-02 17:50:27 +09:00
parent 6fda6bafe4
commit f6b0b447a4
5 changed files with 51 additions and 8 deletions

View File

@@ -425,8 +425,8 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
/** Will use centre point of the actors
* @return List of DistanceResult, list may be empty */
fun findKNearestActors(from: ActorWithBody, maxHits: Int): List<DistanceResult<ActorWithBody>> {
return actorsRTree.nearestNeighbour(actorDistanceCalculator, null, maxHits, object : PointND {
fun findKNearestActors(from: ActorWithBody, maxHits: Int, nodeFilter: (ActorWithBody) -> Boolean): List<DistanceResult<ActorWithBody>> {
return actorsRTree.nearestNeighbour(actorDistanceCalculator, nodeFilter, maxHits, object : PointND {
override fun getDimensions(): Int = 2
override fun getOrd(axis: Int): Double = when(axis) {
0 -> from.hitbox.centeredX
@@ -437,8 +437,8 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
}
/** Will use centre point of the actors
* @return Pair of: the actor, distance from the actor; null if none found */
fun findNearestActors(from: ActorWithBody): DistanceResult<ActorWithBody>? {
val t = findKNearestActors(from, 1)
fun findNearestActor(from: ActorWithBody, nodeFilter: (ActorWithBody) -> Boolean): DistanceResult<ActorWithBody>? {
val t = findKNearestActors(from, 1, nodeFilter)
return if (t.isNotEmpty())
t[0]
else