mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 03:59:59 +01:00
## About The Pull Request Signals were initially only usable with component listeners, which while no longer the case has lead to outdated documentation, names, and a similar location in code. This pr pulls the two apart. Partially because mso thinks we should, but also because they really aren't directly linked anymore, and having them in this midstate just confuses people. [Renames comp_lookup to listen_lookup, since that's what it does](https://github.com/tgstation/tgstation/commit/102b79694fa8eb57ecf7b36032616a9e368ccced) [Moves signal procs over to their own file](https://github.com/tgstation/tgstation/commit/33d07d01fd336726b4f6f6f1b61bb0b3f11a00dc) [Renames the PREQDELETING and QDELETING comsigs to drop the parent bit since they can hook to more then just comps now](https://github.com/tgstation/tgstation/commit/335ea4ad081ec63c42cfa05856e582cca833af6e) [Does something similar to the attackby comsigs (PARENT -> ATOM)](https://github.com/tgstation/tgstation/commit/210e57051df63f88dac3dd83321236da825aae5e) [And finally passes over the examine signals](https://github.com/tgstation/tgstation/commit/65917658fb8a1e7d28ae23c9437a583d646f0302) ## Why It's Good For The Game Code makes more sense, things are better teased apart, s just good imo ## Changelog 🆑 refactor: Pulled apart the last vestiges of names/docs directly linking signals to components /🆑
92 lines
3.2 KiB
Plaintext
92 lines
3.2 KiB
Plaintext
/**
|
|
* organ set bonus element; which makes organs in the same set, all in one person, provide a unique bonus!
|
|
*
|
|
* Used for infused organs!
|
|
*/
|
|
/datum/element/organ_set_bonus
|
|
element_flags = ELEMENT_BESPOKE
|
|
argument_hash_start_idx = 2
|
|
/// Status Effect typepath to instantiate and apply to the mob.
|
|
var/datum/status_effect/organ_set_bonus/bonus_type
|
|
|
|
/datum/element/organ_set_bonus/Attach(datum/target, bonus_type)
|
|
. = ..()
|
|
|
|
if(!isorgan(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
src.bonus_type = bonus_type
|
|
RegisterSignal(target, COMSIG_ORGAN_IMPLANTED, PROC_REF(on_implanted))
|
|
RegisterSignal(target, COMSIG_ORGAN_REMOVED, PROC_REF(on_removed))
|
|
|
|
/datum/element/organ_set_bonus/Detach(obj/item/organ/target)
|
|
UnregisterSignal(target, list(COMSIG_ORGAN_IMPLANTED, COMSIG_ORGAN_REMOVED))
|
|
if(target.owner)
|
|
UnregisterSignal(target.owner, COMSIG_ATOM_EXAMINE)
|
|
return ..()
|
|
|
|
/datum/element/organ_set_bonus/proc/on_implanted(obj/item/organ/target, mob/living/carbon/receiver)
|
|
SIGNAL_HANDLER
|
|
|
|
var/datum/status_effect/organ_set_bonus/set_bonus = receiver.has_status_effect(bonus_type)
|
|
if(!set_bonus)
|
|
set_bonus = receiver.apply_status_effect(bonus_type)
|
|
set_bonus.set_organs(set_bonus.organs + 1)
|
|
|
|
/datum/element/organ_set_bonus/proc/on_removed(obj/item/organ/target, mob/living/carbon/loser)
|
|
SIGNAL_HANDLER
|
|
|
|
//get status effect or remove it
|
|
var/datum/status_effect/organ_set_bonus/set_bonus = loser.has_status_effect(bonus_type)
|
|
if(set_bonus)
|
|
set_bonus.set_organs(set_bonus.organs - 1)
|
|
|
|
/datum/status_effect/organ_set_bonus
|
|
id = "organ_set_bonus"
|
|
duration = -1
|
|
tick_interval = -1
|
|
alert_type = null
|
|
///how many organs the carbon with this has in the set
|
|
var/organs = 0
|
|
///how many organs in the set you need to enable the bonus
|
|
var/organs_needed = 0
|
|
///if the bonus is active
|
|
var/bonus_active = FALSE
|
|
var/bonus_activate_text = span_notice("??? DNA is deeply infused with you! You've learned how to make error reports!")
|
|
var/bonus_deactivate_text = span_notice("Your DNA is no longer majority ???. You did make an issue report, right?")
|
|
/// Required mob bio-type. Also checks DNA validity it's set to MOB_ORGANIC.
|
|
var/required_biotype = MOB_ORGANIC
|
|
/// A list of traits added to the mob upon bonus activation, can be of any length.
|
|
var/list/bonus_traits = list()
|
|
|
|
/datum/status_effect/organ_set_bonus/proc/set_organs(new_value)
|
|
organs = new_value
|
|
if(!organs) //initial value but won't kick in without calling the setter
|
|
qdel(src)
|
|
if(organs >= organs_needed)
|
|
if(!bonus_active)
|
|
INVOKE_ASYNC(src, PROC_REF(enable_bonus))
|
|
else if(bonus_active)
|
|
INVOKE_ASYNC(src, PROC_REF(disable_bonus))
|
|
|
|
/datum/status_effect/organ_set_bonus/proc/enable_bonus()
|
|
SHOULD_CALL_PARENT(TRUE)
|
|
if(required_biotype)
|
|
if(!(owner.mob_biotypes & required_biotype))
|
|
return FALSE
|
|
if((required_biotype == MOB_ORGANIC) && !owner.can_mutate())
|
|
return FALSE
|
|
bonus_active = TRUE
|
|
if(length(bonus_traits))
|
|
owner.add_traits(bonus_traits, REF(src))
|
|
if(bonus_activate_text)
|
|
to_chat(owner, bonus_activate_text)
|
|
return TRUE
|
|
|
|
/datum/status_effect/organ_set_bonus/proc/disable_bonus()
|
|
SHOULD_CALL_PARENT(TRUE)
|
|
bonus_active = FALSE
|
|
if(length(bonus_traits))
|
|
owner.remove_traits(bonus_traits, REF(src))
|
|
if(bonus_deactivate_text)
|
|
to_chat(owner, bonus_deactivate_text)
|