Skip to content

Commit

Permalink
Fix fruit counting and refactor out delete_fruit
Browse files Browse the repository at this point in the history
  • Loading branch information
Drulikar committed Feb 9, 2024
1 parent 9afc17a commit 464deae
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions code/modules/cm_aliens/structures/fruit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,6 @@
qdel(src)
. = ..()

/obj/effect/alien/resin/fruit/proc/delete_fruit()
//Notify and update the xeno count
if(!QDELETED(bound_xeno))
if(!picked)
to_chat(bound_xeno, SPAN_XENOHIGHDANGER("We sense one of our fruit has been destroyed."))
bound_xeno.current_fruits.Remove(src)
var/datum/action/xeno_action/onclick/plant_resin_fruit/prf = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/onclick/plant_resin_fruit)
prf.update_button_icon()

if(picked) // No need to update the number, since the fruit still exists (just as a different item)
return
var/number_of_fruit = length(bound_xeno.current_fruits)
prf.button.set_maptext(SMALL_FONTS_COLOR(7, number_of_fruit, "#e69d00"), 19, 2)
prf.update_button_icon()
bound_xeno = null

/obj/effect/alien/resin/fruit/proc/reduce_timer(maturity_increase)
if (mature || timer_id == TIMER_ID_NULL)
return
Expand Down Expand Up @@ -193,7 +177,19 @@
return FALSE

/obj/effect/alien/resin/fruit/Destroy()
delete_fruit()
//Notify and update the xeno count
if(!QDELETED(bound_xeno))
if(!picked)
to_chat(bound_xeno, SPAN_XENOHIGHDANGER("We sense one of our fruit has been destroyed."))
bound_xeno.current_fruits.Remove(src)

var/number_of_fruit = length(bound_xeno.current_fruits)
var/datum/action/xeno_action/onclick/plant_resin_fruit/prf = get_xeno_action_by_type(bound_xeno, /datum/action/xeno_action/onclick/plant_resin_fruit)
prf.button.set_maptext(SMALL_FONTS_COLOR(7, number_of_fruit, "#e69d00"), 19, 2)
prf.update_button_icon()

bound_xeno = null

return ..()

//Greater
Expand Down Expand Up @@ -281,9 +277,9 @@
..()
START_PROCESSING(SSobj, src)

/obj/effect/alien/resin/fruit/spore/delete_fruit()
/obj/effect/alien/resin/fruit/spore/Destroy()
STOP_PROCESSING(SSobj, src)
..()
return ..()

/obj/effect/alien/resin/fruit/spore/process()
if(mature)
Expand Down

0 comments on commit 464deae

Please sign in to comment.