mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-28 05:45:10 -06:00
Smaller performance improvements
This commit is contained in:
parent
138d9d78a1
commit
bee7395f3e
1 changed files with 17 additions and 6 deletions
|
|
@ -175,16 +175,16 @@ object CombatMovementIntents {
|
|||
reservedTiles.addAll(occupiedTiles(attacker, attacker.location))
|
||||
return
|
||||
}
|
||||
|
||||
val candidates = movementDestinationsFor(attacker, target, targetLocation)
|
||||
val standingOnCandidate = candidates.any { it.location == attacker.location }
|
||||
if (standingOnCandidate && canAttackFrom(attacker, target, attacker.location, targetLocation)) {
|
||||
if (canAttackFrom(attacker, target, attacker.location, targetLocation)) {
|
||||
attacker.walkingQueue.reset()
|
||||
attacker.face(target)
|
||||
projectedLocations[attacker] = attacker.location
|
||||
reservedTiles.addAll(occupiedTiles(attacker, attacker.location))
|
||||
return
|
||||
}
|
||||
|
||||
val candidates = movementDestinationsFor(attacker, target, targetLocation)
|
||||
val standingOnCandidate = candidates.any { it.location == attacker.location }
|
||||
val projectedAttackerLocation = CombatMovementPlanner.predictTargetLocations(attacker).lastOrNull()
|
||||
if (projectedAttackerLocation != null && canAttackFrom(attacker, target, projectedAttackerLocation, targetLocation)) {
|
||||
attacker.face(target)
|
||||
|
|
@ -348,12 +348,23 @@ object CombatMovementIntents {
|
|||
}
|
||||
}
|
||||
}
|
||||
return tiles.filter { hasProjectileLineOfSight(it, attacker.size(), target, targetLocation) }.sortedWith(
|
||||
tiles.sortWith(
|
||||
compareBy<Location> { it.getDistance(attacker.location) }
|
||||
.thenBy { it.getDistance(closestOccupiedTile(target, targetLocation, it)) }
|
||||
.thenBy { it.x }
|
||||
.thenBy { it.y }
|
||||
).take(MAX_RANGED_APPROACH_CANDIDATES)
|
||||
)
|
||||
val attackTiles = ArrayList<Location>(minOf(MAX_RANGED_APPROACH_CANDIDATES, tiles.size))
|
||||
for (tile in tiles) {
|
||||
if (!hasProjectileLineOfSight(tile, attacker.size(), target, targetLocation)) {
|
||||
continue
|
||||
}
|
||||
attackTiles.add(tile)
|
||||
if (attackTiles.size >= MAX_RANGED_APPROACH_CANDIDATES) {
|
||||
break
|
||||
}
|
||||
}
|
||||
return attackTiles
|
||||
}
|
||||
|
||||
private fun canAttackFromMelee(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue