Add REGENERATE_ENERGY_EFFICIENCY_FOOD and REGENERATE_ENERGY_EFFICIENCY_SATURATION

This commit is contained in:
DBotThePony 2025-03-14 12:04:16 +07:00
parent e06928a4b5
commit 5d8f2d5a4a
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 10 additions and 1 deletions

View File

@ -14,6 +14,14 @@ object PlayerConfig : AbstractConfig("player") {
.comment("And also whenever to regenerate energy while in peaceful")
.define("REGENERATE_ENERGY", true)
val REGENERATE_ENERGY_EFFICIENCY_FOOD: Double by builder
.comment("How much % of food points to convert to energy")
.defineInRange("REGENERATE_ENERGY_EFFICIENCY_FOOD", 0.75, 0.0)
val REGENERATE_ENERGY_EFFICIENCY_SATURATION: Double by builder
.comment("How much % of food saturation points to convert to energy")
.defineInRange("REGENERATE_ENERGY_EFFICIENCY_SATURATION", 0.4, 0.0)
val REGENERATE_ENERGY_IN_PEACEFUL: Boolean by builder
.comment("Regenerate energy while in peaceful")
.comment("This is disabled by default because this is easily exploitable")

View File

@ -25,7 +25,8 @@ import kotlin.math.roundToInt
class MatteryFoodData(private var player: Player) : FoodData() {
private fun add(foodLevel: Int, saturation: Float) {
if (player.matteryPlayer.isAndroid && PlayerConfig.REGENERATE_ENERGY) {
energyToDrain -= PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * foodLevel + PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * saturation
energyToDrain -= PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * foodLevel * PlayerConfig.REGENERATE_ENERGY_EFFICIENCY_FOOD
energyToDrain -= PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * saturation.coerceAtMost(PlayerConfig.Food.SOFT_FOOD_LIMIT.toFloat()) * PlayerConfig.REGENERATE_ENERGY_EFFICIENCY_SATURATION
} else if (!player.matteryPlayer.isAndroid) {
this.foodLevel = min(this.foodLevel + foodLevel, PlayerConfig.Food.HARD_FOOD_LIMIT)
this.saturationLevel = min(this.saturationLevel + saturation, this.foodLevel + PlayerConfig.Food.OVERSATURATION_LIMIT.toFloat()).coerceAtLeast(0f)