mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-01-01 13:12:23 +00:00
* Globals work
* Double access works
* All other things
* Revert "All other things"
This reverts commit 6574442eb6.
* More changes that compile and work
* IT WORKS AAAAAA
* Changes even more .len to length()
* Apply suggestions from code review
* Update code/datums/mind.dm
* Update code/__HELPERS/sorts/InsertSort.dm
Co-authored-by: Deniz <66401072+Oyu07@users.noreply.github.com>
* Update code/__HELPERS/sanitize_values.dm
Co-authored-by: Deniz <66401072+Oyu07@users.noreply.github.com>
---------
Co-authored-by: FunnyMan3595 (Charlie Nolan) <funnyman@google.com>
Co-authored-by: Deniz <66401072+Oyu07@users.noreply.github.com>
146 lines
4.0 KiB
Plaintext
146 lines
4.0 KiB
Plaintext
/*
|
|
Alternate Appearances! By RemieRichards
|
|
A framework for replacing an atom (and it's overlays) with an override = 1 image, that's less shit!
|
|
Example uses:
|
|
* hallucinating all mobs looking like skeletons
|
|
* people wearing cardborg suits appearing as Standard Cyborgs to the other Silicons
|
|
* !!use your imagination!!
|
|
|
|
*/
|
|
|
|
|
|
//This datum is built on-the-fly by some of the procs below
|
|
//no need to instantiate it
|
|
/datum/alternate_appearance
|
|
var/key = ""
|
|
var/image/img
|
|
var/list/viewers = list()
|
|
var/atom/owner = null
|
|
|
|
|
|
/*
|
|
Displays the alternate_appearance
|
|
displayTo - a list of MOBS to show this appearance to
|
|
*/
|
|
/datum/alternate_appearance/proc/display_to(list/displayTo)
|
|
if(!displayTo || !length(displayTo))
|
|
return
|
|
for(var/m in displayTo)
|
|
var/mob/M = m
|
|
if(!M.viewing_alternate_appearances)
|
|
M.viewing_alternate_appearances = list()
|
|
viewers |= M
|
|
M.viewing_alternate_appearances |= src
|
|
if(M.client)
|
|
M.client.images |= img
|
|
|
|
/*
|
|
Hides the alternate_appearance
|
|
hideFrom - optional list of MOBS to hide it from the list's mobs specifically
|
|
*/
|
|
/datum/alternate_appearance/proc/hide(list/hideFrom)
|
|
var/list/hiding = viewers
|
|
if(hideFrom)
|
|
hiding = hideFrom
|
|
|
|
for(var/m in hiding)
|
|
var/mob/M = m
|
|
if(M.client)
|
|
M.client.images -= img
|
|
if(M.viewing_alternate_appearances && length(M.viewing_alternate_appearances))
|
|
M.viewing_alternate_appearances -= src
|
|
viewers -= M
|
|
|
|
|
|
/*
|
|
Removes the alternate_appearance from its owner's alternate_appearances list, hiding it also
|
|
*/
|
|
/datum/alternate_appearance/proc/remove()
|
|
hide()
|
|
if(owner && owner.alternate_appearances)
|
|
owner.alternate_appearances -= key
|
|
|
|
|
|
/datum/alternate_appearance/Destroy()
|
|
remove()
|
|
return ..()
|
|
|
|
/*
|
|
Builds an alternate_appearance datum for the supplied args, optionally displaying it straight away
|
|
key - the key to the assoc list of key = /datum/alternate_appearances
|
|
img - the image file to be the "alternate appearance"
|
|
WORKS BEST IF:
|
|
* it has override = 1 set
|
|
* the image's loc is the atom that will use the appearance (otherwise... it's not exactly an alt appearance of this atom is it?)
|
|
displayTo - optional list of MOBS to display to immediately
|
|
|
|
Example:
|
|
var/image/I = image(icon = 'disguise.dmi', icon_state = "disguise", loc = src)
|
|
I.override = 1
|
|
add_alt_appearance("super_secret_disguise", I, players)
|
|
|
|
*/
|
|
/atom/proc/add_alt_appearance(key, img, list/displayTo = list())
|
|
if(!key || !img)
|
|
return
|
|
if(!alternate_appearances)
|
|
alternate_appearances = list()
|
|
|
|
var/datum/alternate_appearance/AA = new()
|
|
AA.img = img
|
|
AA.key = key
|
|
AA.owner = src
|
|
|
|
if(alternate_appearances[key])
|
|
qdel(alternate_appearances[key])
|
|
alternate_appearances[key] = AA
|
|
if(displayTo && length(displayTo))
|
|
display_alt_appearance(key, displayTo)
|
|
|
|
|
|
//////////////
|
|
// WRAPPERS //
|
|
//////////////
|
|
|
|
/*
|
|
Removes an alternate_appearance from src's alternate_appearances list
|
|
Wrapper for: alternate_appearance/remove()
|
|
key - the key to the assoc list of key = /datum/alternate_appearance
|
|
*/
|
|
/atom/proc/remove_alt_appearance(key)
|
|
if(alternate_appearances)
|
|
if(alternate_appearances[key])
|
|
qdel(alternate_appearances[key])
|
|
|
|
|
|
/*
|
|
Displays an alternate appearance from src's alternate_appearances list
|
|
Wrapper for: alternate_appearance/display_to()
|
|
key - the key to the assoc list of key = /datum/alternate_appearance
|
|
displayTo - a list of MOBS to show this appearance to
|
|
*/
|
|
/atom/proc/display_alt_appearance(key, list/displayTo)
|
|
if(!alternate_appearances || !key)
|
|
return
|
|
var/datum/alternate_appearance/AA = alternate_appearances[key]
|
|
if(!AA || !AA.img)
|
|
return
|
|
AA.display_to(displayTo)
|
|
|
|
|
|
/*
|
|
Hides an alternate appearance from src's alternate_appearances list
|
|
Wrapper for: alternate_appearance/hide()
|
|
key - the key to the assoc list of key = /datum/alternate_appearance
|
|
hideFrom - optional list of MOBS to hide it from the list's mobs specifically
|
|
*/
|
|
/atom/proc/hide_alt_appearance(key, list/hideFrom)
|
|
if(!alternate_appearances || !key)
|
|
return
|
|
var/datum/alternate_appearance/AA = alternate_appearances[key]
|
|
if(!AA)
|
|
return
|
|
AA.hide(hideFrom)
|
|
|
|
|