RemoveIf -> RemoveAll to avoid jvm dependencies

This commit is contained in:
Yair Morgenstern 2024-02-27 11:00:39 +02:00
parent 6448f8e47e
commit fd428ce606
3 changed files with 10 additions and 8 deletions

View File

@ -1,5 +1,7 @@
package com.unciv.logic.event
import com.unciv.logic.event.EventBus.EventReceiver
import com.unciv.logic.event.EventBus.send
import java.lang.ref.WeakReference
import kotlin.reflect.KClass
@ -85,7 +87,7 @@ object EventBus {
private fun cleanUp(eventHandlers: Map<KClass<*>, MutableList<Any>>) {
for ((kClass, toRemove) in eventHandlers) {
val registeredListeners = listeners.get(kClass)
registeredListeners?.removeIf {
registeredListeners?.removeAll {
val eventHandler = it.eventHandler.get()
eventHandler == null || (eventHandler as Any) in toRemove
}

View File

@ -712,7 +712,7 @@ class UnitMovement(val unit: MapUnit) {
// We should only be able to move to tiles that our escort can also move to
val escortDistanceToTiles = unit.getOtherEscortUnit()!!.movement
.getDistanceToTiles(considerZoneOfControl, includeOtherEscortUnit = false)
distanceToTiles.keys.removeIf { !escortDistanceToTiles.containsKey(it) }
distanceToTiles.keys.removeAll { !escortDistanceToTiles.containsKey(it) }
}
}
return distanceToTiles

View File

@ -18,7 +18,7 @@ open class KeyShortcutDispatcher {
fun add(shortcut: KeyShortcut?, action: ActivationAction?) {
if (action == null || shortcut == null) return
shortcuts.removeIf { it.shortcut == shortcut }
shortcuts.removeAll { it.shortcut == shortcut }
shortcuts.add(ShortcutAction(shortcut, action))
}
@ -42,23 +42,23 @@ open class KeyShortcutDispatcher {
}
fun remove(shortcut: KeyShortcut?) {
shortcuts.removeIf { it.shortcut == shortcut }
shortcuts.removeAll { it.shortcut == shortcut }
}
fun remove(binding: KeyboardBinding) {
shortcuts.removeIf { it.shortcut.binding == binding }
shortcuts.removeAll { it.shortcut.binding == binding }
}
fun remove(key: KeyCharAndCode?) {
shortcuts.removeIf { it.shortcut.key == key }
shortcuts.removeAll { it.shortcut.key == key }
}
fun remove(char: Char?) {
shortcuts.removeIf { it.shortcut.key.char == char }
shortcuts.removeAll { it.shortcut.key.char == char }
}
fun remove(keyCode: Int?) {
shortcuts.removeIf { it.shortcut.key.code == keyCode }
shortcuts.removeAll { it.shortcut.key.code == keyCode }
}
open fun isActive(): Boolean = true