Skip to content

Commit

Permalink
Made plant_controller into a proper subsystem (#18733)
Browse files Browse the repository at this point in the history
* Made plant_controller into a proper subsystem

* rm oldcode

* Actually remove PHENOL from the list
  • Loading branch information
DamianX authored and jknpj committed Jul 6, 2018
1 parent c9ad4ed commit 43ffcb8
Show file tree
Hide file tree
Showing 24 changed files with 144 additions and 168 deletions.
2 changes: 0 additions & 2 deletions __DEFINES/hydro.dm

This file was deleted.

Expand Up @@ -21,3 +21,6 @@
// Xenobotany machines
#define GENEGUN_MODE_SPLICE 1
#define GENEGUN_MODE_PURGE 2

#define HYDRO_PREHISTORIC 1
#define HYDRO_VOX 2
3 changes: 3 additions & 0 deletions __DEFINES/subsystem.dm
Expand Up @@ -7,6 +7,7 @@
#define SS_INIT_SUN 24
#define SS_INIT_GARBAGE 23
#define SS_INIT_JOB 22
#define SS_INIT_PLANT 21.5
#define SS_INIT_HUMANS 21
#define SS_INIT_MAP 20
#define SS_INIT_POWER 19
Expand Down Expand Up @@ -37,6 +38,7 @@
#define SS_PRIORITY_EVENT 65
#define SS_PRIORITY_DISEASE 60
#define SS_PRIORITY_FAST_MACHINERY 55
#define SS_PRIORITY_PLANT 40
#define SS_PRIORITY_UNSPECIFIED 30
#define SS_PRIORITY_LIGHTING 20
#define SS_PRIORITY_SUN 3
Expand All @@ -55,6 +57,7 @@
#define SS_DISPLAY_MACHINERY -50
#define SS_DISPLAY_PIPENET -40
#define SS_DISPLAY_FAST_MACHINERY -30
#define SS_DISPLAY_PLANT -25
#define SS_DISPLAY_POWER -20
#define SS_DISPLAY_TICKER -10
#define SS_DISPLAY_UNSPECIFIED 0
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/unsorted.dm
Expand Up @@ -1715,12 +1715,12 @@ Game Mode config tags:
if(istype(O, /obj/item/weapon/grown))
var/obj/item/weapon/grown/F = O
if(F.plantname)
new_seed_type = plant_controller.seeds[F.plantname]
new_seed_type = SSplant.seeds[F.plantname]
else
if(istype(O, /obj/item/weapon/reagent_containers/food/snacks/grown))
var/obj/item/weapon/reagent_containers/food/snacks/grown/F = O
if(F.plantname)
new_seed_type = plant_controller.seeds[F.plantname]
new_seed_type = SSplant.seeds[F.plantname]
else
var/obj/item/F = O
if(F.nonplant_seed_type)
Expand Down
80 changes: 80 additions & 0 deletions code/controllers/subsystem/plant.dm
@@ -0,0 +1,80 @@
var/datum/subsystem/plant/SSplant

// Processes vines/spreading plants.
/datum/subsystem/plant
name = "Plants"
init_order = SS_INIT_PLANT
display_order = SS_DISPLAY_PLANT
priority = SS_PRIORITY_PLANT
wait = 3 SECONDS

var/list/processing_plants = list()
var/list/currentrun
var/list/datum/seed/seeds = list() // All seed data stored here.

/datum/subsystem/plant/New()
NEW_SS_GLOBAL(SSplant)

// Predefined/roundstart varieties use a string key to make it
// easier to grab the new variety when mutating. Post-roundstart
// and mutant varieties use their uid converted to a string instead.
// Looks like shit but it's sort of necessary.
/datum/subsystem/plant/Initialize()
// Populate the global seed datum list.
for(var/type in subtypesof(/datum/seed))
var/datum/seed/S = new type
seeds[S.name] = S
S.uid = "[seeds.len]"
S.roundstart = TRUE
..()

/datum/subsystem/plant/proc/create_random_seed(var/survive_on_station)
var/datum/seed/seed = new()
seed.randomize()
seed.uid = seeds.len + 1
seed.name = "[seed.uid]"
seeds[seed.name] = seed

if(survive_on_station)
if(seed.consume_gasses)
seed.consume_gasses["plasma"] = null //PHORON DOES NOT EXIST
seed.consume_gasses["carbon_dioxide"] = null
if(seed.chems)
seed.chems.Remove(PHENOL) // Eating through the hull will make these plants completely inviable, albeit very dangerous.
seed.ideal_heat = initial(seed.ideal_heat)
seed.heat_tolerance = initial(seed.heat_tolerance)
seed.ideal_light = initial(seed.ideal_light)
seed.light_tolerance = initial(seed.light_tolerance)
seed.lowkpa_tolerance = initial(seed.lowkpa_tolerance)
seed.highkpa_tolerance = initial(seed.highkpa_tolerance)
return seed

/datum/subsystem/plant/stat_entry()
..("P:[processing_plants.len]")


/datum/subsystem/plant/fire(var/resumed = FALSE)
if (!resumed)
currentrun = processing_plants.Copy()

while (currentrun.len)
var/obj/effect/plantsegment/plant = currentrun[currentrun.len]
currentrun.len--

if (!plant || plant.gcDestroyed || plant.disposed)
remove_plant(plant)
continue
if(plant.timestopped)
continue

plant.process()
if (MC_TICK_CHECK)
return

/datum/subsystem/plant/proc/add_plant(var/obj/effect/plantsegment/plant)
if(!istype(plant) || plant.gcDestroyed || plant.disposed)
return
processing_plants |= plant

/datum/subsystem/plant/proc/remove_plant(var/obj/effect/plantsegment/plant)
processing_plants -= plant
1 change: 0 additions & 1 deletion code/game/gamemodes/cult/narsie.dm
Expand Up @@ -412,7 +412,6 @@ var/global/mr_clean_targets = list(
/obj/effect/decal/mecha_wreckage,
/obj/effect/decal/remains,
/obj/effect/plantsegment,
///obj/effect/plant_controller,
/obj/effect/biomass,
/obj/effect/biomass_controller,
/obj/effect/rune,
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/events/spacevines.dm
Expand Up @@ -10,7 +10,7 @@

if(turfs.len) //Pick a turf to spawn at if we can
var/turf/simulated/floor/T = pick(turfs)
var/datum/seed/seed = plant_controller.create_random_seed(1)
var/datum/seed/seed = SSplant.create_random_seed(1)
seed.spread = 2 // So it will function properly as vines.
seed.potency = rand(potency_min, potency_max) // 70-100 potency will help guarantee a wide spread and powerful effects.
seed.maturation = rand(maturation_min, maturation_max)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/grown_inedible.dm
Expand Up @@ -20,7 +20,7 @@
spawn(1)
// Fill the object up with the appropriate reagents.
if(!isnull(plantname))
var/datum/seed/S = plant_controller.seeds[plantname]
var/datum/seed/S = SSplant.seeds[plantname]
if(!S || !S.chems)
return

Expand Down
4 changes: 2 additions & 2 deletions code/modules/hydroponics/hydro_tools.dm
Expand Up @@ -32,13 +32,13 @@
else if(istype(target,/obj/item/weapon/reagent_containers/food/snacks/grown))

var/obj/item/weapon/reagent_containers/food/snacks/grown/G = target
grown_seed = plant_controller.seeds[G.plantname]
grown_seed = SSplant.seeds[G.plantname]
grown_reagents = G.reagents

else if(istype(target,/obj/item/weapon/grown))

var/obj/item/weapon/grown/G = target
grown_seed = plant_controller.seeds[G.plantname]
grown_seed = SSplant.seeds[G.plantname]
grown_reagents = G.reagents

else if(istype(target,/obj/item/seeds))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/hydro_tray.dm
Expand Up @@ -170,7 +170,7 @@
//Remove the seed if something is already planted.
if(seed)
remove_plant()
seed = plant_controller.seeds[pick(list("reishi","nettles","amanita","mushrooms","plumphelmet","towercap","harebells","weeds"))]
seed = SSplant.seeds[pick(list("reishi","nettles","amanita","mushrooms","plumphelmet","towercap","harebells","weeds"))]
if(!seed)
return //Weed does not exist, someone fucked up.

Expand Down
8 changes: 3 additions & 5 deletions code/modules/hydroponics/hydroponics_mutations.dm
Expand Up @@ -122,7 +122,7 @@
// We need to make sure we're not modifying one of the global seed datums.
// If it's not in the global list, then no products of the line have been
// harvested yet and it's safe to assume it's restricted to this tray.
if(!isnull(plant_controller.seeds[seed.name]))
if(!isnull(SSplant.seeds[seed.name]))
seed = seed.diverge(modified)

/obj/machinery/portable_atmospherics/hydroponics/proc/get_ratio(var/severity, var/list/softcaps, var/list/hardcaps, var/input)
Expand Down Expand Up @@ -534,11 +534,9 @@
var/previous_plant = seed.display_name
var/newseed = seed.get_mutant_variant()

if(!plant_controller.seeds.Find(newseed))
seed = SSplant.seeds[newseed]
if(!seed)
return

seed = plant_controller.seeds[newseed]

dead = 0
age = 1
health = seed.endurance
Expand Down
102 changes: 0 additions & 102 deletions code/modules/hydroponics/seed_controller.dm

This file was deleted.

6 changes: 3 additions & 3 deletions code/modules/hydroponics/seed_datums.dm
Expand Up @@ -522,10 +522,10 @@ var/global/list/gene_tag_masks = list() // Gene obfuscation for delicious tria

//This may be a new line. Update the global if it is.
/datum/seed/proc/add_newline_to_controller()
if(name == "new line" || !(name in plant_controller.seeds))
uid = plant_controller.seeds.len + 1
if(name == "new line" || !(name in SSplant.seeds))
uid = SSplant.seeds.len + 1
name = "[uid]"
plant_controller.seeds[name] = src
SSplant.seeds[name] = src

//Place the plant products at the feet of the user.
/datum/seed/proc/harvest(var/mob/user,var/yield_mod = 1)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/seed_extractor.dm
Expand Up @@ -167,7 +167,7 @@ obj/machinery/seed_extractor/Topic(var/href, var/list/href_list)
usr.set_machine(src)

var/amt = text2num(href_list["amt"])
var/datum/seed/S = plant_controller.seeds[href_list["seed"]]
var/datum/seed/S = SSplant.seeds[href_list["seed"]]

for(var/datum/seed_pile/P in piles)
if(P.seed == S)
Expand Down
25 changes: 15 additions & 10 deletions code/modules/hydroponics/seed_machines.dm
Expand Up @@ -163,12 +163,17 @@
return

var/list/data = list()

var/list/geneMasks[0]
for(var/gene_tag in plant_controller.gene_tag_list)
geneMasks[list("tag" = gene_tag)] = null // For some reason the JSON writer sees it as assoc if it's a list of strings.

data["geneMasks"] = geneMasks
var/static/list/gene_tag_list = list(
list("tag" = GENE_PHYTOCHEMISTRY),
list("tag" = GENE_MORPHOLOGY),
list("tag" = GENE_BIOLUMINESCENCE),
list("tag" = GENE_ECOLOGY),
list("tag" = GENE_ECOPHYSIOLOGY),
list("tag" = GENE_METABOLISM),
list("tag" = GENE_NUTRITION),
list("tag" = GENE_DEVELOPMENT)
)
data["geneTags"] = gene_tag_list

data["activity"] = active
data["degradation"] = degradation
Expand Down Expand Up @@ -212,10 +217,10 @@
return
loaded_seed.forceMove(get_turf(src))

if(loaded_seed.seed.name == "new line" || isnull(plant_controller.seeds[loaded_seed.seed.name]))
loaded_seed.seed.uid = plant_controller.seeds.len + 1
if(loaded_seed.seed.name == "new line" || isnull(SSplant.seeds[loaded_seed.seed.name]))
loaded_seed.seed.uid = SSplant.seeds.len + 1
loaded_seed.seed.name = "[loaded_seed.seed.uid]"
plant_controller.seeds[loaded_seed.seed.name] = loaded_seed.seed
SSplant.seeds[loaded_seed.seed.name] = loaded_seed.seed

loaded_seed.update_seed()
visible_message("[bicon(src)] [src] beeps and spits out [loaded_seed].")
Expand Down Expand Up @@ -369,7 +374,7 @@
last_action = world.time
active = 1

if(!isnull(plant_controller.seeds[loaded_seed.seed.name]))
if(!isnull(SSplant.seeds[loaded_seed.seed.name]))
loaded_seed.seed = loaded_seed.seed.diverge(1)
loaded_seed.seed_type = loaded_seed.seed.name
loaded_seed.update_seed()
Expand Down

0 comments on commit 43ffcb8

Please sign in to comment.