mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 12:07:27 +01:00
elementize pet collars (#29209)
This commit is contained in:
@@ -313,8 +313,11 @@
|
||||
|
||||
var/list/items = list()
|
||||
|
||||
for(var/strippable_key in strippable.items)
|
||||
var/datum/strippable_item/item_data = strippable.items[strippable_key]
|
||||
var/list/unfiltered_items = strippable.items.Copy()
|
||||
SEND_SIGNAL(owner, COMSIG_STRIPPABLE_REQUEST_ITEMS, unfiltered_items)
|
||||
|
||||
for(var/strippable_key in unfiltered_items)
|
||||
var/datum/strippable_item/item_data = unfiltered_items[strippable_key]
|
||||
|
||||
if(!item_data.should_show(owner, user))
|
||||
continue
|
||||
@@ -389,11 +392,14 @@
|
||||
if(!isliving(ui.user) || !HAS_TRAIT(user, TRAIT_CAN_STRIP))
|
||||
return
|
||||
|
||||
var/list/unfiltered_items = strippable.items.Copy()
|
||||
SEND_SIGNAL(owner, COMSIG_STRIPPABLE_REQUEST_ITEMS, unfiltered_items)
|
||||
|
||||
. = TRUE
|
||||
switch(action)
|
||||
if("use")
|
||||
var/key = params["key"]
|
||||
var/datum/strippable_item/strippable_item = strippable.items[key]
|
||||
var/datum/strippable_item/strippable_item = unfiltered_items[key]
|
||||
|
||||
if(isnull(strippable_item))
|
||||
return
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
/datum/element/wears_collar
|
||||
element_flags = ELEMENT_BESPOKE
|
||||
argument_hash_start_idx = 2
|
||||
///our icon's pathfile
|
||||
var/collar_icon
|
||||
///our collar's icon state
|
||||
var/collar_icon_state
|
||||
///iconstate of our collar while resting
|
||||
var/collar_resting_icon_state
|
||||
|
||||
var/datum/strippable_item/pet_collar/pet_collar
|
||||
|
||||
/datum/element/wears_collar/Attach(datum/target, collar_icon_ = 'icons/mob/pets.dmi', collar_icon_state_, collar_resting_icon_state_ = FALSE)
|
||||
. = ..()
|
||||
|
||||
if(!isliving(target))
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
|
||||
collar_icon = collar_icon_
|
||||
collar_icon_state = collar_icon_state_
|
||||
collar_resting_icon_state = collar_resting_icon_state_
|
||||
pet_collar = new
|
||||
|
||||
RegisterSignal(target, COMSIG_ATTACK_BY, PROC_REF(attach_collar))
|
||||
RegisterSignal(target, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(on_overlays_updated))
|
||||
RegisterSignal(target, COMSIG_ATOM_EXITED, PROC_REF(on_content_exit))
|
||||
RegisterSignal(target, COMSIG_ATOM_ENTERED, PROC_REF(on_content_enter))
|
||||
RegisterSignal(target, COMSIG_LIVING_RESTING, PROC_REF(on_rest))
|
||||
RegisterSignal(target, COMSIG_MOB_STATCHANGE, PROC_REF(on_stat_change))
|
||||
RegisterSignal(target, COMSIG_STRIPPABLE_REQUEST_ITEMS, PROC_REF(on_strippable_request_items))
|
||||
|
||||
/datum/element/wears_collar/Detach(datum/target)
|
||||
. = ..()
|
||||
UnregisterSignal(target, list(
|
||||
COMSIG_ATTACK_BY,
|
||||
COMSIG_ATOM_UPDATE_OVERLAYS,
|
||||
COMSIG_ATOM_EXITED,
|
||||
COMSIG_ATOM_ENTERED,
|
||||
COMSIG_LIVING_RESTING,
|
||||
COMSIG_MOB_STATCHANGE,
|
||||
COMSIG_STRIPPABLE_REQUEST_ITEMS,
|
||||
))
|
||||
|
||||
/datum/element/wears_collar/proc/on_strippable_request_items(datum/source, list/items)
|
||||
SIGNAL_HANDLER // COMSIG_STRIPPABLE_REQUEST_ITEMS
|
||||
items[STRIPPABLE_ITEM_PET_COLLAR] = pet_collar
|
||||
|
||||
/datum/element/wears_collar/proc/on_stat_change(mob/living/source)
|
||||
SIGNAL_HANDLER // COMSIG_MOB_STATCHANGE
|
||||
|
||||
if(collar_icon_state)
|
||||
source.update_icon(UPDATE_OVERLAYS)
|
||||
|
||||
/datum/element/wears_collar/proc/on_content_exit(mob/living/source, atom/moved)
|
||||
SIGNAL_HANDLER // COMSIG_ATOM_EXITED
|
||||
|
||||
var/obj/item/petcollar/collar = moved
|
||||
if(!istype(moved))
|
||||
return
|
||||
|
||||
if(collar.tagname)
|
||||
source.name = collar.original_name
|
||||
source.real_name = collar.original_real_name
|
||||
|
||||
collar.original_name = null
|
||||
collar.original_real_name = null
|
||||
|
||||
if(collar_icon_state)
|
||||
source.update_appearance()
|
||||
|
||||
/datum/element/wears_collar/proc/on_content_enter(mob/living/source, obj/item/petcollar/new_collar)
|
||||
SIGNAL_HANDLER // COMSIG_ATOM_ENTERED
|
||||
|
||||
if(!istype(new_collar))
|
||||
return
|
||||
|
||||
if(new_collar.tagname)
|
||||
new_collar.original_name = source.name
|
||||
new_collar.original_real_name = source.real_name
|
||||
source.name = new_collar.tagname
|
||||
source.real_name = new_collar.tagname
|
||||
|
||||
if(collar_icon_state)
|
||||
source.update_appearance()
|
||||
|
||||
/datum/element/wears_collar/proc/attach_collar(atom/source, atom/movable/attacking_item, mob/user, params)
|
||||
SIGNAL_HANDLER // COMSIG_ATTACK_BY
|
||||
|
||||
if(!istype(attacking_item, /obj/item/petcollar))
|
||||
return NONE
|
||||
if(locate(/obj/item/petcollar) in source)
|
||||
to_chat(user, "<span class='warning'>[source] is already wearing a collar!</span>")
|
||||
return COMPONENT_SKIP_AFTERATTACK
|
||||
|
||||
if(user.drop_item())
|
||||
attacking_item.forceMove(source)
|
||||
to_chat(user, "<span class='notice'>You put [attacking_item] around [source]'s neck.</span>")
|
||||
else
|
||||
to_chat(user, "<span class='warning'>[attacking_item] is stuck to your hand!</span>")
|
||||
|
||||
return COMPONENT_SKIP_AFTERATTACK
|
||||
|
||||
/datum/element/wears_collar/proc/on_overlays_updated(mob/living/source, list/overlays)
|
||||
SIGNAL_HANDLER // COMSIG_ATOM_UPDATE_OVERLAYS
|
||||
|
||||
if(!locate(/obj/item/petcollar) in source)
|
||||
return
|
||||
|
||||
var/icon_tag = ""
|
||||
|
||||
if(source.stat == DEAD || HAS_TRAIT(source, TRAIT_FAKEDEATH))
|
||||
icon_tag = "_dead"
|
||||
else if(collar_resting_icon_state && source.resting)
|
||||
icon_tag = "_rest"
|
||||
|
||||
overlays += mutable_appearance(collar_icon, "[collar_icon_state][icon_tag]collar")
|
||||
overlays += mutable_appearance(collar_icon, "[collar_icon_state][icon_tag]tag")
|
||||
|
||||
/datum/element/wears_collar/proc/on_rest(atom/movable/source)
|
||||
SIGNAL_HANDLER // COMSIG_LIVING_RESTING
|
||||
|
||||
source.update_icon(UPDATE_OVERLAYS)
|
||||
Reference in New Issue
Block a user