mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 04:30:44 +01:00
[MIRROR] [Performance] Makes bot salute not do thousands of hearers_in_view calls (#1413)
* [Performance] Makes bot salute not do thousands of hearers_in_view calls (#54498) It now uses view() instead, and is cooldowned per each check, instead of per each successful salute EDIT: I've changed so the commmissioned bots invoke salutes for even more performance, as AnturK suggested. * [Performance] Makes bot salute not do thousands of hearers_in_view calls Co-authored-by: Azarak <azarak10@gmail.com>
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
var/robot_arm = /obj/item/bodypart/r_arm/robot
|
||||
|
||||
var/commissioned = FALSE // Will other (noncommissioned) bots salute this bot?
|
||||
var/can_salute = TRUE
|
||||
COOLDOWN_DECLARE(next_salute_check)
|
||||
var/salute_delay = 60 SECONDS
|
||||
|
||||
hud_possible = list(DIAG_STAT_HUD, DIAG_BOT_HUD, DIAG_HUD, DIAG_PATH_HUD = HUD_LIST_LIST) //Diagnostic HUD views
|
||||
@@ -273,12 +273,11 @@
|
||||
if(!on || client)
|
||||
return
|
||||
|
||||
if(!commissioned && can_salute)
|
||||
for(var/mob/living/simple_animal/bot/B in get_hearers_in_view(5, get_turf(src)))
|
||||
if(B.commissioned)
|
||||
visible_message("<b>[src]</b> performs an elaborate salute for [B]!")
|
||||
can_salute = FALSE
|
||||
addtimer(VARSET_CALLBACK(src, can_salute, TRUE), salute_delay)
|
||||
if(commissioned && COOLDOWN_FINISHED(src, next_salute_check))
|
||||
COOLDOWN_START(src, next_salute_check, salute_delay)
|
||||
for(var/mob/living/simple_animal/bot/B in view(5, src))
|
||||
if(!B.commissioned && B.on)
|
||||
visible_message("<b>[B]</b> performs an elaborate salute for [src]!")
|
||||
break
|
||||
|
||||
switch(mode) //High-priority overrides are processed first. Bots can do nothing else while under direct command.
|
||||
|
||||
Reference in New Issue
Block a user