[MIRROR] Optimize mirage_border by converting it to an element and a movable [MDB IGNORE] (#22913)

* Optimize mirage_border by converting it to an element and a movable (#77137)

## About The Pull Request

Converts /datum/component/mirage_border to an element, saving init time
spent attaching components to thousands of objects. It also repaths it
from /obj/effect/abstract to /atom/movable, since it doesn't need to be
an object, as it's not a physical object within the game.

~~Also adds a case handling when world.view is not an integer.~~ This
never happens

Here it is working:

https://github.com/tgstation/tgstation/assets/10366817/c8cfe2df-275a-4c97-b063-4fd83f7f09c3

Port of https://github.com/BeeStation/BeeStation-Hornet/pull/9490/

## Why It's Good For The Game

Saves init time, approx 0.32sec on Meta on my machine.

![image](https://github.com/tgstation/tgstation/assets/10366817/f423813e-e627-44a4-b6c6-b1d6fe49e8c3)

![image](https://github.com/tgstation/tgstation/assets/10366817/ad6796c6-ff78-4140-9a5a-3572ac34f42c)

## Changelog

🆑
code: Optimized z-level transition mirages, saving ~0.32s init.
/🆑

---------

Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com>

* Optimize mirage_border by converting it to an element and a movable

---------

Co-authored-by: itsmeow <itsmeow@itsmeow.dev>
Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-08-07 09:41:46 -04:00
committed by GitHub
co-authored by Ghom itsmeow
parent e27ed051e7
commit d833cfa83b
4 changed files with 46 additions and 46 deletions
@@ -123,6 +123,9 @@
var/list/x_pos_transition = list(1, 1, TRANSITIONEDGE + 2, inner_max_x - 1) //values of x for the transition from respective blocks on the side of zlevel, 1 is being translated into turfs respective x value later in the code
var/list/y_pos_transition = list(TRANSITIONEDGE + 2, inner_max_y - 1, 1, 1) //values of y for the transition from respective blocks on the side of zlevel, 1 is being translated into turfs respective y value later in the code
// Cache the range passed to the mirage border element, to reduce world var access in the thousands
var/range_cached = world.view
for(var/datum/space_level/level as anything in cached_z_list)
if(!level.neigbours.len)
continue
@@ -156,6 +159,6 @@
continue
var/turf/place = locate(S.destination_x, S.destination_y, zdestination)
S.AddComponent(/datum/component/mirage_border, place, mirage_dir)
S.AddElement(/datum/element/mirage_border, place, mirage_dir, range_cached)
#undef CHORDS_TO_1D