Skip to content

Commit

Permalink
UPD читаемости
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoonij authored Sep 22, 2024
1 parent ffe32f0 commit 6b96b55
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions code/datums/components/animal_temperature.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@
)
if(!isanimal(parent))
return COMPONENT_INCOMPATIBLE

if(minbodytemp)
src.minbodytemp = minbodytemp

if(maxbodytemp)
src.maxbodytemp = maxbodytemp

if(cold_damage)
src.cold_damage = cold_damage

if(heat_damage)
src.heat_damage = heat_damage

if(show_alert)
src.show_alert = show_alert

Expand All @@ -47,10 +52,12 @@

/datum/component/animal_temperature/proc/regulate_temperature(mob/living/simple_animal/animal, datum/gas_mixture/environment)
var/areatemp = animal.get_temperature(environment)

if(abs(areatemp - animal.bodytemperature) > 5)
var/diff = areatemp - animal.bodytemperature
diff = diff / 5
animal.adjust_bodytemperature(diff)

return

/datum/component/animal_temperature/proc/check_temperature(mob/living/simple_animal/animal)
Expand All @@ -59,15 +66,18 @@
if(show_alert)
animal.throw_alert("temp", /atom/movable/screen/alert/cold, get_severity(animal))
return TRUE

if(animal.bodytemperature > maxbodytemp)
animal.adjustHealth(heat_damage)
if(show_alert)
animal.throw_alert("temp", /atom/movable/screen/alert/hot, get_severity(animal))
return TRUE

animal.clear_alert("temp")
return FALSE

/datum/component/animal_temperature/proc/get_severity(mob/living/simple_animal/animal)
var/multiplier = animal.bodytemperature < minbodytemp ? (1 / minbodytemp) : (1 / maxbodytemp)
var/severity = CEILING(abs(animal.bodytemperature / multiplier), 1)

return min(severity, 3)

0 comments on commit 6b96b55

Please sign in to comment.