Readability & Abstraction Improvements + A Tweak

As per Tigercat's review, readability has been improved and the method
by which eyeshine is applied has been abstracted a lot more.

As part of that, I have divised a solution for the situation where,
prior to this tweak, if you were a Tajara and had the 'bangs' hairstyle
while also having eyeshine, one of your eyes would render ABOVE your
hair.

Now, despite the eye shine happening on a higher layer, the eye that
would ordinarily be hidden by the hair still is.
How? By cutting the pixels that are overlapped by the hair from the eye
icon during rendering.
This commit is contained in:
KasparoVy
2018-02-09 20:12:31 -05:00
parent 64ced9f6b6
commit 541b4f7275
6 changed files with 52 additions and 13 deletions
+11 -5
View File
@@ -1668,12 +1668,18 @@
G.icon_state = "grabbed1"
G.synch()
/mob/living/carbon/human/proc/eyes_shine() /*Used to check if eyes should shine in the dark. Returns the image of the eyes on the layer where they will appear to shine.
Eyes need to have significantly high darksight to shine unless the mob has the XRAY vision mutation. Eyes will not shine if they are covered in any way.*/
/*Used to check if eyes should shine in the dark. Returns the image of the eyes on the layer where they will appear to shine.
Eyes need to have significantly high darksight to shine unless the mob has the XRAY vision mutation. Eyes will not shine if they are covered in any way.*/
/mob/living/carbon/human/proc/eyes_shine()
var/obj/item/organ/internal/eyes/eyes = get_int_organ(/obj/item/organ/internal/eyes)
var/const/shine_threshold = 6
if(istype(eyes) && ((eyes.get_dark_view() > shine_threshold) || (XRAY in mutations)) && get_location_accessible(src, "eyes"))
return(image(eyes.generate_icon(), layer = LIGHTING_LAYER + 1)) //Referenced cult constructs for shining in the dark. Needs to be above lighting effects such as shading.
if(!istype(eyes))
return FALSE
if(!(eyes.get_dark_view() > EYE_SHINE_THRESHOLD) && !(XRAY in mutations))
return FALSE
if(!get_location_accessible(src, "eyes"))
return FALSE
return TRUE
/mob/living/carbon/human/proc/gut()
set category = "Abilities"
@@ -105,6 +105,7 @@ Please contact me on #coderbus IRC. ~Carn x
/mob/living/carbon/human
var/list/overlays_standing[TOTAL_LAYERS]
var/list/misc_effect_overlays = list() //Overlays that are applied at a custom layer (defined in each image's .layer property) outside of standard overlay application. Updated in update_misc_effects()
var/previous_damage_appearance // store what the body last looked like, so we only have to update it if something changed
var/icon/skeleton
var/list/cached_standing_overlays = list() // List of everything currently in a human's actual overlays
@@ -154,13 +155,16 @@ Please contact me on #coderbus IRC. ~Carn x
I.layer = (-2 - (TOTAL_LAYERS - i)) // Highest layer gets -2, each prior layer is 1 lower
new_overlays += I
update_misc_effects()
if(misc_effect_overlays)
new_overlays += misc_effect_overlays
if(frozen) // Admin freeze overlay
new_overlays += frozen
overlays += (new_overlays - old_overlays)
overlays -= (old_overlays - new_overlays)
cached_standing_overlays = new_overlays
overlays |= eyes_shine() //Only applies eyeshine if the eyes are uncovered and have significantly high darksight or XRAY vision.
update_transform()
@@ -1325,6 +1329,14 @@ var/global/list/damage_icon_parts = list()
if(update_icons) update_icons()
/mob/living/carbon/human/proc/update_misc_effects()
misc_effect_overlays.Cut()
//Begin appending miscellaneous effects.
if(eyes_shine())
var/obj/item/organ/internal/eyes/E = get_int_organ(/obj/item/organ/internal/eyes)
misc_effect_overlays += E.get_eye_shine() //Image layer is specified in get_eye_shine() proc as LIGHTING_LAYER + 1.
/mob/living/carbon/human/proc/force_update_limbs()
for(var/obj/item/organ/external/O in bodyparts)
O.sync_colour_to_human(src)
+17 -6
View File
@@ -305,12 +305,23 @@
/obj/item/organ/internal/eyes/proc/update_colour()
dna.write_eyes_attributes(src)
/obj/item/organ/internal/eyes/proc/generate_icon(var/mob/living/carbon/human/H)
var/mob/living/carbon/human/G = H ? H : owner
if(istype(G))
var/icon/eyes_icon = new/icon('icons/mob/human_face.dmi', G.species.eyes)
eyes_icon.Blend(eye_colour, ICON_ADD)
return(eyes_icon)
/obj/item/organ/internal/eyes/proc/generate_icon(var/mob/living/carbon/human/HA)
var/mob/living/carbon/human/H = HA
if(!istype(H))
H = owner
var/icon/eyes_icon = new /icon('icons/mob/human_face.dmi', H.species.eyes)
eyes_icon.Blend(eye_colour, ICON_ADD)
return eyes_icon
/obj/item/organ/internal/eyes/proc/get_eye_shine(var/mob/living/carbon/human/HA) //Referenced cult constructs for shining in the dark. Needs to be above lighting effects such as shading.
var/mob/living/carbon/human/H = HA
if(!istype(H))
H = owner
var/obj/item/organ/external/head/head_organ = H.get_organ("head")
var/datum/sprite_accessory/hair/hair_style = hair_styles_full_list[head_organ.h_style]
var/icon/hair = new /icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_s")
return image(get_icon_difference(generate_icon(H), hair), layer = LIGHTING_LAYER + 1) //Cut the hair's pixels from the eyes icon so eyes covered by bangs stay hidden even while on a higher layer.
/obj/item/organ/internal/eyes/proc/get_colourmatrix() //Returns a special colour matrix if the eyes are organic and the mob is colourblind, otherwise it uses the current one.
if(!robotic && owner.disabilities & COLOURBLIND)