mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-28 10:01:58 +00:00
* Refactors the Nuclear Authentication Disk's Lone Op Behavior Into a Component, + Examine Message (#73453) ## About The Pull Request ### Refactor Turns all the behavior for the nuke disk raising lone op probability when unsecured into a new component, the "Keep Me Secure" component. As an example (and really, I made it to test that the component was actually working), there is a new admin plush called the "whiny plushie" that will change icon depending on whether it is secure or not. Useful! ### Examine I also added an examine message. Will explain below ## Why It's Good For The Game The examine message was really what this entire pr's purpose was really for. > [Capsandi](https://tgstation13.org/phpBB/memberlist.php?mode=viewprofile&u=7767) wrote: [↑](https://tgstation13.org/phpBB/viewtopic.php?p=665827#p665827)Wed Feb 15, 2023 2:42 pm Someone needs to pr some sort of indicator as to whether the disk is 'secure' or not so players who don't know about the niche lone op mechanic won't make the same intuitive assumption (though swat has been trolled for putting it in the safe before). I agree with this for the same reasons I did #73016 so I'll restate the point with it here: A piece of banning a captain recently was that they didn't secure the disk, but there is no indication in game that the disk has special condiitons that trigger lone op, just that it should be kept safe (which yeah, nuke ops want it). I'd rather remove the ambiguity of a captain knowing this mechanic or not for the sake of the game, a single examine for it is harmless I'm considering this administration, not a feature. If maints want me to take it out and have this be refactor only, that's fine with me ## Changelog 🆑 refactor: Refactors how nuclear activation disk works. Shouldn't notice a whole lot but if you do, it might be because of this. admin: Disk now has an examine message for whether it's secure or not, to make it less ambiguous for players. /🆑 * Refactors the Nuclear Authentication Disk's Lone Op Behavior Into a Component, + Examine Message --------- Co-authored-by: tralezab <40974010+tralezab@users.noreply.github.com>
76 lines
2.6 KiB
Plaintext
76 lines
2.6 KiB
Plaintext
/**
|
|
* ### Keep Me Secure component!
|
|
*
|
|
* Component that attaches to items, invoking a function to react when left unmoved and unsecured for too long.
|
|
* Used for Nuclear Authentication Disks, and whiny plushy as an example (which changes sprites depending on whether it considers itself secure.)
|
|
*/
|
|
/datum/component/keep_me_secure
|
|
/// callback for the parent being secure
|
|
var/datum/callback/secured_callback
|
|
/// callback for the parent being unsecured
|
|
var/datum/callback/unsecured_callback
|
|
|
|
/// The last secure location the parent was at.
|
|
var/turf/last_secured_location
|
|
/// The last world time the parent moved.
|
|
var/last_move
|
|
|
|
/datum/component/keep_me_secure/Initialize(secured_callback, unsecured_callback)
|
|
if(!isitem(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
src.secured_callback = secured_callback
|
|
src.unsecured_callback = unsecured_callback
|
|
|
|
/datum/component/keep_me_secure/RegisterWithParent()
|
|
last_move = world.time
|
|
START_PROCESSING(SSobj, src)
|
|
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
|
|
RegisterSignal(parent, COMSIG_PARENT_EXAMINE_MORE, PROC_REF(on_examine_more))
|
|
|
|
|
|
/datum/component/keep_me_secure/UnregisterFromParent()
|
|
STOP_PROCESSING(SSobj, src)
|
|
UnregisterSignal(parent, COMSIG_PARENT_EXAMINE)
|
|
|
|
/// Returns whether the game is supposed to consider the parent "secure".
|
|
/datum/component/keep_me_secure/proc/is_secured()
|
|
var/obj/item/item_parent = parent
|
|
if (last_secured_location == get_turf(item_parent))
|
|
return FALSE
|
|
|
|
var/mob/holder = item_parent.pulledby || get(parent, /mob)
|
|
if (isnull(holder?.client))
|
|
return FALSE
|
|
|
|
return TRUE
|
|
|
|
/datum/component/keep_me_secure/process(delta_time)
|
|
if(is_secured())
|
|
last_secured_location = get_turf(parent)
|
|
last_move = world.time
|
|
if(secured_callback)
|
|
secured_callback.Invoke(last_move)
|
|
else
|
|
if(unsecured_callback)
|
|
unsecured_callback.Invoke(last_move)
|
|
|
|
/// signal sent when parent is examined
|
|
/datum/component/keep_me_secure/proc/on_examine(mob/living/source, mob/examiner, list/examine_list)
|
|
SIGNAL_HANDLER
|
|
|
|
examine_list += span_boldnotice("[parent] should be secured at all times.")
|
|
if(is_secured())
|
|
examine_list += span_notice("Right now, it is.")
|
|
else
|
|
examine_list += span_warning("Right now, it isn't...")
|
|
examine_list += span_notice("Examine closer for more info.")
|
|
|
|
/// signal sent when parent is examined more
|
|
/datum/component/keep_me_secure/proc/on_examine_more(mob/living/source, mob/examiner, list/examine_list)
|
|
SIGNAL_HANDLER
|
|
|
|
examine_list += span_notice("For [parent] to be secure, it needs to be:")
|
|
examine_list += span_notice("1. Always on the move, and...")
|
|
examine_list += span_notice("2. Held or dragged by someone.")
|