Files
Bubberstation/code/modules/research/techweb/_techweb_node.dm
SkyratBot 124ddd7cca [MIRROR] tgui Preferences Menu + total rewrite of the preferences backend (#8153)
* tgui Preferences Menu + total rewrite of the preferences backend

* nah, we dont need to ping those people

* trying to remove the funny stuff

* unmodularizing this

* prefs reset

* this may need to be reverted, who knows

* okay, this part

* perhaps

* EEEEEEEEE

* unsanitary

* E

* Stage 1 + loadout system

* more fixes

* E

* I mean, it launches?

* More fixes and reorganisation

* E

* customisation code is spaget.

* disable ERP prefs

* Update erp_preferences.dm

* Update erp_preferences.dm

* E

* Slowly getting there

* It may be time for help :)

* tri...colors... help

* preferences now pass preferences

* Update dna.dm

* Fuck this man

* missing savefile return, set_species works, removed dumb stuff from updateappearance

* https://github.com/Skyrat-SS13/Skyrat-tg/pull/8199

* https://github.com/Skyrat-SS13/Skyrat-tg/pull/8224

* https://github.com/tgstation/tgstation/pull/61519

* https://github.com/Skyrat-SS13/Skyrat-tg/pull/8278

* e

* le butonAZARAK HELLO

* hhh

* Proper recognition where it's due, MrMelbert!

* EEEE

* examine block

* Better gen hit sounds from whitedream

* final loadout touches, more bug fixes im sure to come

* i said there would be bugfixes

* Update LoadoutManager.js

* Missing preferences in the html menu

* LIVE TESTING PHASE BABY

* Update LoadoutManager.js

* EEE

* LAUNCH TEST FIRE

* Update job.dm

* Update new_player.dm

* 50gb DAY ONE PATCH

* EEE

* Update preferences.dm

* buggle fixes

* Update examine.dm

* >LOOC starts on

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: jjpark-kb <55967837+jjpark-kb@users.noreply.github.com>
Co-authored-by: Gandalf <jzo123@hotmail.com>
Co-authored-by: Azarak <azarak10@gmail.com>
2021-09-23 00:40:37 +01:00

130 lines
4.6 KiB
Plaintext

/**
* # Techweb Node
*
* A datum representing a researchable node in the techweb.
*
* Techweb nodes are GLOBAL, there should only be one instance of them in the game. Persistant
* changes should never be made to them in-game. USE SSRESEARCH PROCS TO OBTAIN REFERENCES.
* DO NOT REFERENCE OUTSIDE OF SSRESEARCH OR YOU WILL FUCK UP GC.
*/
/datum/techweb_node
/// Internal ID of the node
var/id
/// The name of the node as it is shown on UIs
var/display_name = "Errored Node"
/// A description of the node to show on UIs
var/description = "Why are you seeing this?"
/// Whether it starts off hidden
var/hidden = FALSE
/// If the tech can be randomly generated by the BEPIS as a reward. MEant to be fully given in tech disks, not researched
var/experimental = FALSE
/// Whether it's available without any research
var/starting_node = FALSE
var/list/prereq_ids = list()
var/list/design_ids = list()
/// CALCULATED FROM OTHER NODE'S PREREQUISITIES. Associated list id = TRUE
var/list/unlock_ids = list()
/// Associative list, path = list(point type = point_value)
var/list/boost_item_paths = list()
/// Boosting this will autounlock this node
var/autounlock_by_boost = TRUE
/// The points cost to research the node, type = amount
var/list/research_costs = list()
/// The category of the node
var/category = "Misc"
/// The list of experiments required to research the node
var/list/required_experiments = list()
/// If completed, these experiments give a specific point amount discount to the node.area
var/list/discount_experiments = list()
/// When we apply a discount to a node we add the experiment for it here to prevent excess discount applications
var/list/discount_used = list()
/datum/techweb_node/error_node
id = "ERROR"
display_name = "ERROR"
description = "This usually means something in the database has corrupted. If it doesn't go away automatically, inform Central Command for their techs to fix it ASAP(tm)"
/datum/techweb_node/proc/Initialize()
//Make lists associative for lookup
for(var/id in prereq_ids)
prereq_ids[id] = TRUE
for(var/id in design_ids)
design_ids[id] = TRUE
for(var/id in unlock_ids)
unlock_ids[id] = TRUE
/datum/techweb_node/Destroy()
SSresearch.techweb_nodes -= id
return ..()
/datum/techweb_node/serialize_list(list/options)
. = list()
VARSET_TO_LIST(., id)
VARSET_TO_LIST(., display_name)
VARSET_TO_LIST(., hidden)
VARSET_TO_LIST(., starting_node)
VARSET_TO_LIST(., assoc_to_keys(prereq_ids))
VARSET_TO_LIST(., assoc_to_keys(design_ids))
VARSET_TO_LIST(., assoc_to_keys(unlock_ids))
VARSET_TO_LIST(., boost_item_paths)
VARSET_TO_LIST(., autounlock_by_boost)
VARSET_TO_LIST(., research_costs)
VARSET_TO_LIST(., category)
VARSET_TO_LIST(., required_experiments)
VARSET_TO_LIST(., discount_used)
/datum/techweb_node/deserialize_list(list/input, list/options)
if(!input["id"])
return
VARSET_FROM_LIST(input, id)
VARSET_FROM_LIST(input, display_name)
VARSET_FROM_LIST(input, hidden)
VARSET_FROM_LIST(input, starting_node)
VARSET_FROM_LIST(input, prereq_ids)
VARSET_FROM_LIST(input, design_ids)
VARSET_FROM_LIST(input, unlock_ids)
VARSET_FROM_LIST(input, boost_item_paths)
VARSET_FROM_LIST(input, autounlock_by_boost)
VARSET_FROM_LIST(input, research_costs)
VARSET_FROM_LIST(input, category)
VARSET_FROM_LIST(input, required_experiments)
VARSET_FROM_LIST(input, discount_used)
Initialize()
return src
/datum/techweb_node/proc/on_design_deletion(datum/design/D)
prune_design_id(D.id)
/datum/techweb_node/proc/on_node_deletion(datum/techweb_node/TN)
prune_node_id(TN.id)
/datum/techweb_node/proc/prune_design_id(design_id)
design_ids -= design_id
/datum/techweb_node/proc/prune_node_id(node_id)
prereq_ids -= node_id
unlock_ids -= node_id
/datum/techweb_node/proc/get_price(datum/techweb/host)
if(host)
var/list/actual_costs = research_costs
if(host.boosted_nodes[id])
var/list/boostlist = host.boosted_nodes[id]
for(var/booster in boostlist)
if(actual_costs[booster])
actual_costs[booster] -= boostlist[booster]
for(var/cost_type in actual_costs)
for(var/experiment_type in discount_experiments)
if(host.completed_experiments[experiment_type] && !discount_used[experiment_type]) //do we have this discount_experiment unlocked AND it wasn't applied already?
actual_costs[cost_type] -= discount_experiments[experiment_type]
discount_used[experiment_type] = experiment_type
return actual_costs
else
return research_costs
/datum/techweb_node/proc/price_display(datum/techweb/TN)
return techweb_point_display_generic(get_price(TN))
/datum/techweb_node/proc/on_research() //new proc, not currently in file
return