Fix Silicon Examine Text

Move registration of human prefs signal to flavor_text/carbon subtype.
Remove human specific constraint from update_prefs_flavor_text.
Add flavor_text/silicon subtype.
This commit is contained in:
psq95
2023-07-07 23:34:48 +01:00
parent 3a02116785
commit 0ef3779196
4 changed files with 36 additions and 11 deletions
+13 -5
View File
@@ -570,12 +570,21 @@
#define COMSIG_HUMAN_MELEE_UNARMED_ATTACKBY "human_melee_unarmed_attackby"
///Hit by successful disarm attack (mob/living/carbon/human/attacker,zone_targeted)
#define COMSIG_HUMAN_DISARM_HIT "human_disarm_hit"
#define COMSIG_HUMAN_PREFS_COPIED_TO "human_prefs_copied_to" //from datum/preferences/copy_to(): (datum/preferences, icon_updates, roundstart_checks)
#define COMSIG_HUMAN_HARDSET_DNA "human_hardset_dna" //from mob/living/carbon/human/hardset_dna(): (ui, se, newreal_name, newblood_type, datum/species, newfeatures)
#define COMSIG_HUMAN_ON_RANDOMIZE "humman_on_randomize" //from base of proc/randomize_human()
///from datum/preferences/copy_to(): (datum/preferences, icon_updates, roundstart_checks)
#define COMSIG_HUMAN_PREFS_COPIED_TO "human_prefs_copied_to"
///from mob/living/carbon/human/hardset_dna(): (ui, se, newreal_name, newblood_type, datum/species, newfeatures)
#define COMSIG_HUMAN_HARDSET_DNA "human_hardset_dna"
///from base of proc/randomize_human()
#define COMSIG_HUMAN_ON_RANDOMIZE "humman_on_randomize"
///Whenever EquipRanked is called, called after job is set
#define COMSIG_JOB_RECEIVED "job_received"
// GS13: Silicon Examine Text
// /mob/living/silicon signals
//from datum/preferences/copy_to(): (datum/preferences, icon_updates, roundstart_checks)
#define COMSIG_SILICON_PREFS_COPIED_TO "silicon_prefs_copied_to"
// /datum/species signals
///from datum/species/on_species_gain(): (datum/species/new_species, datum/species/old_species)
@@ -732,10 +741,9 @@
///from datum/action/cyborg_small_sprite and sends when a cyborg changes modules
#define COMSIG_CYBORG_MODULE_CHANGE "cyborg_module_change"
/* Attack signals. They should share the returned flags, to standardize the attack chain. */
/// tool_act -> pre_attack -> target.attackby (item.attack) -> afterattack
///Ends the attack chain. If sent early might cause posterior attacks not to happen.
#define COMPONENT_CANCEL_ATTACK_CHAIN (1<<0)
///Skips the specific attack step, continuing for the next one to happen.
#define COMPONENT_SKIP_ATTACK (1<<1)
#define COMPONENT_SKIP_ATTACK (1<<1)
+18 -5
View File
@@ -40,9 +40,6 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code
LAZYOR(GLOB.mobs_with_editable_flavor_text[M], src)
M.verbs |= /mob/proc/manage_flavor_tests
if(save_key && ishuman(target))
RegisterSignal(target, COMSIG_HUMAN_PREFS_COPIED_TO, .proc/update_prefs_flavor_text)
/datum/element/flavor_text/Detach(atom/A)
. = ..()
UnregisterSignal(A, list(COMSIG_PARENT_EXAMINE, COMSIG_HUMAN_PREFS_COPIED_TO))
@@ -150,9 +147,9 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code
return TRUE
return FALSE
/datum/element/flavor_text/proc/update_prefs_flavor_text(mob/living/carbon/human/H, datum/preferences/P, icon_updates = TRUE, roundstart_checks = TRUE)
/datum/element/flavor_text/proc/update_prefs_flavor_text(mob/M, datum/preferences/P, icon_updates = TRUE, roundstart_checks = TRUE)
if(P.features.Find(save_key))
texts_by_atom[H] = P.features[save_key]
texts_by_atom[M] = P.features[save_key]
//subtypes with additional hooks for DNA and preferences.
/datum/element/flavor_text/carbon
@@ -169,6 +166,7 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code
RegisterSignal(target, COMSIG_CARBON_IDENTITY_TRANSFERRED_TO, .proc/update_dna_flavor_text)
RegisterSignal(target, COMSIG_MOB_ANTAG_ON_GAIN, .proc/on_antag_gain)
if(ishuman(target))
RegisterSignal(target, COMSIG_HUMAN_PREFS_COPIED_TO, .proc/update_prefs_flavor_text)
RegisterSignal(target, COMSIG_HUMAN_HARDSET_DNA, .proc/update_dna_flavor_text)
RegisterSignal(target, COMSIG_HUMAN_ON_RANDOMIZE, .proc/unset_flavor)
@@ -193,3 +191,18 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code
texts_by_atom[user] = ""
if(user.dna)
user.dna.features[save_key] = ""
// GS13: Silicon Examine Text
/datum/element/flavor_text/silicon
/datum/element/flavor_text/silicon/Attach(datum/target, text = "", _name = "Flavor Text", _addendum, _max_len = MAX_FLAVOR_LEN, _always_show = FALSE, _edit = TRUE, _save_key = "flavor_text", _examine_no_preview = FALSE)
if(!issilicon(target))
return ELEMENT_INCOMPATIBLE
. = ..()
if(. == ELEMENT_INCOMPATIBLE)
return
RegisterSignal(target, COMSIG_SILICON_PREFS_COPIED_TO, .proc/update_prefs_flavor_text)
/datum/element/flavor_text/silicon/Detach(mob/living/carbon/C)
. = ..()
UnregisterSignal(C, list(COMSIG_SILICON_PREFS_COPIED_TO))
+2 -1
View File
@@ -57,7 +57,8 @@
/mob/living/silicon/ComponentInitialize()
. = ..()
AddElement(/datum/element/flavor_text, "", "Silicon Flavor Text", "", MAX_FLAVOR_LEN, FALSE, TRUE, "silicon_flavor_text")
// GS13: Silicon Examine Text
AddElement(/datum/element/flavor_text/silicon, "", "Silicon Flavor Text", "", MAX_FLAVOR_LEN, FALSE, TRUE, "silicon_flavor_text")
AddElement(/datum/element/flavor_text, "", "Temporary Flavor Text", "This should be used only for things pertaining to the current round!")
/mob/living/silicon/med_hud_set_health()
+3
View File
@@ -372,6 +372,9 @@
var/mob/living/silicon/robot/R = new /mob/living/silicon/robot(loc)
// GS13: Silicon Examine Text
SEND_SIGNAL(R, COMSIG_SILICON_PREFS_COPIED_TO, src)
R.gender = gender
R.invisibility = 0