Skip to content

Commit

Permalink
Optimizes hunger appearance work (tgstation#85299)
Browse files Browse the repository at this point in the history
## About The Pull Request

If our appearance is fully dependant on hunger state, there's no reason
to do ANY work if the state hasn't changed, also don't churn underlays
for no reason.

## Why It's Good For The Game

This has relatively high cost and it's an easy win
  • Loading branch information
LemonInTheDark authored Aug 14, 2024
1 parent 2ce8063 commit 0fc7c56
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -886,9 +886,9 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/splash)
/atom/movable/screen/hunger/update_appearance(updates)
var/old_state = state
update_hunger_state() // Do this before we call all the other update procs
. = ..()
if(state == old_state) // Let's not be wasteful
return
. = ..()
if(state == HUNGER_STATE_FINE)
SetInvisibility(INVISIBILITY_ABSTRACT, name)
return
Expand All @@ -906,9 +906,10 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/splash)
remove_filter("hunger_outline")

// Update color of the food
underlays -= food_image
food_image.color = state == HUNGER_STATE_FAT ? COLOR_DARK : null
underlays += food_image
if((state == HUNGER_STATE_FAT) != (old_state == HUNGER_STATE_FAT))
underlays -= food_image
food_image.color = state == HUNGER_STATE_FAT ? COLOR_DARK : null
underlays += food_image

/atom/movable/screen/hunger/update_icon_state()
. = ..()
Expand Down

0 comments on commit 0fc7c56

Please sign in to comment.