Optmizes handle_mutations_and_radiation

Saving about 90% CPU power on blank humanoids
This commit is contained in:
joep van der velden
2021-05-06 22:36:51 +02:00
parent d4a6a4bcc8
commit dbb153339f
7 changed files with 25 additions and 27 deletions
+1 -5
View File
@@ -32,7 +32,7 @@
var/mutation_active = M.dna.GetSEState(mutation.block)
// Sanity checks, don't skip.
if(!mutation.can_activate(M, flags) && mutation_active)
if(mutation_active && !mutation.can_activate(M, flags))
//testing("[M] - Failed to activate [gene.name] (can_activate fail).")
return FALSE
@@ -46,11 +46,7 @@
if(mutation_active)
//testing("[gene.name] activated!")
mutation.activate(M)
if(M)
M.active_mutations |= mutation.type
// If Gene is NOT active:
else
//testing("[gene.name] deactivated!")
mutation.deactivate(M)
if(M)
M.active_mutations -= mutation.type
+2
View File
@@ -32,6 +32,7 @@
// Called when the gene activates. Do your magic here.
/datum/mutation/proc/activate(mob/living/M)
M.gene_stability -= instability
M.active_mutations |= type // |= is probably not required but just in case
for(var/thing in traits_to_add)
ADD_TRAIT(M, thing, GENETIC_MUTATION)
if(length(activation_messages))
@@ -43,6 +44,7 @@
// Only called when the block is deactivated.
/datum/mutation/proc/deactivate(mob/living/M)
M.gene_stability += instability
M.active_mutations -= type
for(var/thing in traits_to_add)
REMOVE_TRAIT(M, thing, GENETIC_MUTATION)
if(length(deactivation_messages))