mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 14:39:58 +01:00
debug proc for visuallizing spatial grids (#92325)
## About The Pull Request debug PROC (because its super laggy so i locked it behind a proc call on a subsystem) for painting the world based on the cell its located in pulled out of my port of spatial grids in https://github.com/shiptest-ss13/Shiptest/pull/4399 https://github.com/user-attachments/assets/07008518-e418-442b-ab80-6557e936fee2 ## Why It's Good For The Game useful for debugging spatial grid issues. also helped ,e discover a bug since it calls get_cell on every atom. ## Changelog 🆑 code: debug proc for painting the world based on spatial grid. /🆑 --------- Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
This commit is contained in:
committed by
Roxy
co-authored by
LemonInTheDark
parent
cc627b1a25
commit
ffb2eac09a
@@ -104,6 +104,9 @@ SUBSYSTEM_DEF(spatial_grid)
|
||||
///how many pregenerated /mob/oranges_ear instances currently exist. this should hopefully never exceed its starting value
|
||||
var/number_of_oranges_ears = NUMBER_OF_PREGENERATED_ORANGES_EARS
|
||||
|
||||
///for debugging, stores a list of grids with colors to paint atoms with
|
||||
var/list/cells_with_color
|
||||
|
||||
/datum/controller/subsystem/spatial_grid/Initialize()
|
||||
cells_on_x_axis = SPATIAL_GRID_CELLS_PER_SIDE(world.maxx)
|
||||
cells_on_y_axis = SPATIAL_GRID_CELLS_PER_SIDE(world.maxy)
|
||||
@@ -843,6 +846,31 @@ SUBSYSTEM_DEF(spatial_grid)
|
||||
the average client distance is: [average_client_distance], the average hearable_distance is [average_hearable_distance], \
|
||||
and the average atmos distance is [average_atmos_distance] ")
|
||||
|
||||
//A debugging proc that colors objects based on what grid they belong to
|
||||
/datum/controller/subsystem/spatial_grid/proc/paint_grids()
|
||||
cells_with_color = list()
|
||||
for(var/list/z_level_grid as anything in grids_by_z_level)
|
||||
for(var/list/cell_row as anything in z_level_grid)
|
||||
for(var/datum/spatial_grid_cell/cell as anything in cell_row)
|
||||
cells_with_color[cell] = RANDOM_COLOUR
|
||||
for(var/atom/thing in world.contents)
|
||||
var/datum/spatial_grid_cell/things_cell = get_cell_of(thing)
|
||||
if(!things_cell)
|
||||
continue
|
||||
thing.add_atom_colour(cells_with_color[things_cell], ADMIN_COLOUR_PRIORITY)
|
||||
if(ismovable(thing))
|
||||
RegisterSignal(thing, COMSIG_MOVABLE_MOVED, PROC_REF(update_color))
|
||||
CHECK_TICK
|
||||
|
||||
//A debugging proc that colors objects based on what grid they belong to
|
||||
/datum/controller/subsystem/spatial_grid/proc/update_color(atom/movable/thing)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
var/datum/spatial_grid_cell/things_cell = get_cell_of(thing)
|
||||
if(!isdatum(things_cell))
|
||||
return
|
||||
thing.add_atom_colour(cells_with_color[things_cell], ADMIN_COLOUR_PRIORITY)
|
||||
|
||||
#undef BOUNDING_BOX_MAX
|
||||
#undef BOUNDING_BOX_MIN
|
||||
|
||||
|
||||
Reference in New Issue
Block a user