mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-28 19:21:48 +00:00
Process and Process Scheduler Tweaks
This commit is contained in:
@@ -1,20 +1,28 @@
|
||||
/datum/controller/process/bot
|
||||
var/tmp/datum/updateQueue/updateQueueInstance
|
||||
|
||||
/datum/controller/process/bot/setup()
|
||||
name = "bot"
|
||||
schedule_interval = 20 // every 2 seconds
|
||||
updateQueueInstance = new
|
||||
|
||||
/datum/controller/process/bot/started()
|
||||
..()
|
||||
if(!updateQueueInstance)
|
||||
if(!aibots)
|
||||
aibots = list()
|
||||
else if(aibots.len)
|
||||
updateQueueInstance = new
|
||||
if(!aibots)
|
||||
aibots = list()
|
||||
|
||||
/datum/controller/process/bot/statProcess()
|
||||
..()
|
||||
stat(null, "[aibots && aibots.len] bots")
|
||||
|
||||
/datum/controller/process/bot/doWork()
|
||||
if(updateQueueInstance)
|
||||
updateQueueInstance.init(aibots, "bot_process")
|
||||
updateQueueInstance.Run()
|
||||
for(var/obj/machinery/bot/B in aibots)
|
||||
if(istype(B) && isnull(B.gcDestroyed))
|
||||
// Some bots sleep when they process, but there's not many bots, so just spawn them off
|
||||
spawn(-1)
|
||||
try
|
||||
B.bot_process()
|
||||
catch(var/exception/e)
|
||||
catchException(e, B)
|
||||
// Use src explicitly after a try/catch, or BYOND messes src up. I have no idea why.
|
||||
src.scheck()
|
||||
else
|
||||
aibots -= B
|
||||
Reference in New Issue
Block a user