Skip to content

Commit

Permalink
Overhaul how sechuds' and prodocs' icon adding/removing works. (#5359)
Browse files Browse the repository at this point in the history
* Overhaul how sechuds' and prodocs' icon adding/removing works.

* Apply suggestions from code review - removed unnecessary returns

Co-authored-by: ZeWaka <zewakagamer@gmail.com>

Co-authored-by: ZeWaka <zewakagamer@gmail.com>
  • Loading branch information
Gerhazo and ZeWaka committed Jul 10, 2021
1 parent 7ef653c commit 1acfd34
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 259 deletions.
3 changes: 3 additions & 0 deletions code/datums/client_image_group.dm
@@ -1,3 +1,6 @@
#define CLIENT_IMAGE_GROUP_ARREST_ICONS "arrest_icons"
#define CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS "health_mon_icons"

var/global/list/datum/client_image_group/client_image_groups

/datum/client_image_group
Expand Down
2 changes: 0 additions & 2 deletions code/global.dm
Expand Up @@ -60,8 +60,6 @@ var/global
force_random_names = 0 // for the pre-roundstart thing
force_random_looks = 0 // same as above

list/health_mon_icons = new/list()
list/arrestIconsAll = new/list()
list/default_mob_static_icons = list() // new mobs grab copies of these for themselves, or if their chosen type doesn't exist in the list, they generate their own and add it
list/mob_static_icons = list() // these are the images that are actually seen by ghostdrones instead of whatever mob
list/orbicons = list()
Expand Down
25 changes: 11 additions & 14 deletions code/mob/dead/observer.dm
Expand Up @@ -394,32 +394,27 @@
/mob/dead/observer/verb/show_health()
set category = "Ghost"
set name = "Toggle Health"
client.images.Remove(health_mon_icons)
if (!health_shown)
health_shown = 1
if(client?.images)
for(var/image/I in health_mon_icons)
if (I && src && I.loc != src.loc)
client.images.Add(I)
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).add_mob(src)
boutput(src, "Health status toggled on.")
else
health_shown = 0
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).remove_mob(src)
boutput(src, "Health status toggled off.")

/mob/dead/observer/verb/show_arrest()
set category = "Ghost"
set name = "Toggle Arrest Status"
if (!arrest_shown)
arrest_shown = 1
if(client?.images)
for(var/image/I in arrestIconsAll)
if(I && src && I.loc != src.loc)
client.images.Add(I)
get_image_group(CLIENT_IMAGE_GROUP_ARREST_ICONS).add_mob(src)
boutput(src, "Arrest status toggled on.")
else
arrest_shown = 0
client.images.Remove(arrestIconsAll)
get_image_group(CLIENT_IMAGE_GROUP_ARREST_ICONS).remove_mob(src)
boutput(src, "Arrest status toggled off.")


/mob/dead/observer/verb/ai_laws()
set name = "AI Laws"
set desc = "Displays the current AI laws. You must have DNR on to use this."
Expand All @@ -441,11 +436,13 @@
..()

if(last_client)
health_shown = 0
last_client.images.Remove(health_mon_icons)
if(health_shown)
health_shown = 0
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).remove_mob(src)
if(arrest_shown)
arrest_shown = 0
last_client.images.Remove(arrestIconsAll)
get_image_group(CLIENT_IMAGE_GROUP_ARREST_ICONS).remove_mob(src)


if(!src.key && delete_on_logout)
//qdel(src)
Expand Down
14 changes: 6 additions & 8 deletions code/mob/living/carbon/human.dm
Expand Up @@ -196,13 +196,13 @@
#endif

health_mon = image('icons/effects/healthgoggles.dmi',src,"100",10)
health_mon_icons.Add(health_mon)
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).add_image(health_mon)

health_implant = image('icons/effects/healthgoggles.dmi',src,"100",10)
health_mon_icons.Add(health_implant)
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).add_image(health_implant)

arrestIcon = image('icons/effects/sechud.dmi',src,null,10)
arrestIconsAll.Add(arrestIcon)
get_image_group(CLIENT_IMAGE_GROUP_ARREST_ICONS).add_image(arrestIcon)

src.organHolder = new(src)

Expand Down Expand Up @@ -511,17 +511,15 @@
imp.dispose()
src.implant = null

for(var/client/C)
C.images -= list(health_mon, health_implant, arrestIcon)
if(health_mon)
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).remove_image(health_mon)
health_mon.dispose()
health_mon_icons -= health_mon
if(health_implant)
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).remove_image(health_implant)
health_implant.dispose()
health_mon_icons -= health_implant
if(arrestIcon)
get_image_group(CLIENT_IMAGE_GROUP_ARREST_ICONS).remove_image(arrestIcon)
arrestIcon.dispose()
arrestIconsAll -= arrestIcon

src.chest_item = null

Expand Down
27 changes: 0 additions & 27 deletions code/mob/living/life/hud.dm
Expand Up @@ -61,33 +61,6 @@
human_owner.vision.animate_color_mod(rgb(rand(80, 255), rand(80, 255), rand(80, 255)), 15)
else
human_owner.vision.set_color_mod(rgb(color_mod_r, color_mod_g, color_mod_b))

if (istype(human_owner.glasses, /obj/item/clothing/glasses/healthgoggles))
var/obj/item/clothing/glasses/healthgoggles/G = human_owner.glasses
if (human_owner.client && !(G.assigned || G.assigned == human_owner.client))
G.assigned = human_owner.client
processing_items |= G
//G.updateIcons()

if (istype(human_owner.head, /obj/item/clothing/head/helmet/space/syndicate/specialist/medic))
var/obj/item/clothing/head/helmet/space/syndicate/specialist/medic/M = human_owner.head
if (human_owner.client && !(M.assigned || M.assigned == human_owner.client))
M.assigned = human_owner.client
processing_items |= M
//G.updateIcons()

else if (human_owner.organHolder && istype(human_owner.organHolder.left_eye, /obj/item/organ/eye/cyber/prodoc))
var/obj/item/organ/eye/cyber/prodoc/G = human_owner.organHolder.left_eye
if (human_owner.client && !(G.assigned || G.assigned == human_owner.client))
G.assigned = human_owner.client
processing_items |= G
//G.updateIcons()
else if (human_owner.organHolder && istype(human_owner.organHolder.right_eye, /obj/item/organ/eye/cyber/prodoc))
var/obj/item/organ/eye/cyber/prodoc/G = human_owner.organHolder.right_eye
if (human_owner.client && !(G.assigned || G.assigned == human_owner.client))
G.assigned = human_owner.client
processing_items |= G
//G.updateIcons()
else
if (owner.druggy)
owner.vision.animate_color_mod(rgb(rand(0, 255), rand(0, 255), rand(0, 255)), 15)
Expand Down
29 changes: 2 additions & 27 deletions code/modules/robotics/robot/upgrade/prodoc_scanner.dm
Expand Up @@ -4,37 +4,12 @@
icon_state = "up-prodoc"
drainrate = 5

var/client/assigned = null

/obj/item/roboupgrade/healthgoggles/process()
if (assigned)
src.assigned.images.Remove(health_mon_icons)
addIcons()

if (src.loc != assigned.mob)
src.assigned.images.Remove(health_mon_icons)
src.assigned = null

/obj/item/roboupgrade/healthgoggles/proc/addIcons()
if (src.assigned)
for (var/image/I in health_mon_icons)
if (!I || !I.loc || !src)
continue
if (I.loc.invisibility && I.loc != src.loc)
continue
src.assigned.images.Add(I)

/obj/item/roboupgrade/healthgoggles/upgrade_activate(var/mob/living/silicon/robot/user as mob)
if (..())
return
src.assigned = user.client
processing_items |= src
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).add_mob(user)

/obj/item/roboupgrade/healthgoggles/upgrade_deactivate(var/mob/living/silicon/robot/user as mob)
if (..())
return
if (src.assigned)
src.assigned.images.Remove(health_mon_icons)
src.assigned = null
processing_items.Remove(src)
return
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).remove_mob(user)
29 changes: 2 additions & 27 deletions code/modules/robotics/robot/upgrade/sechud_scanner.dm
Expand Up @@ -4,37 +4,12 @@
icon_state = "up-sechud"
drainrate = 5

var/client/assigned = null

process()
if (assigned)
src.assigned.images.Remove(arrestIconsAll)
addIcons()

if (src.loc != assigned.mob)
src.assigned.images.Remove(arrestIconsAll)
src.assigned = null

proc/addIcons()
if (src.assigned)
for (var/image/I in arrestIconsAll)
if (!I || !I.loc || !src)
continue
if (I.loc.invisibility && I.loc != src.loc)
continue
src.assigned.images.Add(I)

upgrade_activate(var/mob/living/silicon/robot/user as mob)
if (..())
return
src.assigned = user.client
processing_items |= src
get_image_group(CLIENT_IMAGE_GROUP_ARREST_ICONS).add_mob(user)

upgrade_deactivate(var/mob/living/silicon/robot/user as mob)
if (..())
return
if (src.assigned)
src.assigned.images.Remove(arrestIconsAll)
src.assigned = null
processing_items.Remove(src)
return
get_image_group(CLIENT_IMAGE_GROUP_ARREST_ICONS).remove_mob(user)
63 changes: 6 additions & 57 deletions code/obj/item/clothing/glasses.dm
Expand Up @@ -163,7 +163,6 @@
name = "\improper Security HUD"
desc = "Sunglasses with a high tech sheen."
icon_state = "sec"
var/client/assigned = null
color_r = 0.95 // darken a little, kinda red
color_g = 0.9
color_b = 0.9
Expand All @@ -178,40 +177,16 @@
H.bioHolder.AddEffect("bad_eyesight")
SPAWN_DBG(10 SECONDS)
H.bioHolder.RemoveEffect("bad_eyesight")
return

process()
if (assigned)
assigned.images.Remove(arrestIconsAll)
addIcons()
if (loc != assigned.mob)
assigned.images.Remove(arrestIconsAll)
assigned = null

proc/addIcons()
if (assigned)
for (var/image/I in arrestIconsAll)
if (!I || !I.loc || !src)
continue
if (I.loc.invisibility && I.loc != src.loc)
continue
else
assigned.images.Add(I)

equipped(var/mob/user, var/slot)
..()
if (slot == SLOT_GLASSES)
assigned = user.client
processing_items |= src
return
get_image_group(CLIENT_IMAGE_GROUP_ARREST_ICONS).add_mob(user)

unequipped(var/mob/user)
if(src.equipped_in_slot == SLOT_GLASSES)
get_image_group(CLIENT_IMAGE_GROUP_ARREST_ICONS).remove_mob(user)
..()
if (assigned)
assigned.images.Remove(arrestIconsAll)
assigned = null
processing_items.Remove(src)
return

/obj/item/clothing/glasses/sunglasses/sechud/superhero
name = "superhero mask"
Expand Down Expand Up @@ -424,7 +399,6 @@
desc = "Fitted with an advanced miniature sensor array that allows the user to quickly determine the physical condition of others."
icon_state = "prodocs"
uses_multiple_icon_states = 1
var/client/assigned = null
var/scan_upgrade = 0
var/health_scan = 0
mats = 8
Expand All @@ -436,40 +410,15 @@
..()
setProperty("disorient_resist_eye", 15)

//proc/updateIcons() //I wouldve liked to avoid this but i dont want to put this inside the mobs life proc as that would be more code.
process()
if (assigned)
assigned.images.Remove(health_mon_icons)
addIcons()

if (loc != assigned.mob)
assigned.images.Remove(health_mon_icons)
assigned = null

proc/addIcons()
if (assigned)
for (var/image/I in health_mon_icons)
if (!I || !I.loc || !src)
continue
if (I.loc.invisibility && I.loc != src.loc)
continue
else
assigned.images.Add(I)

equipped(var/mob/user, var/slot)
..()
if (slot == SLOT_GLASSES)
assigned = user.client
processing_items |= src
return
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).add_mob(user)

unequipped(var/mob/user)
if(src.equipped_in_slot == SLOT_GLASSES)
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).remove_mob(user)
..()
if (assigned)
assigned.images.Remove(health_mon_icons)
assigned = null
processing_items.Remove(src)
return

attackby(obj/item/W as obj, mob/user as mob)
if (istype(W, /obj/item/device/analyzer/healthanalyzer_upgrade))
Expand Down
38 changes: 3 additions & 35 deletions code/obj/item/clothing/helmets.dm
Expand Up @@ -317,51 +317,20 @@
item_state = "syndie_specialist"
permeability_coefficient = 0.01
c_flags = SPACEWEAR | COVERSEYES | COVERSMOUTH | BLOCKCHOKE
var/client/assigned = null

setupProperties()
..()
setProperty("viralprot", 50)

process()
if (assigned)
assigned.images.Remove(health_mon_icons)
src.addIcons()

if (loc != assigned.mob)
assigned.images.Remove(health_mon_icons)
assigned = null

//sleep(2 SECONDS)
else
processing_items.Remove(src)

proc/addIcons()
if (assigned)
for (var/image/I in health_mon_icons)
if (!I || !I.loc || !src)
continue
if (I.loc.invisibility && I.loc != src.loc)
continue
else
assigned.images.Add(I)

equipped(var/mob/user, var/slot)
..()
if (slot == SLOT_HEAD)
assigned = user.client
SPAWN_DBG(-1)
//updateIcons()
processing_items |= src
return
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).add_mob(user)

unequipped(var/mob/user)
if(src.equipped_in_slot == SLOT_HEAD)
get_image_group(CLIENT_IMAGE_GROUP_HEALTH_MON_ICONS).remove_mob(user)
..()
if (assigned)
assigned.images.Remove(health_mon_icons)
assigned = null
processing_items.Remove(src)
return

sniper
name = "specialist combat cover"
Expand Down Expand Up @@ -865,4 +834,3 @@
setProperty("heatprot", 15)
setProperty("disorient_resist_eye", 8)
setProperty("disorient_resist_ear", 8)

0 comments on commit 1acfd34

Please sign in to comment.