Autolathe, protolathe, mech fab and comp printer now use defines for matter bins values. Also some production ui do. (#76020)

Changed hardcoded matter bins values to use defined
`SHEET_MATERIAL_AMOUNT` for following stuff: autolathe, protolathe, mech
fabricator and component printer.

`Material Access Bar` and `MaterialIcon` used for protolathes, circuit
printers and etc. now also use defined `SHEET_MATERIAL_AMOUNT`, via
static ui data, to prevent same issues in future.

Also changed some notes in /// parts just because why not.
This commit is contained in:
Helg2
2023-06-21 04:08:51 +03:00
committed by GitHub
parent 76abc6bf6b
commit 8a2e6f0eb8
13 changed files with 45 additions and 20 deletions
@@ -537,6 +537,11 @@
mat = GET_MATERIAL_REF(mat)
return materials[mat]
/datum/component/material_container/ui_static_data(mob/user)
var/list/data = list()
data["SHEET_MATERIAL_AMOUNT"] = SHEET_MATERIAL_AMOUNT
return data
/// List format is list(material_name = list(amount = ..., ref = ..., etc.))
/datum/component/material_container/ui_data(mob/user)
var/list/data = list()
+1 -1
View File
@@ -341,7 +341,7 @@
. = ..()
var/mat_capacity = 0
for(var/datum/stock_part/matter_bin/new_matter_bin in component_parts)
mat_capacity += new_matter_bin.tier * 75000
mat_capacity += new_matter_bin.tier * (37.5*SHEET_MATERIAL_AMOUNT)
var/datum/component/material_container/materials = GetComponent(/datum/component/material_container)
materials.max_amount = mat_capacity
+1 -1
View File
@@ -1,5 +1,5 @@
/datum/export/material
cost = 5 // Cost per SHEET_MATERIAL_AMOUNT, which is 2000cm3 as of April 2016.
cost = 5 // Cost per SHEET_MATERIAL_AMOUNT, which is 100cm3 as of May 2023.
message = "cm3 of developer's tears. Please, report this on github"
amount_report_multiplier = SHEET_MATERIAL_AMOUNT
var/material_id = null
+1 -1
View File
@@ -65,7 +65,7 @@
// For base materials, see materials.dm
/datum/export/stack/plasteel
cost = CARGO_CRATE_VALUE * 0.41 // 2000u of plasma + 2000u of iron.
cost = CARGO_CRATE_VALUE * 0.41 // 100u of plasma + 100u of iron.
message = "of plasteel"
export_types = list(/obj/item/stack/sheet/plasteel)
+1 -1
View File
@@ -192,7 +192,7 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
* - action: Text that visually describes the action (smelted/deposited/resupplied...)
* - amount: The amount of sheets/objects deposited/withdrawn by this action. Positive for depositing, negative for withdrawing.
* - noun: Name of the object the action was performed with (sheet, units, ore...)
* - [mats][list]: Assoc list in format (material datum = amount of raw materials). Wants the actual amount of raw (iron, glass...) materials involved in this action. If you have 10 metal sheets each worth 2000 iron you would pass a list with the iron material datum = 20000
* - [mats][list]: Assoc list in format (material datum = amount of raw materials). Wants the actual amount of raw (iron, glass...) materials involved in this action. If you have 10 metal sheets each worth 100 iron you would pass a list with the iron material datum = 1000
*/
/obj/machinery/ore_silo/proc/silo_log(obj/machinery/M, action, amount, noun, list/mats)
if (!length(mats))
@@ -75,7 +75,7 @@
* Associated list of items able to be sold to the NPC with the money given for them.
* The price given should be the "base" price; any price manipulation based on variables should be done with apply_sell_price_mods()
* ADDITIONAL_DESCRIPTION is any additional text added to explain how the variables of the item effect the price; if it's stack based, it's final price depends how much is in the stack
* EX; /obj/item/stack/sheet/mineral/diamond = list(500, INFINITY, ", per 2000 cm3 sheet of diamond")
* EX; /obj/item/stack/sheet/mineral/diamond = list(500, INFINITY, ", per 100 cm3 sheet of diamond")
* This list is filled by Initialize(), if you want to change the starting wanted items, modify initial_wanteds()
*/
var/list/wanted_items
+2 -2
View File
@@ -6,13 +6,13 @@
For the materials datum, it assumes you need reagents unless specified otherwise. To designate a material that isn't a reagent,
you use one of the material IDs below. These are NOT ids in the usual sense (they aren't defined in the object or part of a datum),
they are simply references used as part of a "has materials?" type proc. They all start with a $ to denote that they aren't reagents.
The currently supporting non-reagent materials. All material amounts are set as the define SHEET_MATERIAL_AMOUNT, which defaults to 2000
The currently supporting non-reagent materials. All material amounts are set as the define SHEET_MATERIAL_AMOUNT, which defaults to 100
Don't add new keyword/IDs if they are made from an existing one (such as rods which are made from iron). Only add raw materials.
Design Guidelines
- When adding new designs, check rdreadme.dm to see what kind of things have already been made and where new stuff is needed.
- A single sheet of anything is 2000 units of material. Materials besides iron/glass require help from other jobs (mining for
- A single sheet of anything is 100 units of material. Materials besides iron/glass require help from other jobs (mining for
other types of metals and chemistry for reagents).
- Add the AUTOLATHE tag to
*/
@@ -121,7 +121,12 @@
ui.open()
/obj/machinery/rnd/production/ui_static_data(mob/user)
var/list/data = list()
var/list/data
if(isnull(materials.mat_container))
data = list()
else
data = materials.mat_container.ui_static_data()
var/list/designs = list()
var/datum/asset/spritesheet/research_designs/spritesheet = get_asset_datum(/datum/asset/spritesheet/research_designs)
@@ -201,7 +206,7 @@
var/total_storage = 0
for(var/datum/stock_part/matter_bin/bin in component_parts)
total_storage += bin.tier * 75000
total_storage += bin.tier * (37.5*SHEET_MATERIAL_AMOUNT)
materials.set_local_size(total_storage)
@@ -92,7 +92,7 @@
//maximum stocking amount (default 300000, 600000 at T4)
for(var/datum/stock_part/matter_bin/matter_bin in component_parts)
T += matter_bin.tier
rmat.set_local_size((200000 + (T * 50000)))
rmat.set_local_size(((100*SHEET_MATERIAL_AMOUNT) + (T * (25*SHEET_MATERIAL_AMOUNT))))
//resources adjustment coefficient (1 -> 0.85 -> 0.7 -> 0.55)
T = 1.15
@@ -90,7 +90,7 @@
var/total_storage = 0
for(var/datum/stock_part/matter_bin/bin in component_parts)
total_storage += bin.tier * 75000
total_storage += bin.tier * (37.5*SHEET_MATERIAL_AMOUNT)
materials.set_local_size(total_storage)
@@ -343,7 +343,7 @@
var/total_storage = 0
for(var/datum/stock_part/matter_bin/bin in component_parts)
total_storage += bin.tier * 75000
total_storage += bin.tier * (37.5*SHEET_MATERIAL_AMOUNT)
materials.set_local_size(total_storage)
@@ -1,6 +1,6 @@
import { sortBy } from 'common/collections';
import { classes } from 'common/react';
import { useLocalState } from '../../backend';
import { useLocalState, useBackend } from '../../backend';
import { Flex, Button, Stack, AnimatedNumber } from '../../components';
import { formatSiUnit } from '../../format';
import { MaterialIcon } from './MaterialIcon';
@@ -72,6 +72,8 @@ type MaterialCounterProps = {
const MaterialCounter = (props: MaterialCounterProps, context) => {
const { material, onEjectRequested } = props;
const { data } = useBackend<Material>(context);
const { SHEET_MATERIAL_AMOUNT } = data;
const [hovering, setHovering] = useLocalState(
context,
@@ -79,7 +81,7 @@ const MaterialCounter = (props: MaterialCounterProps, context) => {
false
);
const canEject = material.amount > 2_000;
const canEject = material.amount > SHEET_MATERIAL_AMOUNT;
return (
<div
@@ -150,6 +152,8 @@ type EjectButtonProps = {
const EjectButton = (props: EjectButtonProps, context) => {
const { amount, available, material, onEject } = props;
const { data } = useBackend<Material>(context);
const { SHEET_MATERIAL_AMOUNT } = data;
return (
<Button
@@ -157,7 +161,8 @@ const EjectButton = (props: EjectButtonProps, context) => {
color={'transparent'}
className={classes([
'Fabricator__PrintAmount',
amount * 2_000 > available && 'Fabricator__PrintAmount--disabled',
amount * SHEET_MATERIAL_AMOUNT > available &&
'Fabricator__PrintAmount--disabled',
])}
onClick={() => onEject(amount)}>
&times;{amount}
@@ -1,5 +1,7 @@
import { classes } from 'common/react';
import { Icon } from '../../components';
import { Material } from './Types';
import { useBackend } from '../../backend';
const MATERIAL_ICONS: Record<string, [number, string][]> = {
'iron': [
@@ -62,8 +64,8 @@ export type MaterialIconProps = {
materialName: string;
/**
* The amount of material. One sheet is 2,000 units. By default, the icon
* attempts to render a full stack (200,000 units).
* The amount of material. One sheet is 100 units. By default, the icon
* attempts to render a full stack (5,000 units).
*/
amount?: number;
};
@@ -72,9 +74,11 @@ export type MaterialIconProps = {
* A 32x32 material icon. Animates between different stack sizes of the given
* material.
*/
export const MaterialIcon = (props: MaterialIconProps) => {
export const MaterialIcon = (props: MaterialIconProps, context) => {
const { materialName, amount } = props;
const icons = MATERIAL_ICONS[materialName];
const { data } = useBackend<Material>(context);
const { SHEET_MATERIAL_AMOUNT } = data;
if (!icons) {
return <Icon name="question-circle" />;
@@ -84,7 +88,8 @@ export const MaterialIcon = (props: MaterialIconProps) => {
while (
icons[activeIdx + 1] &&
icons[activeIdx + 1][0] <= (amount ?? 200_000) / 2_000
icons[activeIdx + 1][0] <=
(amount ?? 50 * SHEET_MATERIAL_AMOUNT) / SHEET_MATERIAL_AMOUNT
) {
activeIdx += 1;
}
@@ -21,10 +21,15 @@ export type Material = {
ref: string;
/**
* The amount of material; 2,000 units is one sheet.
* The amount of material; 100 units is one sheet.
*/
amount: number;
/**
* Definition of how much units 1 sheet has.
*/
SHEET_MATERIAL_AMOUNT: number;
/**
* The number of sheets.
*/