Make cooldownPercent be property

This commit is contained in:
DBotThePony 2022-10-16 15:03:15 +07:00
parent df683477d1
commit 5a8a3e375d
Signed by: DBot
GPG Key ID: DCC23B5715498507
3 changed files with 4 additions and 4 deletions

View File

@ -28,7 +28,7 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma
val isOnCooldown: Boolean
get() = maxCooldown > 0 && cooldown > 0
fun getCooldownPercent(): Float {
val cooldownPercent: Float get() {
if (maxCooldown <= 0) return 0.0f
return (cooldown.toFloat() / maxCooldown.toFloat()).coerceIn(0.0f, 1.0f)
}

View File

@ -66,7 +66,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl
if (feature.isOnCooldown) {
RGBAColor.WHITE.setSystemColor()
val cooldownPct = feature.getCooldownPercent()
val cooldownPct = feature.cooldownPercent
if (cooldownPct > 0.0f) {
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f)

View File

@ -237,9 +237,9 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
minecraft.font.drawAligned(event.poseStack, feature.type.displayName, TextAlign.CENTER_CENTER, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, 0)
minecraft.font.drawAligned(event.poseStack, feature.type.displayName, TextAlign.CENTER_CENTER, shift * cos, -shift * sin - iconSize / 1.5f, if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED)
if (feature.isOnCooldown && feature.getCooldownPercent() > 0.0f) {
if (feature.isOnCooldown && feature.cooldownPercent > 0.0f) {
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f)
drawArc(event.poseStack, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.getCooldownPercent().toDouble())
drawArc(event.poseStack, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble())
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
minecraft.font.drawAligned(event.poseStack, formatTickDuration(feature.cooldown), TextAlign.CENTER_CENTER, shift * cos, -shift * sin + iconSize / 1.5f, RGBAColor.WHITE)