From a715a21226985141d0d62eeab79b3940d2b3e9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Wed, 2 Apr 2014 20:15:04 +0200 Subject: [PATCH] Made blank screens not draw power. This actually reduces the energy cost for screens, but realizing that computers and robots don't actually draw as fast as the config suggests (because they idle most of the time) this is for the better I think. --- src/main/resources/reference.conf | 17 ++++++++--------- .../li/cil/oc/common/tileentity/Screen.scala | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/resources/reference.conf b/src/main/resources/reference.conf index 293e43d97..7fff0c69d 100644 --- a/src/main/resources/reference.conf +++ b/src/main/resources/reference.conf @@ -471,15 +471,14 @@ opencomputers { # The amount of energy a screen consumes per tick. For each lit pixel # (each character that is not blank) this cost increases linearly: # for basic screens, if all pixels are lit the cost per tick will be - # twice as high as this value. Higher tier screens can become even - # more expensive to run, due to their higher resolution. If a screen - # cannot consume the defined amount of energy it will stop rendering - # the text that should be displayed on it. It will *not* forget that - # text, however, so when enough power is available again it will - # restore the previously displayed text (with any changes possibly - # made in the meantime). Note that for multi-block screens *each* - # screen that is part of it will consume this amount of energy per - # tick. + # this value. Higher tier screens can become even more expensive to + # run, due to their higher resolution. If a screen cannot consume the + # defined amount of energy it will stop rendering the text that + # should be displayed on it. It will *not* forget that text, however, + # so when enough power is available again it will restore the + # previously displayed text (with any changes possibly made in the + # meantime). Note that for multi-block screens *each* screen that is + # part of it will consume this amount of energy per tick. screen: 0.05 # The amount of energy a hologram projetor consumes per tick. This diff --git a/src/main/scala/li/cil/oc/common/tileentity/Screen.scala b/src/main/scala/li/cil/oc/common/tileentity/Screen.scala index 8c099f418..5ed3d3127 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Screen.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Screen.scala @@ -208,9 +208,9 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with // The relative lit area is the number of pixels that are not blank // versus the number of pixels in the *current* resolution. This is // scaled to multi-block screens, since we only compute this for the - // origin. We add 1 to make sure we at least consume `screenCost`. + // origin. val (w, h) = buffer.resolution - relativeLitArea = 1 + width * height * buffer.lines.foldLeft(0) { + relativeLitArea = width * height * buffer.lines.foldLeft(0) { (acc, line) => acc + line.count(' ' !=) } / (w * h).toDouble }