Files
Bubberstation/code/datums/elements/hostile_machine.dm
Mothblocks 404d2cb36c Optimize find_potential_targets self cost (#80602)
![image](https://github.com/tgstation/tgstation/assets/35135081/84ae20b6-5f44-4a69-bda3-0df1435dea5c)

`find_potential_targets/perform` currently has a pretty bad self cost in
part due to it running a second "loop over everything in range" check to
find turrets and mechs. This doesn't drop it down by as much as I'd like
because it still needs `hearers`, it still shows up pretty high, but
this at least cuts out some unnecessary work.

Best case is likely to minimize work AIs need to do when there are no
players on their z-level, as there are a lot of calls from Lavaland.
2023-12-28 14:14:49 +01:00

16 lines
390 B
Plaintext

/// AIs will attack this as a potential target if they see it
/datum/element/hostile_machine
element_flags = ELEMENT_DETACH_ON_HOST_DESTROY
/datum/element/hostile_machine/Attach(datum/target)
. = ..()
if (!isatom(target))
return ELEMENT_INCOMPATIBLE
GLOB.hostile_machines += target
/datum/element/hostile_machine/Detach(datum/source)
GLOB.hostile_machines -= source
return ..()