/tg/ Station 13 - Modules - TypesVar Details - Proc Details

spatial_grid

Vars

dummy_listempty spatial grid cell content lists are just a reference to this instead of a standalone list to save memory without needed to check if its null when iterating
grids_by_z_levellist of the spatial_grid_cell datums per z level, arranged in the order of y index then x index
number_of_oranges_earshow many pregenerated /mob/oranges_ear instances currently exist. this should hopefully never exceed its starting value
pregenerated_oranges_earslist of all of /mob/oranges_ear instances we have pregenerated for view() iteration speedup
waiting_to_add_by_typeeverything that spawns before us is added to this list until we initialize

Procs

after_world_bounds_expandedthe next unallocated /mob/oranges_ear that we try to allocate to assigned_atom's turf the next atom in atoms_that_need_ears an ear assigned to it the turf loc of the current assigned_atom. turfs are used to track oranges_ears already assigned to one location so we dont allocate more than one because allocating more than one oranges_ear to a given loc wastes view iterations adds cells to the grid for every z level when world.maxx or world.maxy is expanded after this subsystem is initialized. hopefully this is never needed. because i never tested this.
assign_oranges_earsallocate one /mob/oranges_ear mob per turf containing atoms_that_need_ears and give them a reference to every listed atom in their turf. if an oranges_ear is allocated to a turf that already has an oranges_ear then the second one fails to allocate (and gives the existing one the atom it was assigned to)
enter_cellfind the spatial map cell that target belongs to, then add target's important_recusive_contents to it. make sure to provide the turf new_target is "in"
enter_pre_init_queueadd a movable to the pre init queue for whichever type is specified so that when the subsystem initializes they get added to the grid
exit_cellfind the spatial map cell that target used to belong to, then subtract target's important_recusive_contents from it. make sure to provide the turf old_target used to be "in"
find_hanging_cell_refs_for_movableif shit goes south, this will find hanging references for qdeleting movables inside the spatial grid
force_remove_from_cellfind the cell this movable is associated with and removes it from all lists
get_cell_ofget the grid cell encomapassing targets coordinates
get_cells_in_rangeget all grid cells intersecting the bounding box around center with sides of length 2 * range
orthogonal_range_searchhttps://en.wikipedia.org/wiki/Range_searching#Orthogonal_range_searching
pregenerate_more_oranges_earscreates number_to_generate new oranges_ear's and adds them to the subsystems list of ears. i really fucking hope this never gets called after init :clueless:
propogate_spatial_grid_to_new_zcreates the spatial grid for a new z level
queued_item_deletedif a movable is inside our pre init queue before we're initialized and it gets deleted we need to remove that reference with this proc
remove_from_pre_init_queueremoves an initialized and probably deleted movable from our pre init queue before we're initialized

Var Details

dummy_list

empty spatial grid cell content lists are just a reference to this instead of a standalone list to save memory without needed to check if its null when iterating

grids_by_z_level

list of the spatial_grid_cell datums per z level, arranged in the order of y index then x index

number_of_oranges_ears

how many pregenerated /mob/oranges_ear instances currently exist. this should hopefully never exceed its starting value

pregenerated_oranges_ears

list of all of /mob/oranges_ear instances we have pregenerated for view() iteration speedup

waiting_to_add_by_type

everything that spawns before us is added to this list until we initialize

Proc Details

after_world_bounds_expanded

the next unallocated /mob/oranges_ear that we try to allocate to assigned_atom's turf the next atom in atoms_that_need_ears an ear assigned to it the turf loc of the current assigned_atom. turfs are used to track oranges_ears already assigned to one location so we dont allocate more than one because allocating more than one oranges_ear to a given loc wastes view iterations adds cells to the grid for every z level when world.maxx or world.maxy is expanded after this subsystem is initialized. hopefully this is never needed. because i never tested this.

assign_oranges_ears

allocate one /mob/oranges_ear mob per turf containing atoms_that_need_ears and give them a reference to every listed atom in their turf. if an oranges_ear is allocated to a turf that already has an oranges_ear then the second one fails to allocate (and gives the existing one the atom it was assigned to)

enter_cell

find the spatial map cell that target belongs to, then add target's important_recusive_contents to it. make sure to provide the turf new_target is "in"

enter_pre_init_queue

add a movable to the pre init queue for whichever type is specified so that when the subsystem initializes they get added to the grid

exit_cell

find the spatial map cell that target used to belong to, then subtract target's important_recusive_contents from it. make sure to provide the turf old_target used to be "in"

find_hanging_cell_refs_for_movable

if shit goes south, this will find hanging references for qdeleting movables inside the spatial grid

force_remove_from_cell

find the cell this movable is associated with and removes it from all lists

get_cell_of

get the grid cell encomapassing targets coordinates

get_cells_in_range

get all grid cells intersecting the bounding box around center with sides of length 2 * range

https://en.wikipedia.org/wiki/Range_searching#Orthogonal_range_searching

searches through the grid cells intersecting a rectangular search space (with sides of length 2 * range) then returns all contents of type inside them. much faster than iterating through view() to find all of what you want.

this does NOT return things only in range distance from center! the search space is a square not a circle, if you want only things in a certain distance then you need to filter that yourself

pregenerate_more_oranges_ears

creates number_to_generate new oranges_ear's and adds them to the subsystems list of ears. i really fucking hope this never gets called after init :clueless:

propogate_spatial_grid_to_new_z

creates the spatial grid for a new z level

queued_item_deleted

if a movable is inside our pre init queue before we're initialized and it gets deleted we need to remove that reference with this proc

remove_from_pre_init_queue

removes an initialized and probably deleted movable from our pre init queue before we're initialized