[MIRROR] Research queue (#28846)

* 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.
/🆑

* Research queue

---------

Co-authored-by: Andrew <mt.forspam@gmail.com>
This commit is contained in:
SkyratBot
2024-07-15 06:35:42 +02:00
committed by GitHub
parent a0a2280f68
commit a585b40a1c
6 changed files with 195 additions and 33 deletions

View File

@@ -50,6 +50,7 @@
return data
data += list(
"nodes" = list(),
"queue_nodes" = stored_research.research_queue_nodes,
"experiments" = list(),
"researched_designs" = stored_research.researched_designs,
"points" = stored_research.research_points,
@@ -64,6 +65,10 @@
// Serialize all nodes to display
for(var/tier in stored_research.tiers)
var/datum/techweb_node/node = SSresearch.techweb_node_by_id(tier)
var/enqueued_by_user = FALSE
if((tier in stored_research.research_queue_nodes) && stored_research.research_queue_nodes[tier] == user)
enqueued_by_user = TRUE
// Ensure node is supposed to be visible
if (stored_research.hidden_nodes[tier])
@@ -71,8 +76,11 @@
data["nodes"] += list(list(
"id" = node.id,
"is_free" = node.is_free(stored_research),
"can_unlock" = stored_research.can_unlock_node(node),
"tier" = stored_research.tiers[node.id]
"have_experiments_done" = stored_research.have_experiments_for_node(node),
"tier" = stored_research.tiers[node.id],
"enqueued_by_user" = enqueued_by_user
))
// Get experiments and serialize them
@@ -111,6 +119,12 @@
if ("researchNode")
research_node(params["node_id"], usr)
return TRUE
if ("enqueueNode")
enqueue_node(params["node_id"], usr)
return TRUE
if ("dequeueNode")
dequeue_node(params["node_id"], usr)
return TRUE
/datum/computer_file/program/science/ui_static_data(mob/user)
. = list(
@@ -188,6 +202,20 @@
id_cache_seq += 1
return id_cache[id]
/datum/computer_file/program/science/proc/enqueue_node(id, mob/user)
if(!stored_research || !stored_research.available_nodes[id] || stored_research.researched_nodes[id])
computer.say("Node enqueue failed: Either no techweb is found, node is already researched or is not available!")
return FALSE
stored_research.enqueue_node(id, user)
return TRUE
/datum/computer_file/program/science/proc/dequeue_node(id, mob/user)
if(!stored_research || !stored_research.available_nodes[id] || stored_research.researched_nodes[id])
computer.say("Node dequeue failed: Either no techweb is found, node is already researched or is not available!")
return FALSE
stored_research.dequeue_node(id, user)
return TRUE
/datum/computer_file/program/science/proc/research_node(id, mob/user)
if(!stored_research || !stored_research.available_nodes[id] || stored_research.researched_nodes[id])
computer.say("Node unlock failed: Either no techweb is found, node is already researched or is not available!")