Files
Aurora.3/code/modules/cargo/items/cargo_items.dm
naut 55f4e12614 Codeside Cargo Refactor (#20030)
**NOTE TO SYSADMINS: See "SQL Details" section below for information on
SQL modifications.**

Moves the data containing cargo items (i.e. the ones you order from ops
and get in the cargo shuttle) from the online database to the codebase.
Everything from suppliers to categories to individual items is now
code-side and editable by developers/contributors.

Refactors cargo items to use `singletons` instead of `datums` for
`cargo_supplier`, `cargo_category`, and `cargo_item`. Multiple-instnace
things like cargo_orders, etc. still use `datums`.

Fixed a bunch of strange discrepancies in categories, suppliers, and
pricing for various cargo items. I did a little bit, but it's exhausting
to go through all of it right now.

Clicking the 'Details' button on the Cargo Order app now actually gives
you details instead of bluescreening. Also added some UI elements to the
Cargo Order app - Cargo Control and Delivery remain untouched.

Overhauled the Cargo Order console TGUI window. It now has tabs on the
left, displays restricted access, supplier information, and boasts
search functionality.

### SQL Details
<details>
<summary>SQL Details [Click to Expand]</summary>

The following SQL tables should be deleted or deprecated from the server
database, as they are no longer in use:

- `ss13_cargo_items`
- `ss13_cargo_categories`
- `ss13_cargo_suppliers`

The included migration file, `V011__codeside_cargo`, creates a new table
`ss13_cargo_item_orderlog` to the DB. This **replaces**
`ss13_cargo_orderlog_items`. Because of this,
`ss13_cargo_orderlog_items` is deprecated and should either be deleted
or locked & preserved for logging purposes.

</details>

## Screenshots


![image](https://github.com/user-attachments/assets/79129923-1fb6-4cee-ac8d-5505a52270a4)

![image](https://github.com/user-attachments/assets/a323be35-8ce6-4ec4-98f7-ee701d0931a3)

![image](https://github.com/user-attachments/assets/5ddb02c5-152f-4715-b2da-20903fa11c93)

![image](https://github.com/user-attachments/assets/420e45b0-6a9f-4420-beb8-a2c8423a5be4)

![image](https://github.com/user-attachments/assets/114f4755-ee51-41e6-8670-07aacc5326ae)

---------

Signed-off-by: naut <55491249+nauticall@users.noreply.github.com>
Co-authored-by: Fluffy <65877598+FluffyGhoster@users.noreply.github.com>
2025-03-04 18:18:00 +00:00

55 lines
2.4 KiB
Plaintext

/// Master singleton for cargo items. Contains data relating to what a cargo item spawns, price, desc, supplier, access, etc.
/singleton/cargo_item
/// The category this item belongs to. This MUST match the cargo_category "name" this item belongs to.
var/category = "miscellaneous"
/// The name of the item.
var/name = "generic cargo item"
/// The category this item belongs to. This MUST match the cargo_supplier "short_name" this item belongs to.
var/supplier = "generic_supplier"
/// The description of this item.
var/description = "A basic cargo item."
/// The amount of 'things' this "item" has. Defaults to 1. Change this for cargo items that have multiple objects packaged in them.
var/amount = 1
/// The base price of the item, in credits.
var/price = 1
/// The list of objects this item has. Duplicate items are handled by the "spawn_amount" variable.
var/list/items = list()
/// The req_access level required to order/open the crate.
var/access = 0
/// What kind of container this object spawns in. Valid options: "crate", "freezer", "box" (wooden box, or shipping container if restricted), and "bodybag".
var/container_type = "crate"
/// Whether or not this item can be shipped with other objects in the same crate. Switch to FALSE for large items that realistically cannot fit multiple in a container.
var/groupable = TRUE
/// How many of the given items to spawn. A value of 2 spawns double the items, 5 spawns 5x, etc. Applied to EVERYTHING in the "items" list.
var/spawn_amount = 1
/// The numerical ID of this item. Assigned automatically during initialization. DO NOT MANUALLY MODIFY.
var/id = 0
/// The adjusted price of this item. Automatically calculated during initialization. DO NOT MANUALLY MODIFY.
var/adjusted_price = 1
/// The "supplier data" of this item, containing all the data of this item's "supplier". Automatically calculated during initialization. DO NOT MANUALLY MODIFY.
var/singleton/cargo_supplier/supplier_data = /singleton/cargo_supplier/generic_supplier
/// Sets the item's adjusted_price according to different price modifiers. Returns nothing.
/singleton/cargo_item/proc/get_adjusted_price()
var/return_price = price
for(var/category_name in SScargo.cargo_categories)
var/singleton/cargo_category/cc = SScargo.get_category_by_name(category_name)
if(cc)
return_price *= cc.price_modifier
adjusted_price = return_price