Port Integrated Electronics from Polaris (#3371)

Ports Polaris' integrated electronics system, whichallows for Roboticists & Electricians/Engineers to build custom devices and machines for a variety of purposes.
This commit is contained in:
Lohikar
2017-09-12 21:41:39 -05:00
committed by GitHub
parent ee2c01c1ec
commit e28c29a551
77 changed files with 5240 additions and 43 deletions
+28 -29
View File
@@ -2,14 +2,14 @@
/datum/controller/subsystem
// Metadata; you should define these.
name = "fire coderbus" //name of the subsystem
var/init_order = SS_INIT_MISC //order of initialization. Higher numbers are initialized first, lower numbers later. Can be decimal and negative values.
var/wait = 20 //time to wait (in deciseconds) between each call to fire(). Must be a positive integer.
var/priority = 50 //When mutiple subsystems need to run in the same tick, higher priority subsystems will run first and be given a higher share of the tick before MC_TICK_CHECK triggers a sleep
name = "fire coderbus" //name of the subsystem
var/init_order = SS_INIT_MISC //order of initialization. Higher numbers are initialized first, lower numbers later. Can be decimal and negative values.
var/wait = 20 //time to wait between each call to fire(). Must be a positive integer. In ticks if SS_TICKER, deciseconds otherwise.
var/priority = 50 //When mutiple subsystems need to run in the same tick, higher priority subsystems will run first and be given a higher share of the tick before MC_TICK_CHECK triggers a sleep.
var/flags = 0 //see MC.dm in __DEFINES Most flags must be set on world start to take full effect. (You can also restart the mc to force them to process again)
var/flags = 0 //see master_controller.dm in __defines. Most flags must be set on world start to take full effect. (You can also restart the mc to force them to process again)
//set to 0 to prevent fire() calls, mostly for admin use or subsystems that may be resumed later
//set to 0 to prevent fire() calls, mostly for admin use.
// use the SS_NO_FIRE flag instead for systems that never fire to keep it from even being added to the list
var/can_fire = TRUE
// Similar to can_fire, but intended explicitly for subsystems that are asleep. Using this var instead of can_fire
@@ -17,30 +17,30 @@
var/suspended = FALSE
// Bookkeeping variables; probably shouldn't mess with these.
var/last_fire = 0 //last world.time we called fire()
var/next_fire = 0 //scheduled world.time for next fire()
var/cost = 0 //average time to execute
var/tick_usage = 0 //average tick usage
var/tick_overrun = 0 //average tick overrun
var/state = SS_IDLE //tracks the current state of the ss, running, paused, etc.
var/paused_ticks = 0 //ticks this ss is taking to run right now.
var/paused_tick_usage //total tick_usage of all of our runs while pausing this run
var/ticks = 1 //how many ticks does this ss take to run on avg.
var/times_fired = 0 //number of times we have called fire()
var/queued_time = 0 //time we entered the queue, (for timing and priority reasons)
var/queued_priority //we keep a running total to make the math easier, if priority changes mid-fire that would break our running total, so we store it here
// Subsystem startup accounting.
var/init_state = FALSE
var/init_time = 0
var/init_start = 0
var/init_finish
var/last_fire = 0 //last world.time we called fire()
var/next_fire = 0 //scheduled world.time for next fire()
var/cost = 0 //average time to execute
var/tick_usage = 0 //average tick usage
var/tick_overrun = 0 //average tick overrun
var/state = SS_IDLE //tracks the current state of the ss, running, paused, etc.
var/paused_ticks = 0 //ticks this ss is taking to run right now.
var/paused_tick_usage //total tick_usage of all of our runs while pausing this run
var/ticks = 1 //how many ticks does this ss take to run on avg.
var/times_fired = 0 //number of times we have called fire()
var/queued_time = 0 //time we entered the queue, (for timing and priority reasons)
var/queued_priority //we keep a running total to make the math easier, if priority changes mid-fire that would break our running total, so we store it here
// Subsystem startup accounting - these variables cannot be trusted if the subsystem has crashed and been Recover()'d.
var/init_state = SS_INITSTATE_NONE // The current initialization state of this SS - this might be invalid if the subsystem has been Recover()'d.
var/init_time = 0 // How long the subsystem took to initialize, in seconds.
var/init_start = 0 // What timeofday did we start initializing?
var/init_finish // What timeofday did we finish initializing?
//linked list stuff for the queue
var/datum/controller/subsystem/queue_next
var/datum/controller/subsystem/queue_prev
var/static/list/failure_strikes //How many times we suspect a subsystem type has crashed the MC, 3 strikes and you're out!
var/static/list/failure_strikes //How many times we suspect a subsystem type has crashed the MC, 3 strikes and you're out! This is an assoc list indexed by type.
// Used to initialize the subsystem BEFORE the map has loaded
/datum/controller/subsystem/New()
@@ -167,12 +167,11 @@
init_state = SS_INITSTATE_DONE
//used to initialize the subsystem AFTER the map has loaded
/datum/controller/subsystem/Initialize(start_timeofday, silent = FALSE)
/datum/controller/subsystem/Initialize(start_timeofday)
var/time = (REALTIMEOFDAY - start_timeofday) / 10
init_time = time
var/msg = "Initialized [name] subsystem within [time] second[time == 1 ? "" : "s"]!"
if (!silent)
admin_notice(span("danger", msg), R_DEBUG)
admin_notice(span("danger", msg), R_DEBUG)
world.log << "SS Init: [msg]"
log_ss_init(msg)
return time
@@ -21,7 +21,7 @@ var/datum/controller/subsystem/nightlight/SSnightlight
fire(FALSE, FALSE)
..(timeofday, silent = TRUE)
..()
/datum/controller/subsystem/nightlight/stat_entry()
..("A:[isactive] T:[worldtime2hours()] DT:[config.nl_start] NT:[config.nl_finish] D:[disable_type]")
@@ -0,0 +1,60 @@
#define IC_SPAWN_DEFAULT 1 // If the circuit comes in the default circuit box and able to be printed in the IC printer.
#define IC_SPAWN_RESEARCH 2 // If the circuit design will be available in the IC printer after upgrading it.
/var/datum/controller/subsystem/processing/electronics/SSelectronics
/datum/controller/subsystem/processing/electronics
name = "Electronics"
wait = 2 SECONDS
priority = SS_PRIORITY_ELECTRONICS
flags = SS_KEEP_TIMING
init_order = SS_INIT_MISC_FIRST
var/list/all_integrated_circuits = list()
var/list/printer_recipe_list = list()
/datum/controller/subsystem/processing/electronics/New()
NEW_SS_GLOBAL(SSelectronics)
/datum/controller/subsystem/processing/electronics/Initialize(timeofday)
init_subtypes(/obj/item/integrated_circuit, all_integrated_circuits)
// First loop is to seperate the actual circuits from base circuits.
var/list/circuits_to_use = list()
for(var/obj/item/integrated_circuit/IC in all_integrated_circuits)
if((IC.spawn_flags & (IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH)))
circuits_to_use += IC
// Second loop is to find all categories.
var/list/found_categories = list()
for(var/obj/item/integrated_circuit/IC in circuits_to_use)
if(!(IC.category_text in found_categories))
found_categories += IC.category_text
// Third loop is to initialize lists by category names, then put circuits matching the category inside.
for(var/category in found_categories)
printer_recipe_list[category] = list()
var/list/current_list = printer_recipe_list[category]
for(var/obj/item/integrated_circuit/IC in circuits_to_use)
if(IC.category_text == category)
current_list += IC
// Now for non-circuit things.
printer_recipe_list["Assemblies"] = list(
new /obj/item/device/electronic_assembly,
new /obj/item/device/electronic_assembly/medium,
new /obj/item/device/electronic_assembly/large,
new /obj/item/device/electronic_assembly/drone,
new /obj/item/weapon/implant/integrated_circuit,
new /obj/item/device/assembly/electronic_assembly
)
printer_recipe_list["Tools"] = list(
new /obj/item/device/integrated_electronics/wirer,
new /obj/item/device/integrated_electronics/debugger
)
..()
#undef IC_SPAWN_DEFAULT
#undef IC_SPAWN_RESEARCH
@@ -25,7 +25,7 @@ var/datum/controller/subsystem/processing/SSprocessing
while(current_run.len)
var/datum/thing = current_run[current_run.len]
current_run.len--
if(thing)
if(!QDELETED(thing))
if (thing.process() == PROCESS_KILL)
stop_processing(thing)
else
+1
View File
@@ -398,6 +398,7 @@ var/datum/controller/subsystem/ticker/SSticker
data_core.manifest()
Master.RoundStart()
round_start_time = world.time
callHook("roundstart")