mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-30 08:29:57 +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
|
||||
|
||||
Reference in New Issue
Block a user