BasicNetworkedElement.bumpVersion call from outside now properly notifies listeners

This commit is contained in:
DBotThePony 2024-05-22 19:03:11 +07:00
parent 06a202bf17
commit 6729f2decc
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -42,11 +42,16 @@ open class BasicNetworkedElement<TYPE, LEGACY>(private var value: TYPE, protecte
val old = value val old = value
value = t value = t
queue.clear() queue.clear()
bumpVersion() super.bumpVersion()
valueListeners.forEach { it.callable.invoke(t, old) } valueListeners.forEach { it.callable.invoke(t, old) }
} }
} }
override fun bumpVersion() {
super.bumpVersion()
valueListeners.forEach { it.callable.invoke(value, value) }
}
override fun addListener(listener: Consumer<TYPE>): Listenable.L { override fun addListener(listener: Consumer<TYPE>): Listenable.L {
return Listener(listener) return Listener(listener)
} }
@ -68,7 +73,7 @@ open class BasicNetworkedElement<TYPE, LEGACY>(private var value: TYPE, protecte
val old = value val old = value
value = if (isLegacy) fromLegacy(legacyCodec.read(data)) else codec.read(data) value = if (isLegacy) fromLegacy(legacyCodec.read(data)) else codec.read(data)
queue.clear() queue.clear()
bumpVersion() super.bumpVersion()
if (value != old) { if (value != old) {
valueListeners.forEach { it.callable.invoke(value, old) } valueListeners.forEach { it.callable.invoke(value, old) }
@ -85,7 +90,7 @@ open class BasicNetworkedElement<TYPE, LEGACY>(private var value: TYPE, protecte
override fun readDelta(data: DataInputStream, interpolationDelay: Double, isLegacy: Boolean) { override fun readDelta(data: DataInputStream, interpolationDelay: Double, isLegacy: Boolean) {
val read = if (isLegacy) fromLegacy(legacyCodec.read(data)) else codec.read(data) val read = if (isLegacy) fromLegacy(legacyCodec.read(data)) else codec.read(data)
bumpVersion() super.bumpVersion()
if (isInterpolating) { if (isInterpolating) {
queue.push(read, interpolationDelay) queue.push(read, interpolationDelay)