Skip to content

Commit

Permalink
[MIRROR] TGUI Destructive Analyzer [MDB IGNORE] (#25005)
Browse files Browse the repository at this point in the history
* TGUI Destructive Analyzer (#79572)

## About The Pull Request

I made this to help me move more towards my goals [laid out
here](https://hackmd.io/XLt5MoRvRxuhFbwtk4VAUA) which currently doesn't
have much interest.

This makes the Destructive Analyzer use a little neat TGUI menu instead
of its old HTML one. I also touch a lot of science stuff and a little
experimentor stuff, so let me explain a bit:
Old iterations of Science had different items that you can use to boost
nodes through deconstruction. This has been removed, and its only
feature is the auto-unlocking of nodes (that is; making them visible to
the R&D console). I thought that instead of keeping this deprecated code
around, I would rework it a little to make it clear what we actually use
it for (unhiding nodes).
All vars and procs that mentioned this have been renamed or reworked to
make more sense now.

Experimentor stuff shares a lot with the destructive analyzer, so I had
to mess with that a bit to keep its decayed corpse of deprecated code,
functional.

I also added context tips to the destructive analyzer, and added the
ability to AltClick to remove the inserted item. Removing items now also
plays a little sound because it was kinda lame.
Also, balloon alerts.

## Why It's Good For The Game

Moves a shitty machine to TGUI so it is slightly less shitty, now it's
more direct and compact with more player-feedback.
Helps me with a personal project and yea

### Video demonstration

I show off connecting the machine to R&D Servers, but I haven't changed
the behavior of that and the roundstart analyzers are connected to
servers by default.

https://github.com/tgstation/tgstation/assets/53777086/65295600-4fae-42d1-9bae-eccefe337a2b

## Changelog

:cl:
refactor: Destructive Analyzers now have a TGUI menu.
/:cl:

* TGUI Destructive Analyzer

* Modular

---------

Co-authored-by: John Willard <[email protected]>
Co-authored-by: Giz <[email protected]>
  • Loading branch information
3 people authored and FFMirrorBot committed Nov 14, 2023
1 parent 3517791 commit 0cfde8c
Show file tree
Hide file tree
Showing 17 changed files with 374 additions and 323 deletions.
4 changes: 0 additions & 4 deletions code/__DEFINES/research.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#define RDSCREEN_NOBREAK "<NO_HTML_BREAK>"

/// For instances where we don't want a design showing up due to it being for debug/sanity purposes
#define DESIGN_ID_IGNORE "IGNORE_THIS_DESIGN"

#define RESEARCH_MATERIAL_DESTROY_ID "__destroy"

//! Techweb names for new point types. Can be used to define specific point values for specific types of research (science, security, engineering, etc.)
#define TECHWEB_POINT_TYPE_GENERIC "General Research"

Expand Down
42 changes: 15 additions & 27 deletions code/controllers/subsystem/research.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ SUBSYSTEM_DEF(research)
var/list/techweb_nodes_starting = list()
///category name = list(node.id = TRUE)
var/list/techweb_categories = list()
///associative double-layer path = list(id = list(point_type = point_discount))
var/list/techweb_boost_items = list()
///List of all items that can unlock a node. (node.id = list(items))
var/list/techweb_unlock_items = list()
///Node ids that should be hidden by default.
var/list/techweb_nodes_hidden = list()
///Node ids that are exclusive to the BEPIS.
var/list/techweb_nodes_experimental = list()
///path = list(point type = value)
var/list/techweb_point_items = list(
/obj/item/assembly/signaler/anomaly = list(TECHWEB_POINT_TYPE_GENERIC = 10000)
/obj/item/assembly/signaler/anomaly = list(TECHWEB_POINT_TYPE_GENERIC = 10000)
)
var/list/errored_datums = list()
var/list/point_types = list() //typecache style type = TRUE list
Expand Down Expand Up @@ -64,7 +64,7 @@ SUBSYSTEM_DEF(research)
/// Lookup list for ordnance briefers.
var/list/ordnance_experiments = list()
/// Lookup list for scipaper partners.
var/list/scientific_partners = list()
var/list/datum/scientific_partner/scientific_partners = list()

/datum/controller/subsystem/research/Initialize()
point_types = TECHWEB_POINT_TYPE_LIST_ASSOCIATIVE_NAMES
Expand Down Expand Up @@ -153,7 +153,7 @@ SUBSYSTEM_DEF(research)
if (!verify_techweb_nodes()) //Verify all nodes have ids and such.
stack_trace("Invalid techweb nodes detected")
calculate_techweb_nodes()
calculate_techweb_boost_list()
calculate_techweb_item_unlocking_requirements()
if (!verify_techweb_nodes()) //Verify nodes and designs have been crosslinked properly.
CRASH("Invalid techweb nodes detected")

Expand Down Expand Up @@ -209,25 +209,15 @@ SUBSYSTEM_DEF(research)
N.unlock_ids -= u
research_node_id_error(u)
. = FALSE
for(var/p in N.boost_item_paths)
for(var/p in N.required_items_to_unlock)
if(!ispath(p))
N.boost_item_paths -= p
N.required_items_to_unlock -= p
WARNING("[p] is not a valid path.")
node_boost_error(N.id, "[p] is not a valid path.")
. = FALSE
var/list/points = N.boost_item_paths[p]
if(islist(points))
for(var/i in points)
if(!isnum(points[i]))
WARNING("[points[i]] is not a valid number.")
node_boost_error(N.id, "[points[i]] is not a valid number.")
. = FALSE
else if(!point_types[i])
WARNING("[i] is not a valid point type.")
node_boost_error(N.id, "[i] is not a valid point type.")
. = FALSE
else if(!isnull(points))
N.boost_item_paths -= p
var/list/points = N.required_items_to_unlock[p]
if(!isnull(points))
N.required_items_to_unlock -= p
node_boost_error(N.id, "No valid list.")
WARNING("No valid list.")
. = FALSE
Expand Down Expand Up @@ -281,18 +271,16 @@ SUBSYSTEM_DEF(research)
var/datum/techweb_node/prereq_node = techweb_node_by_id(prereq_id)
prereq_node.unlock_ids[node.id] = node

/datum/controller/subsystem/research/proc/calculate_techweb_boost_list(clearall = FALSE)
if(clearall)
techweb_boost_items = list()
/datum/controller/subsystem/research/proc/calculate_techweb_item_unlocking_requirements()
for(var/node_id in techweb_nodes)
var/datum/techweb_node/node = techweb_nodes[node_id]
for(var/path in node.boost_item_paths)
for(var/path in node.required_items_to_unlock)
if(!ispath(path))
continue
if(length(techweb_boost_items[path]))
techweb_boost_items[path][node.id] = node.boost_item_paths[path]
if(length(techweb_unlock_items[path]))
techweb_unlock_items[path][node.id] = node.required_items_to_unlock[path]
else
techweb_boost_items[path] = list(node.id = node.boost_item_paths[path])
techweb_unlock_items[path] = list(node.id = node.required_items_to_unlock[path])
CHECK_TICK

/datum/controller/subsystem/research/proc/populate_ordnance_experiments()
Expand Down
5 changes: 1 addition & 4 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
///Separator between the items on the list
var/sep = ""
///Nodes that can be boosted
var/list/boostable_nodes = techweb_item_boost_check(src)
var/list/boostable_nodes = techweb_item_unlock_check(src)
if (boostable_nodes)
for(var/id in boostable_nodes)
var/datum/techweb_node/node = SSresearch.techweb_node_by_id(id)
Expand Down Expand Up @@ -618,9 +618,6 @@
R.activate_module(src)
R.hud_used.update_robot_modules_display()

/obj/item/proc/GetDeconstructableContents()
return get_all_contents() - src

// afterattack() and attack() prototypes moved to _onclick/item_attack.dm for consistency

/obj/item/proc/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK, damage_type = BRUTE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,8 @@
req_components = list(
/datum/stock_part/scanning_module = 1,
/datum/stock_part/servo = 1,
/datum/stock_part/micro_laser = 1)
/datum/stock_part/micro_laser = 1,
)

/obj/item/circuitboard/machine/experimentor
name = "E.X.P.E.R.I-MENTOR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
singular_partner["path"] = partner.type
singular_partner["boostedNodes"] = list()
singular_partner["acceptedExperiments"] = list()
for (var/node_id in partner.boosted_nodes)
for (var/node_id in partner.boostable_nodes)
var/datum/techweb_node/node = SSresearch.techweb_node_by_id(node_id)
singular_partner["boostedNodes"] += list(list("name" = node.display_name, "discount" = partner.boosted_nodes[node_id], "id"=node_id))
singular_partner["boostedNodes"] += list(list("name" = node.display_name, "discount" = partner.boostable_nodes[node_id], "id" = node_id))
for (var/datum/experiment/ordnance/ordnance_experiment as anything in partner.accepted_experiments)
singular_partner["acceptedExperiments"] += initial(ordnance_experiment.name)
parsed_partners += list(singular_partner)
Expand Down Expand Up @@ -154,7 +154,7 @@
data["purchaseableBoosts"][partner.type] = list()
for(var/node_id in linked_techweb.get_available_nodes())
// Not from our partner
if(!(node_id in partner.boosted_nodes))
if(!(node_id in partner.boostable_nodes))
continue
if(!partner.allowed_to_boost(linked_techweb, node_id))
continue
Expand Down
Loading

0 comments on commit 0cfde8c

Please sign in to comment.