VS: Convert bellies to processing subsystem

This commit is contained in:
Aronai Sieyes
2020-03-30 16:11:05 -04:00
parent 0a46acbb31
commit cdb2336bf7
5 changed files with 36 additions and 76 deletions

View File

@@ -1,55 +0,0 @@
#define SSBELLIES_PROCESSED 1
#define SSBELLIES_IGNORED 2
//
// Bellies subsystem - Process vore bellies
//
SUBSYSTEM_DEF(bellies)
name = "Bellies"
priority = 5
wait = 1 SECONDS
flags = SS_KEEP_TIMING|SS_NO_INIT
runlevels = RUNLEVEL_GAME|RUNLEVEL_POSTGAME
var/list/belly_list = list()
var/list/currentrun = list()
var/ignored_bellies = 0
var/obj/belly/current_belly
/datum/controller/subsystem/bellies/Recover()
log_debug("[name] subsystem Recover().")
if(SSbellies.current_belly)
log_debug("current_belly was: (\ref[SSbellies.current_belly])[SSbellies.current_belly]([SSbellies.current_belly.type])(SSbellies.current_belly.owner) - currentrun: [SSbellies.currentrun.len] vs total: [SSbellies.belly_list.len]")
var/list/old_bellies = SSbellies.belly_list.Copy()
for(var/datum/D in old_bellies)
if(!isbelly(D))
log_debug("[name] subsystem Recover() found inappropriate item in list: [D.type]")
belly_list |= D
/datum/controller/subsystem/bellies/stat_entry()
..("#: [belly_list.len] | P: [ignored_bellies]")
/datum/controller/subsystem/bellies/fire(resumed = 0)
if (!resumed)
ignored_bellies = 0
src.currentrun = belly_list.Copy()
//cache for sanic speed (lists are references anyways)
var/list/currentrun = src.currentrun
var/times_fired = src.times_fired
while(currentrun.len)
current_belly = currentrun[currentrun.len]
currentrun.len--
if(QDELETED(current_belly))
belly_list -= current_belly
else
if(current_belly.process_belly(times_fired,wait) == SSBELLIES_IGNORED)
ignored_bellies++
if (MC_TICK_CHECK)
current_belly = null
return
current_belly = null

View File

@@ -0,0 +1,20 @@
//
// Bellies subsystem - Process vore bellies
//
PROCESSING_SUBSYSTEM_DEF(bellies)
name = "Bellies"
wait = 6 SECONDS
flags = SS_KEEP_TIMING|SS_NO_INIT
runlevels = RUNLEVEL_GAME|RUNLEVEL_POSTGAME
/datum/controller/subsystem/processing/bellies/Recover()
log_debug("[name] subsystem Recover().")
if(SSbellies.current_thing)
log_debug("current_thing was: (\ref[SSbellies.current_thing])[SSbellies.current_thing]([SSbellies.current_thing.type]) - currentrun: [SSbellies.currentrun.len] vs total: [SSbellies.processing.len]")
var/list/old_processing = SSbellies.processing.Copy()
for(var/datum/D in old_processing)
if(!isbelly(D))
log_debug("[name] subsystem Recover() found inappropriate item in list: [D.type]")
if(CHECK_BITFIELD(D.datum_flags, DF_ISPROCESSING))
processing |= D

View File

@@ -55,9 +55,8 @@
var/tmp/mob/living/owner // The mob whose belly this is.
var/tmp/digest_mode = DM_HOLD // Current mode the belly is set to from digest_modes (+transform_modes if human)
var/tmp/tf_mode = DM_TRANSFORM_REPLICA // Current transformation mode.
var/tmp/next_process = 0 // Waiting for this SSbellies times_fired to process again.
var/tmp/list/items_preserved = list() // Stuff that wont digest so we shouldn't process it again.
var/tmp/next_emote = 0 // When we're supposed to print our next emote, as a belly controller tick #
var/tmp/next_emote = 0 // When we're supposed to print our next emote, as a world.time
var/tmp/recent_sound = FALSE // Prevent audio spam
// Don't forget to watch your commas at the end of each line if you change these.
@@ -160,20 +159,20 @@
"wet_loop"
)
/obj/belly/New(var/newloc)
..(newloc)
/obj/belly/Initialize()
. = ..()
//If not, we're probably just in a prefs list or something.
if(isliving(newloc))
if(isliving(loc))
owner = loc
owner.vore_organs |= src
SSbellies.belly_list += src
START_PROCESSING(SSbellies, src)
/obj/belly/Destroy()
SSbellies.belly_list -= src
STOP_PROCESSING(SSbellies, src)
if(owner)
owner.vore_organs -= src
owner = null
. = ..()
return ..()
// Called whenever an atom enters this belly
/obj/belly/Entered(atom/movable/thing, atom/OldLoc)

View File

@@ -1,17 +1,13 @@
// Process the predator's effects upon the contents of its belly (i.e digestion/transformation etc)
/obj/belly/proc/process_belly(times_fired, wait) //Passed by controller
if((times_fired < next_process) || !contents.len)
recent_sound = FALSE
return SSBELLIES_IGNORED
/obj/belly/process(wait) //Passed by controller
recent_sound = FALSE
if(loc != owner)
if(istype(owner))
loc = owner
else
qdel(src)
return SSBELLIES_PROCESSED
next_process = times_fired + (6 SECONDS / wait) //Set up our next process time.
return
var/play_sound //Potential sound to play at the end to avoid code duplication.
var/to_update = FALSE //Did anything update worthy happen?
@@ -38,13 +34,13 @@
/////////////////////////// Exit Early ////////////////////////////
var/list/touchable_atoms = contents - items_preserved
if(!length(touchable_atoms))
return SSBELLIES_PROCESSED
return
var/list/touchable_mobs = list()
///////////////////// Early Non-Mode Handling /////////////////////
if(contents.len && next_emote <= times_fired)
next_emote = times_fired + round(emote_time/wait,1)
if(contents.len && next_emote <= world.time)
next_emote = world.time + emote_time
var/list/EL = emote_lists[digest_mode]
if(LAZYLEN(EL))
for(var/mob/living/M in contents)
@@ -107,7 +103,7 @@
//We deliberately do not want any gurgly noises if the belly is in DM_HOLD
if(to_update)
updateVRPanels()
return SSBELLIES_PROCESSED
return
if(digest_mode == DM_TRANSFORM)
process_tf(tf_mode, touchable_mobs)
@@ -221,7 +217,7 @@
if(to_update)
updateVRPanels()
return SSBELLIES_PROCESSED
return
/obj/belly/proc/prey_loop()
for(var/mob/living/M in contents)

View File

@@ -233,7 +233,6 @@
#include "code\controllers\subsystems\airflow.dm"
#include "code\controllers\subsystems\assets.dm"
#include "code\controllers\subsystems\atoms.dm"
#include "code\controllers\subsystems\bellies_vr.dm"
#include "code\controllers\subsystems\character_setup.dm"
#include "code\controllers\subsystems\chat.dm"
#include "code\controllers\subsystems\circuits.dm"
@@ -262,6 +261,7 @@
#include "code\controllers\subsystems\transcore_vr.dm"
#include "code\controllers\subsystems\vote.dm"
#include "code\controllers\subsystems\xenoarch.dm"
#include "code\controllers\subsystems\processing\bellies_vr.dm"
#include "code\controllers\subsystems\processing\chemistry.dm"
#include "code\controllers\subsystems\processing\fastprocess.dm"
#include "code\controllers\subsystems\processing\obj.dm"