Makes obj_integrity only updated through procs (#59474)

Having things updating integrity directly is just going to cause more problems down the line as more elements and components depend on being notified of integrity changes. It's an easy mistake to make so making it private should deal with the problem.

get_integrity() might be useful in the future but is mainly a side effect of making obj_integrity private as that also disallows reads.
This commit is contained in:
Emmett Gaines
2021-06-04 11:48:05 -03:00
committed by GitHub
parent cf937160de
commit 43c5dc8bfa
49 changed files with 133 additions and 97 deletions
+1 -1
View File
@@ -587,7 +587,7 @@
newlight.setDir(src.dir)
newlight.stage = cur_stage
if(!disassembled)
newlight.obj_integrity = newlight.max_integrity * 0.5
newlight.take_damage(newlight.max_integrity * 0.5, sound_effect=FALSE)
if(status != LIGHT_BROKEN)
break_light_tube()
if(status != LIGHT_EMPTY)
@@ -280,7 +280,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
if(!air)
return SUPERMATTER_ERROR
var/integrity = get_integrity()
var/integrity = get_integrity_percent()
if(integrity < SUPERMATTER_DELAM_PERCENT)
return SUPERMATTER_DELAMINATING
@@ -311,7 +311,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
if(SUPERMATTER_WARNING)
playsound(src, 'sound/machines/terminal_alert.ogg', 75)
/obj/machinery/power/supermatter_crystal/proc/get_integrity()
/obj/machinery/power/supermatter_crystal/proc/get_integrity_percent()
var/integrity = damage / explosion_point
integrity = round(100 - integrity * 100, 0.01)
integrity = integrity < 0 ? 0 : integrity
@@ -483,7 +483,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
//Check for holes in the SM inner chamber
for(var/turf/open/space/turf_to_check in RANGE_TURFS(1, loc))
if(LAZYLEN(turf_to_check.atmos_adjacent_turfs))
var/integrity = get_integrity()
var/integrity = get_integrity_percent()
if(integrity < 10)
damage += clamp((power * 0.0005) * DAMAGE_INCREASE_MULTIPLIER, 0, MAX_SPACE_EXPOSURE_DAMAGE)
else if(integrity < 25)
@@ -720,7 +720,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
//Oh shit it's bad, time to freak out
if(damage > emergency_point)
radio.talk_into(src, "[emergency_alert] Integrity: [get_integrity()]%", common_channel)
radio.talk_into(src, "[emergency_alert] Integrity: [get_integrity_percent()]%", common_channel)
SEND_SIGNAL(src, COMSIG_SUPERMATTER_DELAM_ALARM)
lastwarning = REALTIMEOFDAY
if(!has_reached_emergency)
@@ -728,12 +728,12 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
message_admins("[src] has reached the emergency point [ADMIN_JMP(src)].")
has_reached_emergency = TRUE
else if(damage >= damage_archived) // The damage is still going up
radio.talk_into(src, "[warning_alert] Integrity: [get_integrity()]%", engineering_channel)
radio.talk_into(src, "[warning_alert] Integrity: [get_integrity_percent()]%", engineering_channel)
SEND_SIGNAL(src, COMSIG_SUPERMATTER_DELAM_ALARM)
lastwarning = REALTIMEOFDAY - (WARNING_DELAY * 5)
else // Phew, we're safe
radio.talk_into(src, "[safe_alert] Integrity: [get_integrity()]%", engineering_channel)
radio.talk_into(src, "[safe_alert] Integrity: [get_integrity_percent()]%", engineering_channel)
lastwarning = REALTIMEOFDAY
if(power > POWER_PENALTY_THRESHOLD)
@@ -783,8 +783,8 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal)
if(!blob || isspaceturf(loc)) //does nothing in space
return
playsound(get_turf(src), 'sound/effects/supermatter.ogg', 50, TRUE)
damage += blob.obj_integrity * 0.5 //take damage equal to 50% of remaining blob health before it tried to eat us
if(blob.obj_integrity > 100)
damage += blob.get_integrity() * 0.5 //take damage equal to 50% of remaining blob health before it tried to eat us
if(blob.get_integrity() > 100)
blob.visible_message("<span class='danger'>\The [blob] strikes at \the [src] and flinches away!</span>",
"<span class='hear'>You hear a loud crack as you are washed with a wave of heat.</span>")
blob.take_damage(100, BURN)