mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-27 06:54:18 +01:00
Shave process spatial gridmap (#16693)
* Atomization * atomization + possible fix + changelog * Update html/changelogs/FluffyGhost-shave_process_spatial_gridmap.yml Co-authored-by: Cody Brittain <cbrittain10@yahoo.com> --------- Co-authored-by: FluffyGhost <FluffyGhost> Co-authored-by: Cody Brittain <cbrittain10@yahoo.com>
This commit is contained in:
co-authored by
Cody Brittain
FluffyGhost <FluffyGhost>
parent
947631322b
commit
71a7bb9223
@@ -17,3 +17,38 @@
|
||||
// Whether movable is itself or containing something which should be in one of the spatial grid channels
|
||||
#define HAS_SPATIAL_GRID_CONTENTS(movable) (movable.important_recursive_contents && \
|
||||
(movable.important_recursive_contents[RECURSIVE_CONTENTS_HEARING_SENSITIVE] || movable.important_recursive_contents[RECURSIVE_CONTENTS_CLIENT_MOBS] || movable.important_recursive_contents[RECURSIVE_CONTENTS_AI_TARGETS]))
|
||||
|
||||
|
||||
/**
|
||||
* Checks if two atoms are in line of sight (can see each other)
|
||||
*
|
||||
* * RETURN_VALUE - Where to store the result of this check (TRUE if LoS, FALSE otherwise)
|
||||
* * source - Source atom
|
||||
* * target - Target atom
|
||||
* * view_radius - How far the atom can see, usually you want to use `world.view` for the default value
|
||||
*/
|
||||
#define SPATIAL_CHECK_LOS(RETURN_VALUE, source, target, view_radius)\
|
||||
do{\
|
||||
var/turf/source_turf = get_turf(source);\
|
||||
var/turf/target_turf = get_turf(target);\
|
||||
var/distance = get_dist(source_turf, target_turf);\
|
||||
if(distance > view_radius){\
|
||||
RETURN_VALUE = FALSE;\
|
||||
break;\
|
||||
}\
|
||||
if(distance < 2){\
|
||||
RETURN_VALUE = TRUE;\
|
||||
break;\
|
||||
}\
|
||||
for(var/step_counter in 1 to distance){\
|
||||
source_turf = get_step_towards(source_turf, target_turf);\
|
||||
if(source_turf == target_turf){\
|
||||
RETURN_VALUE = TRUE;\
|
||||
break;\
|
||||
}\
|
||||
if(IS_OPAQUE_TURF(source_turf)){\
|
||||
RETURN_VALUE = FALSE;\
|
||||
break;\
|
||||
}\
|
||||
}\
|
||||
} while(FALSE)
|
||||
|
||||
@@ -191,32 +191,12 @@
|
||||
. = SSspatial_grid.orthogonal_range_search(source, SPATIAL_GRID_CONTENTS_TYPE_TARGETS, view_radius)
|
||||
|
||||
for(var/mob/target as anything in .)
|
||||
if(!check_los(source, target, view_radius))
|
||||
var/los = null
|
||||
SPATIAL_CHECK_LOS(los, source, target, view_radius)
|
||||
if(!los)
|
||||
. -= target
|
||||
continue
|
||||
|
||||
/proc/check_los(atom/source, atom/target, view_radius = world.view)
|
||||
var/turf/source_turf = get_turf(source)
|
||||
var/turf/target_turf = get_turf(target)
|
||||
|
||||
var/distance = get_dist(source_turf, target_turf)
|
||||
if(distance > view_radius)
|
||||
return FALSE
|
||||
|
||||
if(distance < 2)
|
||||
return TRUE
|
||||
|
||||
var/turf/mid_turf = source_turf
|
||||
|
||||
for(var/step_counter in 1 to distance)
|
||||
mid_turf = get_step_towards(mid_turf, target_turf)
|
||||
if(mid_turf == target_turf)
|
||||
break
|
||||
if(IS_OPAQUE_TURF(mid_turf))
|
||||
return FALSE
|
||||
|
||||
return TRUE
|
||||
|
||||
///Calculate if two atoms are in sight, returns TRUE or FALSE
|
||||
/proc/inLineOfSight(X1,Y1,X2,Y2,Z=1,PX1=16.5,PY1=16.5,PX2=16.5,PY2=16.5)
|
||||
var/turf/T
|
||||
|
||||
@@ -151,7 +151,9 @@
|
||||
return
|
||||
|
||||
/mob/living/simple_animal/hostile/proc/see_target()
|
||||
return check_los(src, target_mob)
|
||||
var/los = null
|
||||
SPATIAL_CHECK_LOS(los, src, target_mob, world.view)
|
||||
return los
|
||||
|
||||
/mob/living/simple_animal/hostile/proc/MoveToTarget()
|
||||
stop_automated_movement = 1
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
################################
|
||||
# Example Changelog File
|
||||
#
|
||||
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
|
||||
#
|
||||
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
|
||||
# When it is, any changes listed below will disappear.
|
||||
#
|
||||
# Valid Prefixes:
|
||||
# bugfix
|
||||
# wip (For works in progress)
|
||||
# tweak
|
||||
# soundadd
|
||||
# sounddel
|
||||
# rscadd (general adding of nice things)
|
||||
# rscdel (general deleting of nice things)
|
||||
# imageadd
|
||||
# imagedel
|
||||
# maptweak
|
||||
# spellcheck (typo fixes)
|
||||
# experiment
|
||||
# balance
|
||||
# admin
|
||||
# backend
|
||||
# security
|
||||
# refactor
|
||||
#################################
|
||||
|
||||
# Your name.
|
||||
author: FluffyGhost
|
||||
|
||||
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
|
||||
delete-after: True
|
||||
|
||||
# Any changes you've made. See valid prefix list above.
|
||||
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
|
||||
# SCREW THIS UP AND IT WON'T WORK.
|
||||
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
|
||||
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
|
||||
changes:
|
||||
- refactor: "Added a spatial gridmap check LoS define, to be used inside spatial_info for often called procs (get_target_in_LOS for now, which is called very often, 455k times in 10 minutes)."
|
||||
Reference in New Issue
Block a user