Merge pull request #10132 from Nyksia/species-moar-fix

Fixing few oversights and more optimization for species
This commit is contained in:
Novacat
2021-04-11 18:58:06 -04:00
committed by GitHub
2 changed files with 23 additions and 20 deletions
@@ -23,6 +23,8 @@
var/silk_color = "#FFFFFF"
var/list/traits = list()
//Vars that need to be copied when producing a copy of species.
var/list/copy_vars = list("base_species", "icobase", "deform", "tail", "tail_animation", "icobase_tail", "color_mult", "primitive_form", "appearance_flags", "flesh_color", "base_color", "blood_mask", "damage_mask", "damage_overlays", "move_trail", "has_floating_eyes")
/datum/species/proc/give_numbing_bite() //Holy SHIT this is hacky, but it works. Updating a mob's attacks mid game is insane.
unarmed_attacks = list()
@@ -42,31 +44,19 @@
nif.nifsofts = nifsofts
else
..()
/datum/species/proc/produceCopy(var/list/traits,var/mob/living/carbon/human/H, var/custom_base)
var/datum/species/S
/datum/species/proc/produceCopy(var/list/traits,var/mob/living/carbon/human/H)
//If species allows custom base, and custom base is set, apply it, otherwise use default.
if(selects_bodytype && custom_base)
S = GLOB.all_species[custom_base]
else
S = GLOB.all_species[src.name]
ASSERT(S)
ASSERT(src)
ASSERT(istype(H))
var/datum/species/new_copy = new S.type()
var/datum/species/new_copy = new src.type()
for(var/i in S.vars) //Thorough copy of species.
if(new_copy.vars[i] != S.vars[i])
//Skipping lists because they may contain more lists, copy those manually.
//Also ignoring type var since it's read-only and will runtime.
if(islist(vars[i]))
continue
new_copy.vars[i] = S.vars[i]
if(selects_bodytype) //If race selects a bodytype, copy needed variables.
copy_variables(new_copy, copy_vars)
for(var/organ in S.has_limbs) //Copy important organ data generated by species.
var/list/organ_data = S.has_limbs[organ]
for(var/organ in has_limbs) //Copy important organ data generated by species.
var/list/organ_data = has_limbs[organ]
new_copy.has_limbs[organ] = organ_data.Copy()
new_copy.traits = traits
//If you had traits, apply them
if(new_copy.traits)
for(var/trait in new_copy.traits)
@@ -85,6 +75,15 @@
return new_copy
/datum/species/proc/copy_variables(var/datum/species/S, var/list/whitelist)
//List of variables to ignore, trying to copy type will runtime.
var/list/blacklist = list("type", "loc", "client", "ckey")
//Makes thorough copy of species datum.
for(var/i in vars)
if(S.vars[i] != vars[i] && !islist(vars[i])) //If vars are same, no point in copying.
if(whitelist && !(i in whitelist) && i in blacklist) //If whitelist is provided, only vars in the list will be copied.
continue
S.vars[i] = vars[i]
/datum/species/get_bodytype()
return base_species
@@ -46,10 +46,14 @@
var/datum/species/real = GLOB.all_species[base_species]
return real.race_key
/datum/species/custom/produceCopy(var/list/traits,var/mob/living/carbon/human/H)
/datum/species/custom/produceCopy(var/list/traits,var/mob/living/carbon/human/H,var/custom_base)
. = ..()
if(selects_bodytype && custom_base)
var/datum/species/S = GLOB.all_species[custom_base]
S.copy_variables(., copy_vars)
H.maxHealth = H.species.total_health
H.hunger_rate = H.species.hunger_factor
return .
// Stub species overrides for shoving trait abilities into