mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 07:08:00 +01:00
Botany reagent cross pollination code improvement and fix (#85329)
## About The Pull Request fixes #83852 Rewrites the code responsible for the pollination reagent selection logic making it more readable and self contained, fixes a bug where plants would repeatedly select reagents they already have for pollination ## Why It's Good For The Game Better code, fixes a bug that would cause reagent cross pollination to take forever in plants with many reagents. ## Changelog 🆑 fix: plants no longer select reagent genes they already have while cross pollinating code: improves reagent cross pollination code 🆑 --------- Co-authored-by: RafRoq <rafael.roquec@gmail.com> Co-authored-by: Rafael <34388545+RafRoq@users.noreply.github.com> Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
co-authored by
RafRoq
Rafael
Ghom
parent
56d294df7c
commit
460a2d8a92
@@ -798,15 +798,7 @@
|
||||
if(isnull(particles))
|
||||
particles = new /particles/pollen()
|
||||
if(myseed.instability >= 20 && prob(70) && length(T.myseed.reagents_add))
|
||||
var/list/datum/plant_gene/reagent/possible_reagents = list()
|
||||
for(var/datum/plant_gene/reagent/reag in T.myseed.genes)
|
||||
possible_reagents += reag
|
||||
var/datum/plant_gene/reagent/reagent_gene = pick(possible_reagents) //Let this serve as a lession to delete your WIP comments before merge.
|
||||
if(reagent_gene.can_add(myseed))
|
||||
if(!reagent_gene.try_upgrade_gene(myseed))
|
||||
myseed.genes += reagent_gene.Copy()
|
||||
myseed.reagents_from_genes()
|
||||
continue
|
||||
myseed.perform_reagent_pollination(T.myseed)
|
||||
if(!any_adjacent)
|
||||
particles = null
|
||||
|
||||
|
||||
@@ -616,3 +616,27 @@
|
||||
|
||||
/obj/item/grown/get_plant_seed()
|
||||
return seed
|
||||
|
||||
/obj/item/seeds/proc/perform_reagent_pollination(obj/item/seeds/donor)
|
||||
var/list/datum/plant_gene/reagent/valid_reagents = list()
|
||||
for(var/datum/plant_gene/reagent/donor_reagent in donor.genes)
|
||||
var/repeated = FALSE
|
||||
for(var/datum/plant_gene/reagent/receptor_reagent in genes)
|
||||
if(donor_reagent.reagent_id == receptor_reagent.reagent_id)
|
||||
if(receptor_reagent.rate < donor_reagent.rate)
|
||||
receptor_reagent.rate = donor_reagent.rate
|
||||
// sucessful pollination/upgrade, we stop here.
|
||||
reagents_from_genes()
|
||||
return
|
||||
else
|
||||
repeated = TRUE
|
||||
break
|
||||
|
||||
if(!repeated)
|
||||
valid_reagents += donor_reagent
|
||||
|
||||
if(length(valid_reagents))
|
||||
// pick a valid reagent that our receptor seed don't have and add the gene to it
|
||||
var/datum/plant_gene/reagent/selected_reagent = pick(valid_reagents)
|
||||
genes += selected_reagent
|
||||
reagents_from_genes()
|
||||
|
||||
Reference in New Issue
Block a user