mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 13:38:41 +01:00
Research queue (#84731)
## About The Pull Request <img alt="2dZbpr8MK1" src="https://github.com/tgstation/tgstation/assets/3625094/dd78feba-224a-41a1-8d4a-83af3a8b68df"> Added an ability to queue up to one node per player in a techweb for an automatic research. You can queue up a node only when all requirements are met, but there are not enough points. People can't research when there is something in the queue, only add things to the queue. So a 40 points node can't be researched if someone queued up a 200 points node ahead of it. When a node is enqueued by RD, it is placed in front of the queue. The research button is available when the queue is empty. TODO: - [x] Bypass queue when the node cost is zero ## Why It's Good For The Game No need to stay at the console to wait for the points. No "Research" button spamming. ## Changelog 🆑 qol: Research nodes can be queued, one per player. RDs can place their node at the beginning of the queue. /🆑
This commit is contained in:
@@ -70,6 +70,12 @@
|
||||
* Filled with nulls on init, populated only on publication.
|
||||
*/
|
||||
var/list/published_papers
|
||||
/**
|
||||
* Assoc list of nodes queued for automatic research when there are enough points available
|
||||
* research_queue_nodes[node_id] = user_enqueued
|
||||
*/
|
||||
var/list/research_queue_nodes = list()
|
||||
|
||||
|
||||
/datum/techweb/New()
|
||||
SSresearch.techwebs += src
|
||||
@@ -325,6 +331,40 @@
|
||||
/datum/techweb/proc/printout_points()
|
||||
return techweb_point_display_generic(research_points)
|
||||
|
||||
/datum/techweb/proc/enqueue_node(id, mob/user)
|
||||
var/mob/living/carbon/human/human_user = user
|
||||
var/is_rd = FALSE
|
||||
if(human_user.wear_id)
|
||||
var/list/access = human_user.wear_id.GetAccess()
|
||||
if(ACCESS_RD in access)
|
||||
is_rd = TRUE
|
||||
|
||||
if(id in research_queue_nodes)
|
||||
if(is_rd)
|
||||
research_queue_nodes.Remove(id)
|
||||
else
|
||||
return FALSE
|
||||
|
||||
for(var/node_id in research_queue_nodes)
|
||||
if(research_queue_nodes[node_id] == user)
|
||||
research_queue_nodes.Remove(node_id)
|
||||
|
||||
if (is_rd)
|
||||
research_queue_nodes.Insert(1, id)
|
||||
research_queue_nodes[id] = user
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/techweb/proc/dequeue_node(id, mob/user)
|
||||
if(!(id in research_queue_nodes))
|
||||
return FALSE
|
||||
if(research_queue_nodes[id] != user)
|
||||
return FALSE
|
||||
|
||||
research_queue_nodes.Remove(id)
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/techweb/proc/research_node_id(id, force, auto_update_points, get_that_dosh_id)
|
||||
return research_node(SSresearch.techweb_node_by_id(id), force, auto_update_points, get_that_dosh_id)
|
||||
|
||||
@@ -377,6 +417,10 @@
|
||||
if (MC_RUNNING())
|
||||
log_research(log_message)
|
||||
|
||||
// Dequeue
|
||||
if(node.id in research_queue_nodes)
|
||||
research_queue_nodes.Remove(node.id)
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/techweb/proc/unresearch_node_id(id)
|
||||
|
||||
@@ -95,6 +95,17 @@
|
||||
|
||||
return actual_costs
|
||||
|
||||
/datum/techweb_node/proc/is_free(datum/techweb/host)
|
||||
var/list/costs = get_price(host)
|
||||
var/total_points = 0
|
||||
|
||||
for(var/point_type in costs)
|
||||
total_points += costs[point_type]
|
||||
|
||||
if(total_points == 0)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/datum/techweb_node/proc/price_display(datum/techweb/TN)
|
||||
return techweb_point_display_generic(get_price(TN))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user