Skip to content

Commit

Permalink
Removes an infective GetComponent (tgstation#44422)
Browse files Browse the repository at this point in the history
* Removes an infective GetComponent

* Adds a meme underscore

* Restructures signal registration
  • Loading branch information
ninjanomnom authored and AnturK committed Jun 11, 2019
1 parent 1380c95 commit 6e1a049
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/components.dm
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@
//Food
#define COMSIG_FOOD_EATEN "food_eaten" //from base of obj/item/reagent_containers/food/snacks/attack(): (mob/living/eater, mob/feeder)

//Gibs
#define COMSIG_GIBS_STREAK "gibs_streak" // from base of /obj/effect/decal/cleanable/blood/gibs/streak(): (list/directions, list/diseases)

//Mood
#define COMSIG_ADD_MOOD_EVENT "add_mood" //Called when you send a mood event from anywhere in the code.
#define COMSIG_CLEAR_MOOD_EVENT "clear_mood" //Called when you clear a mood event from anywhere in the code.
Expand Down
22 changes: 16 additions & 6 deletions code/datums/components/infective.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@

/datum/component/infective/Initialize(list/datum/disease/_diseases, expire_in)
if(islist(_diseases))
diseases = diseases
diseases = _diseases
else
diseases = list(_diseases)
if(expire_in)
expire_time = world.time + expire_in
QDEL_IN(src, expire_in)

if(!ismovableatom(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, .proc/clean)
RegisterSignal(parent, COMSIG_MOVABLE_BUCKLE, .proc/try_infect_buckle)
RegisterSignal(parent, COMSIG_MOVABLE_BUMP, .proc/try_infect_collide)
RegisterSignal(parent, COMSIG_MOVABLE_CROSSED, .proc/try_infect_crossed)
RegisterSignal(parent, COMSIG_ITEM_ATTACK_ZONE, .proc/try_infect_attack_zone)
RegisterSignal(parent, COMSIG_ITEM_ATTACK, .proc/try_infect_attack)
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, .proc/try_infect_equipped)
RegisterSignal(parent, COMSIG_MOVABLE_IMPACT_ZONE, .proc/try_infect_impact_zone)
RegisterSignal(parent, COMSIG_FOOD_EATEN, .proc/try_infect_eat)
RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, .proc/clean)
if(isitem(parent))
RegisterSignal(parent, COMSIG_ITEM_ATTACK_ZONE, .proc/try_infect_attack_zone)
RegisterSignal(parent, COMSIG_ITEM_ATTACK, .proc/try_infect_attack)
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, .proc/try_infect_equipped)
if(istype(parent, /obj/item/reagent_containers/food/snacks))
RegisterSignal(parent, COMSIG_FOOD_EATEN, .proc/try_infect_eat)
else if(istype(parent, /obj/effect/decal/cleanable/blood/gibs))
RegisterSignal(parent, COMSIG_GIBS_STREAK, .proc/try_infect_streak)

/datum/component/infective/proc/try_infect_eat(datum/source, mob/living/eater, mob/living/feeder)
for(var/V in diseases)
Expand Down Expand Up @@ -73,6 +80,9 @@
if(isliving(M))
try_infect(M, BODY_ZONE_PRECISE_L_FOOT)

/datum/component/infective/proc/try_infect_streak(datum/source, list/directions, list/output_diseases)
output_diseases |= diseases

/datum/component/infective/proc/try_infect(mob/living/L, target_zone)
for(var/V in diseases)
L.ContactContractDisease(V, target_zone)
10 changes: 4 additions & 6 deletions code/game/objects/effects/decals/cleanable/humans.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,13 @@
. = ..()

/obj/effect/decal/cleanable/blood/gibs/proc/streak(list/directions)
set waitfor = 0
set waitfor = FALSE
var/list/diseases = list()
SEND_SIGNAL(src, COMSIG_GIBS_STREAK, directions, diseases)
var/direction = pick(directions)
for(var/i = 0, i < pick(1, 200; 2, 150; 3, 50), i++)
for(var/i in 0 to pick(0, 200; 1, 150; 2, 50))
sleep(2)
if(i > 0)
var/list/datum/disease/diseases
var/datum/component/infective/infective = GetComponent(/datum/component/infective)
if(infective)
diseases = infective.diseases
new /obj/effect/decal/cleanable/blood/splatter(loc, diseases)
if(!step_to(src, get_step(src, direction), 0))
break
Expand Down

0 comments on commit 6e1a049

Please sign in to comment.