Files
Paradise/code/datums/components/label.dm
Charlie Nolan 5c5f7842df Secondary goals (#24599)
* Extract requests console message sending code.

* Add secondary goals

* Converted supply shuttle to a signal-based system.

* Lint.

* Review suggestions.

* Secondary goals can now check the supply shuttle for their requirements.

* Remove redundant completion variable, undef what we define.

* Made the request console refuse to issue a secondary goal until you finish the current one.

* Made the shuttle blacklist error more specific, added locked/manifest-attached crates to blacklist.

* Added round end secondary goal report.

* Lint

* Add tags to reagents for secondary goals to use.

* Extracted the reagent logic from the bar goal, used reagent tags.

* Added the Variety of Drinks Bar goal.

* Added variety drinks goal for the Bar.

* CC no longer complains about sending stuff in containers, but the shuttle will refuse lockboxes without goal items.

* Allow unlocked lockboxes on the shuttle.

* Added kitchen goals.

* Lint

* More lint

* Add goals for scichem and medchem, pending reagent labelling.

* Added Kudzu goal for botany.

* I forgot to rename them, oops.

* Lint

* Made mechs sellable, configurable goal rewards.

* Balancing changes.

* Added random Ripley goal.

* Add Clear Task Backlog station goal.

* Lint

* Oops.

* did i even do this right

* Lint

* Excluded drinks available from upgraded booze dispenser.

* Such bugs. Much fix. Wow.

* Goal notice formatting.

* Apply suggestions from code review

Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>

* Made storage nesting better, improved consistency between storage types.

* Out, er, space.

* Added a proc for sending a requests console message.

* Added error messages to Virology Goals.

Backported a few small things from Secondary Goals to make this easier.

* Extracted out the three-way reward code into a proc.

* Update code/__DEFINES/dcs/signals.dm

Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>

* Removed redundant SIGNAL_HANDLER labels.

* Yes, that should be a proc.

* Enforce important parent calls.

* Thank you, DreamChecker

* Undid accidental merge of #24699

* Removed a testing proc that wasn't intended for this PR.

* Removed parts of #24750 that also crept in.

* Made the variety of [x] goals more explicit that they want 50u of each.

* Reduced Kudzu trait requirement to 1.

* Request consoles now output the list of valid departments if you're at an unsupported one.

* Added personal crates.

* Added a supply pack of personal crates.

* Added special cargo handling for personal crates.

* Added automatic personal crate when requesting a goal.

* Required personal crates for most secondary goals.

* Add goal labels to the hand labeler, require them for mech goals.

* Made secondary goals one-per-person, not one-per-department.

* Added support for multi-line system messages to the request consoles.

* Made the RC message for goals nicer.

* Send goal crates even if no normal crates are ready, name and access-lock them properly.

* Don't double-label.

* Let's not use registered_account, names are fine.

* Add a ton of blackbox data to cargo and secondary goals.

* Fix a few bugs.

* More bugfixing, couple more stats.

* Even more stats.

* Text fix.

* Made cargo fines more consistent with other cargo feedback.

* Fixed a bug that prevented non-top-level items from being checked for CARGO_REQUIRE_PRIORITY.

* Blocked large crates from being sent back unopened.

* Enum values should probably be different from each other.

* Correct a bitflag mishap.

* Removed redundant supply shuttle docking and buy/sell attempts.

* Tweak message about personal crates to inlclude that they need to lock it.

* Add /Crates to the Personal Lockers description.

* Less pretty alignment, less complaining linters.

* Corrected a bad name in stats tracking.

* Reduced SciChem variety goal to 5 types.

* Toned down Task Backlog a bit.

* Fixed a bug that made unsellable items nested in containers be stolen by CC (qdeleted).

* Don't require bluespace 8, that's silly.

* Made secondary goals modifiable in the Modify Station Goals UI.

* Whoops, that was supposed to be 600u.

* i ded pls nerf

---------

Co-authored-by: synthtee <127706731+SynthTwo@users.noreply.github.com>
Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>
Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
2024-04-01 07:50:07 +00:00

113 lines
4.8 KiB
Plaintext

/**
The label component.
This component is used to manage labels applied by the hand labeler.
Atoms can only have one instance of this component, and therefore only one label at a time.
This is to avoid having names like "Backpack (label1) (label2) (label3)". This is annoying and abnoxious to read.
When a player clicks the atom with a hand labeler to apply a label, this component gets applied to it.
If the labeler is off, the component will be removed from it, and the label will be removed from its name.
*/
/datum/component/label
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
/// The name of the label the player is applying to the parent.
var/label_name
/datum/component/label/Initialize(_label_name)
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE
label_name = _label_name
apply_label()
/datum/component/label/RegisterWithParent()
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, PROC_REF(OnAttackby))
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(Examine))
/datum/component/label/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_PARENT_ATTACKBY, COMSIG_PARENT_EXAMINE))
/**
This proc will fire after the parent is hit by a hand labeler which is trying to apply another label.
Since the parent already has a label, it will remove the old one from the parent's name, and apply the new one.
*/
/datum/component/label/InheritComponent(datum/component/label/new_comp , i_am_original, _label_name)
remove_label()
if(new_comp)
label_name = new_comp.label_name
else
label_name = _label_name
apply_label()
/**
This proc will trigger when any object is used to attack the parent.
If the attacking object is not a hand labeler, it will return.
If the attacking object is a hand labeler it will restore the name of the parent to what it was before this component was added to it, and the component will be deleted.
Arguments:
* source: The parent.
* attacker: The object that is hitting the parent.
* user: The mob who is wielding the attacking object.
*/
/datum/component/label/proc/OnAttackby(datum/source, obj/item/attacker, mob/user)
// If the attacking object is not a hand labeler or it's not off (has a label ready to apply), return.
// The hand labeler should be off in order to remove a label.
var/obj/item/hand_labeler/labeler = attacker
if(!istype(labeler) || labeler.mode)
return
remove_label()
playsound(parent, 'sound/items/poster_ripped.ogg', 20, TRUE)
to_chat(user, "<span class='warning'>You remove the label from [parent].</span>")
qdel(src) // Remove the component from the object.
/**
This proc will trigger when someone examines the parent.
It will attach the text found in the body of the proc to the `examine_list` and display it to the player examining the parent.
Arguments:
* source: The parent.
* user: The mob exmaining the parent.
* examine_list: The current list of text getting passed from the parent's normal examine() proc.
*/
/datum/component/label/proc/Examine(datum/source, mob/user, list/examine_list)
examine_list += "<span class='notice'>It has a label with some words written on it. Use a hand labeler to remove it.</span>"
/// Applies a label to the name of the parent in the format of: "parent_name (label)"
/datum/component/label/proc/apply_label()
var/atom/owner = parent
owner.name += " ([label_name])"
/// Removes the label from the parent's name
/datum/component/label/proc/remove_label()
var/atom/owner = parent
owner.name = replacetext(owner.name, "([label_name])", "") // Remove the label text from the parent's name, wherever it's located.
owner.name = trim(owner.name) // Shave off any white space from the beginning or end of the parent's name.
/// A verson of the label component specific to labelling goal items.
/datum/component/label/goal
/datum/component/label/goal/Initialize(_label_name)
if(istype(parent, /obj/item))
// Can only be attached to things that won't go in a crate.
return COMPONENT_INCOMPATIBLE
return ..()
/// Adds detailed information to the examine text.
/datum/component/label/goal/Examine(datum/source, mob/user, list/examine_list)
examine_list += "<span class='notice'>It has a label on it, marking it as part of a secondary goal for [label_name]. Use a hand labeler to remove it.</span>"
/// Applies a static label to the parent's name.
/// We do this instead of using label_name so it's easier to identify goal objects at a glance.
/datum/component/label/goal/apply_label()
var/atom/owner = parent
owner.name += " (Secondary Goal)"
/// Removes the label from the parent's name
/datum/component/label/goal/remove_label()
var/atom/owner = parent
owner.name = replacetext(owner.name, "(Secondary Goal)", "") // Remove the label text from the parent's name, wherever it's located.
owner.name = trim(owner.name) // Shave off any white space from the beginning or end of the parent's name.