mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-01-19 22:13:37 +00:00
* move along move along * Update bot.dm * Diagonals are now more expensive * Update path.dm * Update parrot.dm * Update path.dm * Tweaks * Fix cleanbot, add path safety * Tweaked, added a safety, removed the previous one * Update medbot.dm * path.len isn't very safe as a whole, floorbots also had order of operations wrong * Update medbot.dm * clings not even once * Back to the drawing board * Update path.dm * Make mules actually clear the drawn path. * Make bots use step_towards unconditionally instead of flipping between step_to and Move * Making extra sure the path is cleared. Somehow path was left over. * Check for length as get_path_to is always true * This and that
47 lines
924 B
Plaintext
47 lines
924 B
Plaintext
SUBSYSTEM_DEF(pathfinder)
|
|
name = "Pathfinder"
|
|
init_order = INIT_ORDER_PATH
|
|
flags = SS_NO_FIRE
|
|
var/datum/flowcache/mobs
|
|
var/static/space_type_cache
|
|
|
|
/datum/controller/subsystem/pathfinder/Initialize()
|
|
space_type_cache = typecacheof(/turf/space)
|
|
mobs = new(10)
|
|
return ..()
|
|
|
|
/datum/flowcache
|
|
var/lcount
|
|
var/run
|
|
var/free
|
|
var/list/flow
|
|
|
|
/datum/flowcache/New(n)
|
|
. = ..()
|
|
lcount = n
|
|
run = 0
|
|
free = 1
|
|
flow = new/list(lcount)
|
|
|
|
/datum/flowcache/proc/getfree(atom/M)
|
|
if(run < lcount)
|
|
run += 1
|
|
while(flow[free])
|
|
CHECK_TICK
|
|
free = (free % lcount) + 1
|
|
var/t = addtimer(CALLBACK(src, /datum/flowcache.proc/toolong, free), 150, TIMER_STOPPABLE)
|
|
flow[free] = t
|
|
flow[t] = M
|
|
return free
|
|
else
|
|
return 0
|
|
|
|
/datum/flowcache/proc/toolong(l)
|
|
log_game("Pathfinder route took longer than 150 ticks, src bot [flow[flow[l]]]")
|
|
found(l)
|
|
|
|
/datum/flowcache/proc/found(l)
|
|
deltimer(flow[l])
|
|
flow[l] = null
|
|
run -= 1
|