mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
RemoveIf -> RemoveAll to avoid jvm dependencies
This commit is contained in:
parent
6448f8e47e
commit
fd428ce606
@ -1,5 +1,7 @@
|
|||||||
package com.unciv.logic.event
|
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 java.lang.ref.WeakReference
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
@ -85,7 +87,7 @@ object EventBus {
|
|||||||
private fun cleanUp(eventHandlers: Map<KClass<*>, MutableList<Any>>) {
|
private fun cleanUp(eventHandlers: Map<KClass<*>, MutableList<Any>>) {
|
||||||
for ((kClass, toRemove) in eventHandlers) {
|
for ((kClass, toRemove) in eventHandlers) {
|
||||||
val registeredListeners = listeners.get(kClass)
|
val registeredListeners = listeners.get(kClass)
|
||||||
registeredListeners?.removeIf {
|
registeredListeners?.removeAll {
|
||||||
val eventHandler = it.eventHandler.get()
|
val eventHandler = it.eventHandler.get()
|
||||||
eventHandler == null || (eventHandler as Any) in toRemove
|
eventHandler == null || (eventHandler as Any) in toRemove
|
||||||
}
|
}
|
||||||
|
@ -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
|
// We should only be able to move to tiles that our escort can also move to
|
||||||
val escortDistanceToTiles = unit.getOtherEscortUnit()!!.movement
|
val escortDistanceToTiles = unit.getOtherEscortUnit()!!.movement
|
||||||
.getDistanceToTiles(considerZoneOfControl, includeOtherEscortUnit = false)
|
.getDistanceToTiles(considerZoneOfControl, includeOtherEscortUnit = false)
|
||||||
distanceToTiles.keys.removeIf { !escortDistanceToTiles.containsKey(it) }
|
distanceToTiles.keys.removeAll { !escortDistanceToTiles.containsKey(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return distanceToTiles
|
return distanceToTiles
|
||||||
|
@ -18,7 +18,7 @@ open class KeyShortcutDispatcher {
|
|||||||
|
|
||||||
fun add(shortcut: KeyShortcut?, action: ActivationAction?) {
|
fun add(shortcut: KeyShortcut?, action: ActivationAction?) {
|
||||||
if (action == null || shortcut == null) return
|
if (action == null || shortcut == null) return
|
||||||
shortcuts.removeIf { it.shortcut == shortcut }
|
shortcuts.removeAll { it.shortcut == shortcut }
|
||||||
shortcuts.add(ShortcutAction(shortcut, action))
|
shortcuts.add(ShortcutAction(shortcut, action))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,23 +42,23 @@ open class KeyShortcutDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun remove(shortcut: KeyShortcut?) {
|
fun remove(shortcut: KeyShortcut?) {
|
||||||
shortcuts.removeIf { it.shortcut == shortcut }
|
shortcuts.removeAll { it.shortcut == shortcut }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun remove(binding: KeyboardBinding) {
|
fun remove(binding: KeyboardBinding) {
|
||||||
shortcuts.removeIf { it.shortcut.binding == binding }
|
shortcuts.removeAll { it.shortcut.binding == binding }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun remove(key: KeyCharAndCode?) {
|
fun remove(key: KeyCharAndCode?) {
|
||||||
shortcuts.removeIf { it.shortcut.key == key }
|
shortcuts.removeAll { it.shortcut.key == key }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun remove(char: Char?) {
|
fun remove(char: Char?) {
|
||||||
shortcuts.removeIf { it.shortcut.key.char == char }
|
shortcuts.removeAll { it.shortcut.key.char == char }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun remove(keyCode: Int?) {
|
fun remove(keyCode: Int?) {
|
||||||
shortcuts.removeIf { it.shortcut.key.code == keyCode }
|
shortcuts.removeAll { it.shortcut.key.code == keyCode }
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun isActive(): Boolean = true
|
open fun isActive(): Boolean = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user