mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-25 16:45:42 +00:00
This is just a revitalization of #80275. ## About The Pull Request On the tin, basically demotes everything related to setting up and storing these bulky lists generated from reading `/datum/sprite_accessory` subtypes from living in a global space that will instead be in a compartmentalized subsystem for accesses. Also a lot of code modernization and micro-improvements (unquantifiable) ## Why It's Good For The Game Same exact expected results, just accessed in a different way.  There's a few reasons why I want this to happen. * The `GLOB` space is too clogged. There are at least a thousand variables on `GLOB`, and it's extremely painful to access stuff on production/local through view variables when you're debugging stuff like this. It's also painful when there is stuff that _should_ live on `GLOB` that you might want to see in VV/Debugger but are forced to either have to scroll a mile to find what you want or wait a long while for it to load. The less bulky lists we have of stored initialized datums, the better. * `make_datum_reference_lists()` is a consequence of wack stuff like this where we're reliant on certain things being initialized in the `GLOB` portion of world initialization _before_ subsystems/static variables load - most of these datum lists in the aforementioned proc doesn't _really_ need to be ready to go before `world.New()` for example. We'll sadly have to abuse `PreInit()` for now, but it really is something that has to be ready to go due the critical dependence that stuff like Preferences has on it. * We don't have to have the procs live in a global namespace either. Instead of passing in `GLOB.XList` or `DSstorage.XList` every single time, we can instead just move the proc setup on the subsystem and use `XList` in a more native fashion. * It's easier to find what you need. To me, it's a lot nicer to ctrl+click the DS and go to the variables to find something I'm looking for instead of having to scavenge around for any footprint/trace of the global I want to look for. This is more trivial than the other two, but that's something I like to think about when I go to bed. I also had to refactor a bit of the code to accommodate the limitations of the new DS system, but it should be a lot cleaner anyways. ## Changelog Not relevant --- Also nothing should have broken but it's a good thing we have screenshot unit tests to prove me wrong.
51 lines
1.9 KiB
Plaintext
51 lines
1.9 KiB
Plaintext
/obj/item/dyespray
|
|
name = "hair dye spray"
|
|
desc = "A spray to dye your hair any gradients you'd like."
|
|
w_class = WEIGHT_CLASS_TINY
|
|
icon = 'icons/obj/cosmetic.dmi'
|
|
icon_state = "dyespray"
|
|
|
|
/obj/item/dyespray/attack_self(mob/user)
|
|
dye(user, user)
|
|
|
|
/obj/item/dyespray/pre_attack(atom/target, mob/living/user, params)
|
|
dye(target, user)
|
|
return ..()
|
|
|
|
/**
|
|
* Applies a gradient and a gradient color to a mob.
|
|
*
|
|
* Arguments:
|
|
* * target - The mob who we will apply the gradient and gradient color to.
|
|
*/
|
|
|
|
/obj/item/dyespray/proc/dye(mob/target, mob/user)
|
|
if(!ishuman(target))
|
|
return
|
|
var/mob/living/carbon/human/human_target = target
|
|
var/beard_or_hair = tgui_alert(user, "What do you want to dye?", "Character Preference", list("Hair", "Facial Hair"))
|
|
if(!beard_or_hair || !user.can_perform_action(src, NEED_DEXTERITY))
|
|
return
|
|
|
|
var/list/choices = beard_or_hair == "Hair" ? SSaccessories.hair_gradients_list : SSaccessories.facial_hair_gradients_list
|
|
var/new_grad_style = tgui_input_list(user, "Choose a color pattern", "Character Preference", choices)
|
|
if(isnull(new_grad_style))
|
|
return
|
|
if(!user.can_perform_action(src, NEED_DEXTERITY))
|
|
return
|
|
|
|
var/new_grad_color = input(user, "Choose a secondary hair color:", "Character Preference",human_target.grad_color) as color|null
|
|
if(!new_grad_color || !user.can_perform_action(src, NEED_DEXTERITY) || !user.CanReach(target))
|
|
return
|
|
|
|
to_chat(user, span_notice("You start applying the hair dye..."))
|
|
if(!do_after(user, 3 SECONDS, target))
|
|
return
|
|
if(beard_or_hair == "Hair")
|
|
human_target.set_hair_gradient_style(new_grad_style, update = FALSE)
|
|
human_target.set_hair_gradient_color(new_grad_color, update = TRUE)
|
|
else
|
|
human_target.set_facial_hair_gradient_style(new_grad_style, update = FALSE)
|
|
human_target.set_facial_hair_gradient_color(new_grad_color, update = TRUE)
|
|
playsound(src, 'sound/effects/spray.ogg', 10, vary = TRUE)
|