Files
Bubberstation/code/datums/elements/dryable.dm
SmArtKar a27949d5f5 Advanced Color Shifting: Spraypaint Edition (#88201)
## About The Pull Request

"If GAGS is such a good system, why isn't there GAGS 2?" - Sun Tzu

GAGS is very neat but it has one glaring issue: it needs sprites to be
greyscaled in advance to be used. On the other hand we have color
matrices, but they're hard to use and even harder to get good results
from. The logical solution grew out of a discord argument about colors
this morning after @LemonInTheDark decided to toy around with HSL
matrices using filters on live servers.

This PR implements Color Transition Filters as an additional option for
atom colors - passing a transition filter matrix into
``add_atom_colour`` will "recolor" the atom into the passed color by
using an HSL filter (since color only supports RGB values and matrices).
Normal color matrices are now also supported in atom colors, in case
anyone needs to use them there. ``color_transition_filter`` has 2 modes:
``SATURATION_MULTIPLY`` which only changes the hue and shifts saturation
of the original icon, and ``SATURATION_OVERRIDE`` which changes
saturation and light values to more correctly fit the passed color.
Multiply mode does a far better job at recoloring clothing or objects
with obvious highlights, but fails to color pale or white objects, while
Override mode is closer to what we have right now (just doesn't produce
rancid blobs of color nearly as much)

Here are some examples of colored clothes, mechs, items and tiles using
the new system.

Green RD? Sure.

![image](https://github.com/user-attachments/assets/6d79cac3-15a5-4850-abae-19219e1d4bdb)

Atmos MODsuit colored with a speed potion

![4cTKpeu](https://github.com/user-attachments/assets/9106e74c-8d60-489a-9ef7-4d154ddbbdf9)

Why override mode exists in the first place

![dreamseeker_fAKn811LXT](https://github.com/user-attachments/assets/3d3bea8c-5e27-4390-a924-0c243265fa6a)

Aftermath of a colorful reagent grenade.

![image](https://github.com/user-attachments/assets/ba4c78c5-cba5-42da-ac4d-7861bb329b68)

As you can see, the colors are far brighter and significantly less
acidic, since they're no longer just used as multipliers for existing
colors but instead shift the palette of the sprite towards themselves.

In order to bypass the main downside of "default" Multiply mode,
spraycans have received a new right click function "coat with paint",
which will color the item using the Override mode. Left Click mode lost
its coloring restrictions (RMB still has them), and color
sampling/prosthetic recoloring has been moved to Ctrl Click instead.
Here's the full list of all systems/items that now use color transition
filters:
 * Drying items
 * Deep frying items
 * Slime blueprints/potions/coloring crossbreeds
 * Colorful reagent
 * Spraycans
 * Paint buckets

## Why It's Good For The Game

Our coloring system is ***really*** bad, to the point where we're
preventing players from using any dark colors because item icons become
unintelligible when colored into them.

## Changelog
🆑 SmArtKar, LemonInTheDark
add: Changed how spraycans color items - "old" mode is still availible
via right click.
refactor: Refactored how some items and effects color things so that
they look prettier.
/🆑
2024-12-13 00:12:14 -08:00

59 lines
2.3 KiB
Plaintext

// If an item has this element, it can be dried on a drying rack.
/datum/element/dryable
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// The type of atom that is spawned by this element on drying.
var/dry_result
/datum/element/dryable/Attach(datum/target, atom/dry_result)
. = ..()
if(!isatom(target))
return ELEMENT_INCOMPATIBLE
src.dry_result = dry_result
RegisterSignal(target, COMSIG_ITEM_DRIED, PROC_REF(finish_drying))
ADD_TRAIT(target, TRAIT_DRYABLE, ELEMENT_TRAIT(type))
/datum/element/dryable/Detach(datum/target)
. = ..()
UnregisterSignal(target, COMSIG_FOOD_CONSUMED)
REMOVE_TRAIT(target, TRAIT_DRYABLE, ELEMENT_TRAIT(type))
/datum/element/dryable/proc/finish_drying(atom/source, datum/weakref/drying_user)
SIGNAL_HANDLER
var/static/list/dried_color
if (isnull(dried_color))
dried_color = color_transition_filter(COLOR_DRIED_TAN)
var/atom/dried_atom = source
if(dry_result == dried_atom.type)//if the dried type is the same as our currrent state, don't bother creating a whole new item, just re-color it.
var/atom/movable/resulting_atom = dried_atom
resulting_atom.add_atom_colour(dried_color, FIXED_COLOUR_PRIORITY)
apply_dried_status(resulting_atom, drying_user)
return
else if(isstack(source)) //Check if its a sheet
var/obj/item/stack/itemstack = dried_atom
for(var/i in 1 to itemstack.amount)
var/atom/movable/resulting_atom = new dry_result(source.loc)
apply_dried_status(resulting_atom, drying_user)
qdel(source)
return
else if(istype(source, /obj/item/food) && ispath(dry_result, /obj/item/food))
var/obj/item/food/source_food = source
var/obj/item/food/resulting_food = new dry_result(source.loc)
resulting_food.reagents.clear_reagents()
source_food.reagents.trans_to(resulting_food, source_food.reagents.total_volume)
apply_dried_status(resulting_food, drying_user)
qdel(source)
return
else
var/atom/movable/resulting_atom = new dry_result(source.loc)
apply_dried_status(resulting_atom, drying_user)
qdel(source)
/datum/element/dryable/proc/apply_dried_status(atom/target, datum/weakref/drying_user)
ADD_TRAIT(target, TRAIT_DRIED, ELEMENT_TRAIT(type))
var/datum/mind/user_mind = drying_user?.resolve()
if(drying_user && istype(target, /obj/item/food))
ADD_TRAIT(target, TRAIT_FOOD_CHEF_MADE, REF(user_mind))