Files
Bubberstation/code/datums/components/spill.dm
AnturK 4d6a8bc537 515 Compatibility (#71161)
Makes the code compatible with 515.1594+

Few simple changes and one very painful one.
Let's start with the easy:
* puts call behind `LIBCALL` define, so call_ext is properly used in 515
* Adds `NAMEOF_STATIC(_,X)` macro for nameof in static definitions since
src is now invalid there.
* Fixes tgui and devserver. From 515 onward the tmp3333{procid} cache
directory is not appened to base path in browser controls so we don't
check for it in base js and put the dev server dummy window file in
actual directory not the byond root.
* Renames the few things that had /final/ in typepath to ultimate since
final is a new keyword

And the very painful change:
`.proc/whatever` format is no longer valid, so we're replacing it with
new nameof() function. All this wrapped in three new macros.
`PROC_REF(X)`,`TYPE_PROC_REF(TYPE,X)`,`GLOBAL_PROC_REF(X)`. Global is
not actually necessary but if we get nameof that does not allow globals
it would be nice validation.
This is pretty unwieldy but there's no real alternative.
If you notice anything weird in the commits let me know because majority
was done with regex replace.

@tgstation/commit-access Since the .proc/stuff is pretty big change.

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
2022-11-15 03:50:11 +00:00

72 lines
2.2 KiB
Plaintext

// This component is for forcing strange things into your pocket that fall out if you fall down
// Yes this exists purely for the spaghetti meme
/datum/component/spill
can_transfer = TRUE
var/preexisting_slot_flags
var/list/droptext
var/list/dropsound
var/drop_memory
// droptext is an arglist for visible_message
// dropsound is a list of potential sounds that gets picked from
/datum/component/spill/Initialize(list/_droptext, list/_dropsound, _drop_memory)
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
if(_droptext && !islist(_droptext))
_droptext = list(_droptext)
droptext = _droptext
if(_dropsound && !islist(_dropsound))
_dropsound = list(_dropsound)
dropsound = _dropsound
drop_memory = _drop_memory
/datum/component/spill/PostTransfer()
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
/datum/component/spill/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(equip_react))
RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(drop_react))
var/obj/item/master = parent
preexisting_slot_flags = master.slot_flags
master.slot_flags |= ITEM_SLOT_POCKETS
/datum/component/spill/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED))
var/obj/item/master = parent
if(!(preexisting_slot_flags & ITEM_SLOT_POCKETS))
master.slot_flags &= ~ITEM_SLOT_POCKETS
/datum/component/spill/proc/equip_react(obj/item/source, mob/equipper, slot)
SIGNAL_HANDLER
if(slot & (ITEM_SLOT_LPOCKET|ITEM_SLOT_RPOCKET))
RegisterSignal(equipper, COMSIG_LIVING_STATUS_KNOCKDOWN, PROC_REF(knockdown_react), TRUE)
else
UnregisterSignal(equipper, COMSIG_LIVING_STATUS_KNOCKDOWN)
/datum/component/spill/proc/drop_react(obj/item/source, mob/dropper)
SIGNAL_HANDLER
UnregisterSignal(dropper, COMSIG_LIVING_STATUS_KNOCKDOWN)
/datum/component/spill/proc/knockdown_react(mob/living/fool, amount)
SIGNAL_HANDLER
if(amount <= 0)
return
var/obj/item/master = parent
fool.dropItemToGround(master)
if(droptext)
fool.visible_message(arglist(droptext))
if(dropsound)
playsound(master, pick(dropsound), 30)
if(drop_memory)
fool.mind?.add_memory(MEMORY_SPAGHETTI_SPILL, list(DETAIL_PROTAGONIST = fool), story_value = STORY_VALUE_OKAY, memory_flags = MEMORY_CHECK_BLINDNESS)