Refactors the list datatype to support composite lists. Adapts a lot of circuits to be able to properly use composite lists. Adds the dispenser shell (#61856)

Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>
Co-authored-by: Colovorat <35225170+Colovorat@users.noreply.github.com>
This commit is contained in:
Watermelon914
2021-10-06 22:51:36 -07:00
committed by GitHub
co-authored by Watermelon914 Colovorat
parent 001315f214
commit d15b305527
52 changed files with 966 additions and 300 deletions
@@ -6,6 +6,8 @@ SUBSYSTEM_DEF(circuit_component)
var/list/callbacks_to_invoke = list()
var/list/currentrun = list()
var/list/instant_run_stack = list()
var/instant_run_tick = 0
var/instant_run_start_cpu_usage = 0
var/instant_run_max_cpu_usage = 10
@@ -45,9 +47,17 @@ SUBSYSTEM_DEF(circuit_component)
callbacks_to_invoke += to_call
/// Queues any callbacks to be executed instantly instead of using the subsystem.
/datum/controller/subsystem/circuit_component/proc/queue_instant_run()
/datum/controller/subsystem/circuit_component/proc/queue_instant_run(start_cpu_time)
if(instant_run_tick)
instant_run_stack += list(instant_run_callbacks_to_run)
// If we're already instantly executing, don't change the start_cpu_time.
start_cpu_time = instant_run_start_cpu_usage
if(!start_cpu_time)
start_cpu_time = TICK_USAGE
instant_run_tick = world.time
instant_run_start_cpu_usage = TICK_USAGE
instant_run_start_cpu_usage = start_cpu_time
instant_run_callbacks_to_run = list()
/**
@@ -67,7 +77,11 @@ SUBSYSTEM_DEF(circuit_component)
to_call.InvokeAsync(received_inputs)
qdel(to_call)
instant_run_tick = 0
if(length(instant_run_stack))
instant_run_callbacks_to_run = pop(instant_run_stack)
else
instant_run_tick = 0
if((TICK_USAGE - instant_run_start_cpu_usage) < instant_run_max_cpu_usage)
return received_inputs
else
@@ -0,0 +1,42 @@
/**
* This subsystem is to handle creating and storing
* composite templates that are used to create composite datatypes
* for integrated circuits
*
* See: https://en.wikipedia.org/wiki/Composite_data_type
**/
SUBSYSTEM_DEF(wiremod_composite)
name = "Wiremod Composite Templates"
flags = SS_NO_FIRE
/// The templates created and stored
var/list/templates = list()
/datum/controller/subsystem/wiremod_composite/New()
. = ..()
// This needs to execute before global variables have initialized.
for(var/datum/circuit_composite_template/type as anything in subtypesof(/datum/circuit_composite_template))
if(!initial(type.datatype))
continue
templates[initial(type.datatype)] = new type()
/datum/controller/subsystem/wiremod_composite/Initialize(start_timeofday)
. = ..()
for(var/type in templates)
var/datum/circuit_composite_template/template = templates[type]
template.Initialize()
/**
* Used to produce a composite datatype using another datatype, or
* to get an already existing composite datatype.
*/
/datum/controller/subsystem/wiremod_composite/proc/composite_datatype(datatype, ...)
var/datum/circuit_composite_template/type = templates[datatype]
if(!type)
return
return type.generate_composite_type(args.Copy(2))
/datum/controller/subsystem/wiremod_composite/proc/get_composite_type(base_type, datatype)
var/datum/circuit_composite_template/template = templates[base_type]
if(!template)
return
return template.generated_types[datatype]