Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ported the Microlathe from Bay, and began autolathe refactor #19839

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions aurorastation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include "code\__DEFINES\emitter.dm"
#include "code\__DEFINES\empulse.dm"
#include "code\__DEFINES\evacuation.dm"
#include "code\__DEFINES\fabricators.dm"
#include "code\__DEFINES\feedback.dm"
#include "code\__DEFINES\flags.dm"
#include "code\__DEFINES\fonts.dm"
Expand Down Expand Up @@ -391,6 +392,7 @@
#include "code\controllers\subsystems\initialization\atlas.dm"
#include "code\controllers\subsystems\initialization\atoms.dm"
#include "code\controllers\subsystems\initialization\codex.dm"
#include "code\controllers\subsystems\initialization\fabrication.dm"
#include "code\controllers\subsystems\initialization\holomap.dm"
#include "code\controllers\subsystems\initialization\map_finalization.dm"
#include "code\controllers\subsystems\initialization\misc_early.dm"
Expand Down Expand Up @@ -585,10 +587,10 @@
#include "code\datums\wires\airlock.dm"
#include "code\datums\wires\alarm.dm"
#include "code\datums\wires\apc.dm"
#include "code\datums\wires\autolathe.dm"
#include "code\datums\wires\camera.dm"
#include "code\datums\wires\disposals.dm"
#include "code\datums\wires\explosive.dm"
#include "code\datums\wires\fabricator.dm"
#include "code\datums\wires\iff.dm"
#include "code\datums\wires\ipc_tag_scanner.dm"
#include "code\datums\wires\landmine.dm"
Expand Down Expand Up @@ -969,17 +971,6 @@
#include "code\game\machinery\atmoalter\portable_atmospherics.dm"
#include "code\game\machinery\atmoalter\pump.dm"
#include "code\game\machinery\atmoalter\scrubber.dm"
#include "code\game\machinery\autolathe\autolathe.dm"
#include "code\game\machinery\autolathe\autolathe_datums.dm"
#include "code\game\machinery\autolathe\designs\ammunition.dm"
#include "code\game\machinery\autolathe\designs\armaments.dm"
#include "code\game\machinery\autolathe\designs\components.dm"
#include "code\game\machinery\autolathe\designs\dinnerware.dm"
#include "code\game\machinery\autolathe\designs\engineering.dm"
#include "code\game\machinery\autolathe\designs\general.dm"
#include "code\game\machinery\autolathe\designs\materials.dm"
#include "code\game\machinery\autolathe\designs\medical.dm"
#include "code\game\machinery\autolathe\designs\tools.dm"
#include "code\game\machinery\bots\bots.dm"
#include "code\game\machinery\camera\camera.dm"
#include "code\game\machinery\camera\camera_assembly.dm"
Expand Down Expand Up @@ -2199,6 +2190,24 @@
#include "code\modules\events\visitor.dm"
#include "code\modules\events\wallrot.dm"
#include "code\modules\ext_scripts\python.dm"
#include "code\modules\fabrication\_fabricator.dm"
#include "code\modules\fabrication\_fabricator_build_order.dm"
#include "code\modules\fabrication\fabricator_build.dm"
#include "code\modules\fabrication\fabricator_hacked.dm"
#include "code\modules\fabrication\fabricator_intake.dm"
#include "code\modules\fabrication\fabricator_microlathe.dm"
#include "code\modules\fabrication\designs\_design.dm"
#include "code\modules\fabrication\designs\general\designs_ammo.dm"
#include "code\modules\fabrication\designs\general\designs_arms.dm"
#include "code\modules\fabrication\designs\general\designs_devices.dm"
#include "code\modules\fabrication\designs\general\designs_engineering.dm"
#include "code\modules\fabrication\designs\general\designs_general.dm"
#include "code\modules\fabrication\designs\general\designs_materials.dm"
#include "code\modules\fabrication\designs\general\designs_medical.dm"
#include "code\modules\fabrication\designs\general\designs_tools.dm"
#include "code\modules\fabrication\designs\micro\designs_cutlery.dm"
#include "code\modules\fabrication\designs\micro\designs_dinnerware.dm"
#include "code\modules\fabrication\designs\micro\designs_glasses.dm"
#include "code\modules\flufftext\Dreaming.dm"
#include "code\modules\flufftext\TextFilters.dm"
#include "code\modules\games\cardemon.dm"
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/fabricators.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define FABRICATOR_CLASS_GENERAL "general"
#define FABRICATOR_CLASS_MICRO "microlathe"
6 changes: 6 additions & 0 deletions code/__DEFINES/machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
#define MAINT 0x8 // Under maintenance.
#define EMPED 0x10 // Temporary broken by EMP pulse.

#define FABRICATOR_EXTRA_COST_FACTOR 1.25
#define FAB_HACKED BITFLAG(0)
#define FAB_DISABLED BITFLAG(1)
#define FAB_SHOCKED BITFLAG(2)
#define FAB_BUSY BITFLAG(3)

#define INOPERABLE(machine) (machine.stat & (BROKEN|NOPOWER|MAINT|EMPED))
#define OPERABLE(machine) !INOPERABLE(machine)

Expand Down
85 changes: 85 additions & 0 deletions code/controllers/subsystems/initialization/fabrication.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
SUBSYSTEM_DEF(fabrication)
name = "Fabrication"
flags = SS_NO_FIRE
init_order = INIT_ORDER_MISC

/**
* List of lists(Strings => Paths - Subtypes of `/singsingleton/fabricator_recipe`). Global list of fabricator recipes. Set during `Initialize()`.
*
* Example formatting:
* ```dm
* list(
* "general" = list(
* /singleton/fabricator_recipe/A,
* /singleton/fabricator_recipe/B
* ),
* "microlathe" = list(
* /singleton/fabricator_recipe/C,
* /singleton/fabricator_recipe/D
* )
* )
* ```
*/
var/list/recipes = list()

/**
* List of lists (Strings => Strings). Global list of recipe categories. These are pulled from the recipes provided in `recipes`. Set during `Initialize()`.
*
* Example formatting:
* ```dm
* list(
* "general" = list(
* "Arms and Ammunition",
* "Devices and Components"
* ),
* "microlathe" = list(
* "Cutlery",
* "Drinking Glasses"
* )
* )
* ```
*/
var/list/categories = list()

/datum/controller/subsystem/fabrication/Initialize()
for(var/singleton/fabricator_recipe/recipe in GET_SINGLETON_SUBTYPE_LIST(/singleton/fabricator_recipe))
if(is_abstract(recipe))
continue
if(!recipe.name)
continue
for(var/type in recipe.fabricator_types)
if(!recipes[type])
recipes[type] = list()
recipes[type] += recipe
if (!categories[type])
categories[type] = list()
categories[type] |= recipe.category
var/obj/item/I = new recipe.path
if(I.matter && !recipe.resources) //This can be overidden in the datums.
recipe.resources = list()
for(var/material in I.matter)
recipe.resources[material] = I.matter[material] * FABRICATOR_EXTRA_COST_FACTOR
qdel(I)
return SS_INIT_SUCCESS

/**
* Retrieves a list of categories for the given root type.
*
* **Parameters**:
* - `type` - The root type to fetch from the `categories` list.
*
* Returns list of strings. The categories associated with the given root type.
*/
/datum/controller/subsystem/fabrication/proc/get_categories(type)
return categories[type]

/**
* Retrieves a list of recipes for the given root type.
*
* **Parameters**:
* - `type` - The root type to fetch from the `recipes` list.
*
* Returns list of paths (`/singleton/fabricator_recipe`). The recipes associated with the given root type.
*/
/datum/controller/subsystem/fabrication/proc/get_recipes(type)
return recipes[type]
60 changes: 0 additions & 60 deletions code/datums/wires/autolathe.dm

This file was deleted.

78 changes: 78 additions & 0 deletions code/datums/wires/fabricator.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/datum/wires/fabricator
proper_name = "Fabricator"
holder_type = /obj/machinery/fabricator

/datum/wires/fabricator/New(atom/holder)
wires = list(
WIRE_HACK, WIRE_DISABLE,
WIRE_SHOCK
)
add_duds(2)
..()

/datum/wires/fabricator/get_status()
var/obj/machinery/fabricator/A = holder
. = ..()
. += "\The [A] [(A.fab_status_flags & FAB_DISABLED) ? "is dead quiet" : "has a soft electric whirr"]."
. += "\The [A] [(A.fab_status_flags & FAB_SHOCKED) ? "is making sparking noises" : "is cycling normally"]."
. += "\The [A] [(A.fab_status_flags & FAB_HACKED) ? "rarely" : "occasionally"] makes a beep boop noise."

/datum/wires/fabricator/interactable(mob/user)
if(!..())
return FALSE
var/obj/machinery/fabricator/A = holder
if(A.panel_open)
return TRUE
return FALSE

/datum/wires/fabricator/on_cut(wire, mend, source)
var/obj/machinery/fabricator/A = holder
switch(wire)
if(WIRE_HACK)
if(mend)
A.fab_status_flags &= ~FAB_HACKED
else
A.fab_status_flags |= FAB_HACKED
if(WIRE_SHOCK)
if(mend)
A.fab_status_flags &= ~FAB_SHOCKED
else
A.fab_status_flags |= FAB_SHOCKED
if(WIRE_DISABLE)
if(mend)
A.fab_status_flags &= ~FAB_DISABLED
else
A.fab_status_flags |= FAB_DISABLED

/datum/wires/fabricator/on_pulse(wire)
if(is_cut(wire))
return
var/obj/machinery/fabricator/A = holder
switch(wire)
if(WIRE_HACK)
if(A.fab_status_flags & FAB_HACKED)
A.fab_status_flags &= ~FAB_HACKED
else
A.fab_status_flags |= FAB_HACKED
spawn(50)
if(A && !is_cut(wire))
A.fab_status_flags &= ~FAB_HACKED
interact(usr)
if(WIRE_SHOCK)
if(A.fab_status_flags & FAB_SHOCKED)
A.fab_status_flags &= ~FAB_SHOCKED
else
A.fab_status_flags |= FAB_SHOCKED
spawn(50)
if(A && !is_cut(wire))
A.fab_status_flags &= ~FAB_SHOCKED
interact(usr)
if(WIRE_DISABLE)
if(A.fab_status_flags & FAB_DISABLED)
A.fab_status_flags &= ~FAB_DISABLED
else
A.fab_status_flags |= FAB_DISABLED
spawn(50)
if(A && !is_cut(wire))
A.fab_status_flags &= ~FAB_DISABLED
interact(usr)
Loading
Loading