mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-06-23 07:05:13 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
104 lines
3.7 KiB
Plaintext
104 lines
3.7 KiB
Plaintext
/// Lets you graffiti on an object
|
|
/datum/component/defaceable
|
|
/// Icon file from which to draw our overlay
|
|
var/icon
|
|
/// Icon states to draw from our file, optionally use as a list key for TRUE to skip recolouring that icon state
|
|
var/list/icon_states
|
|
/// String description of what you have drawn
|
|
var/drawing_of
|
|
/// What colour have we been drawn with?
|
|
var/ink_colour
|
|
/// Optional callback called when we are drawn on, we pass in the ink colour
|
|
var/datum/callback/on_defaced
|
|
|
|
/datum/component/defaceable/Initialize(icon, list/icon_states, drawing_of, datum/callback/on_defaced)
|
|
if (!isatom(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
src.icon = icon
|
|
src.icon_states = icon_states
|
|
src.drawing_of = drawing_of
|
|
src.on_defaced = on_defaced
|
|
|
|
/datum/component/defaceable/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(on_drawn))
|
|
RegisterSignal(parent, COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM, PROC_REF(on_hovered))
|
|
var/atom/atom_parent = parent
|
|
atom_parent.flags_1 |= HAS_CONTEXTUAL_SCREENTIPS_1
|
|
|
|
/datum/component/defaceable/UnregisterFromParent()
|
|
UnregisterSignal(parent, list(COMSIG_ATOM_ITEM_INTERACTION, COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM, COMSIG_ATOM_EXAMINE, COMSIG_COMPONENT_CLEAN_ACT, COMSIG_ATOM_UPDATE_OVERLAYS))
|
|
var/atom/atom_parent = parent
|
|
atom_parent.update_appearance(UPDATE_OVERLAYS)
|
|
|
|
/datum/component/defaceable/Destroy(force = FALSE)
|
|
on_defaced = null
|
|
return ..()
|
|
|
|
/// Inform people that they can mess us up
|
|
/datum/component/defaceable/proc/on_hovered(atom/source, list/context, obj/item/held_item, mob/user)
|
|
if (HAS_TRAIT(source, TRAIT_DEFACED))
|
|
if (is_type_in_list(held_item, list(/obj/item/reagent_containers/spray, /obj/item/soap, /obj/item/rag)))
|
|
context[SCREENTIP_CONTEXT_LMB] = "Clean"
|
|
else
|
|
if (istype(held_item, /obj/item/pen) || istype(held_item, /obj/item/toy/crayon))
|
|
context[SCREENTIP_CONTEXT_LMB] = "Draw [drawing_of ? drawing_of : "on"]"
|
|
return CONTEXTUAL_SCREENTIP_SET
|
|
|
|
/// See if someone can draw on us
|
|
/datum/component/defaceable/proc/on_drawn(atom/source, mob/living/user, obj/item/tool)
|
|
SIGNAL_HANDLER
|
|
if (user.combat_mode)
|
|
return
|
|
if(istype(tool, /obj/item/toy/crayon))
|
|
var/obj/item/toy/crayon/crayon = tool
|
|
ink_colour = crayon.paint_color
|
|
else if(istype(tool, /obj/item/pen))
|
|
var/obj/item/pen/pen = tool
|
|
ink_colour = pen.colour
|
|
|
|
if (!ink_colour)
|
|
return
|
|
|
|
ADD_TRAIT(parent, TRAIT_DEFACED, ref(src))
|
|
|
|
on_defaced?.Invoke(ink_colour)
|
|
|
|
RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, PROC_REF(on_cleaned))
|
|
|
|
if (drawing_of)
|
|
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examined))
|
|
|
|
if (icon && icon_states)
|
|
RegisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(on_update_overlays))
|
|
source.update_appearance(UPDATE_OVERLAYS)
|
|
|
|
UnregisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION)
|
|
|
|
return ITEM_INTERACT_SUCCESS
|
|
|
|
/// Render our beautiful drawing
|
|
/datum/component/defaceable/proc/on_update_overlays(atom/source, list/overlays)
|
|
SIGNAL_HANDLER
|
|
for (var/state in icon_states)
|
|
var/mutable_appearance/appearance = mutable_appearance(icon, state)
|
|
if (!icon_states[state])
|
|
appearance.color = ink_colour
|
|
overlays += appearance
|
|
|
|
/// Wash it off
|
|
/datum/component/defaceable/proc/on_cleaned(atom/source, clean_types)
|
|
SIGNAL_HANDLER
|
|
if (!(clean_types & (CLEAN_WASH|CLEAN_SCRUB)))
|
|
return
|
|
|
|
REMOVE_TRAIT(parent, TRAIT_DEFACED, ref(src))
|
|
RegisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(on_drawn))
|
|
UnregisterSignal(parent, list(COMSIG_ATOM_EXAMINE, COMSIG_COMPONENT_CLEAN_ACT, COMSIG_ATOM_UPDATE_OVERLAYS))
|
|
source.update_appearance(UPDATE_OVERLAYS)
|
|
|
|
/// See it there
|
|
/datum/component/defaceable/proc/on_examined(atom/source, mob/user, list/examine_list)
|
|
SIGNAL_HANDLER
|
|
examine_list += span_notice("Someone has crudely drawn [drawing_of] on [source.p_them()].")
|