mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
Refactors subsystems to use dependency-ordering to determine init order. Subsystems can now declare their own dependencies. (#90268)
## About The Pull Request
As the title says.
`init_order` is no more, subsystems ordering now depends on their
declared dependencies.
Subsystems can now declare which other subsystems need to init before
them using a list and the subsystem's typepath
I.e.
```dm
dependencies = list(
/datum/controller/subsystem/atoms,
/datum/controller/subsystem/mapping
)
```
The reverse can also be done, if a subsystem must initialize after your
own:
```dm
dependents = list(
/datum/controller/subsystem/atoms
)
```
Cyclical dependencies are not allowed and will throw an error on
initialization if one is found.
There's also a debug tool to visualize the dependency graph, although
it's a bit basic:

Subsystem load ordering can still be controlled using `init_stage`, some
subsystems use this in cases where they must initialize first or last
regardless of dependencies. An error will be thrown if a subsystem has
an `init_stage` before one of their dependencies.
## Why It's Good For The Game
Makes dealing with subsystem dependencies easier, and reduces the chance
of making a dependency error when needing to shift around subsystem
inits.
## Changelog
🆑
refactor: Refactored subsystem initialization
/🆑
This commit is contained in:
@@ -4,7 +4,9 @@ PROCESSING_SUBSYSTEM_DEF(ai_behaviors)
|
||||
flags = SS_POST_FIRE_TIMING|SS_BACKGROUND
|
||||
priority = FIRE_PRIORITY_NPC_ACTIONS
|
||||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
||||
init_order = INIT_ORDER_AI_CONTROLLERS
|
||||
dependencies = list(
|
||||
/datum/controller/subsystem/movement/ai_movement
|
||||
)
|
||||
wait = 1
|
||||
///List of all ai_behavior singletons, key is the typepath while assigned value is a newly created instance of the typepath. See SetupAIBehaviors()
|
||||
var/list/ai_behaviors
|
||||
|
||||
@@ -3,7 +3,9 @@ PROCESSING_SUBSYSTEM_DEF(idle_ai_behaviors)
|
||||
flags = SS_BACKGROUND
|
||||
wait = 1.5 SECONDS
|
||||
priority = FIRE_PRIORITY_IDLE_NPC
|
||||
init_order = INIT_ORDER_AI_IDLE_CONTROLLERS //must execute only after ai behaviors are initialized
|
||||
dependencies = list(
|
||||
/datum/controller/subsystem/ai_controllers
|
||||
)
|
||||
///List of all the idle ai behaviors
|
||||
var/list/idle_behaviors = list()
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
/// subsystem for the fishing minigame processing.
|
||||
PROCESSING_SUBSYSTEM_DEF(fishing)
|
||||
name = "Fishing"
|
||||
dependencies = list(
|
||||
/datum/controller/subsystem/atoms
|
||||
)
|
||||
flags = SS_BACKGROUND
|
||||
wait = 0.05 SECONDS // If you raise it to 0.1 SECONDS, you better also modify [datum/fish_movement/move_fish()]
|
||||
///A list of cached fish icons
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
PROCESSING_SUBSYSTEM_DEF(greyscale)
|
||||
name = "Greyscale"
|
||||
flags = SS_BACKGROUND
|
||||
init_order = INIT_ORDER_GREYSCALE
|
||||
wait = 3 SECONDS
|
||||
|
||||
init_stage = INITSTAGE_EARLY
|
||||
var/list/datum/greyscale_config/configurations = list()
|
||||
var/list/datum/greyscale_layer/layer_types = list()
|
||||
#ifdef USE_RUSTG_ICONFORGE_GAGS
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
PROCESSING_SUBSYSTEM_DEF(instruments)
|
||||
name = "Instruments"
|
||||
wait = 0.5
|
||||
init_order = INIT_ORDER_INSTRUMENTS
|
||||
flags = SS_KEEP_TIMING
|
||||
priority = FIRE_PRIORITY_INSTRUMENTS
|
||||
/// List of all instrument data, associative id = datum
|
||||
|
||||
@@ -47,7 +47,6 @@ GLOBAL_LIST_INIT(quirk_string_blacklist, generate_quirk_string_blacklist())
|
||||
// - Quirk datums are stored and hold different effects, as well as being a vector for applying trait string
|
||||
PROCESSING_SUBSYSTEM_DEF(quirks)
|
||||
name = "Quirks"
|
||||
init_order = INIT_ORDER_QUIRKS
|
||||
flags = SS_BACKGROUND
|
||||
runlevels = RUNLEVEL_GAME
|
||||
wait = 1 SECONDS
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
PROCESSING_SUBSYSTEM_DEF(reagents)
|
||||
name = "Reagents"
|
||||
init_order = INIT_ORDER_REAGENTS
|
||||
priority = FIRE_PRIORITY_REAGENTS
|
||||
wait = 0.25 SECONDS //You might think that rate_up_lim has to be set to half, but since everything is normalised around seconds_per_tick, it automatically adjusts it to be per second. Magic!
|
||||
flags = SS_KEEP_TIMING
|
||||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
||||
init_stage = INITSTAGE_EARLY
|
||||
///What time was it when we last ticked
|
||||
var/previous_world_time = 0
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
PROCESSING_SUBSYSTEM_DEF(station)
|
||||
name = "Station"
|
||||
init_order = INIT_ORDER_STATION
|
||||
flags = SS_BACKGROUND
|
||||
runlevels = RUNLEVEL_GAME
|
||||
wait = 5 SECONDS
|
||||
|
||||
Reference in New Issue
Block a user