mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Make unnatural resizing even better and more efficient with the power of DCS™️
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
GLOBAL_LIST_EMPTY(size_uncapped_mobs)
|
||||
GLOBAL_VAR(size_uncapped_mobs_timer)
|
||||
|
||||
// Adding needed defines to /mob/living
|
||||
// Note: Polaris had this on /mob/living/carbon/human We need it higher up for animals and stuff.
|
||||
/mob/living
|
||||
@@ -60,6 +57,7 @@ GLOBAL_VAR(size_uncapped_mobs_timer)
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
<<<<<<< HEAD
|
||||
/proc/add_to_uncapped_list(var/mob/living/L)
|
||||
if(L.size_uncapped)
|
||||
return
|
||||
@@ -92,14 +90,87 @@ GLOBAL_VAR(size_uncapped_mobs_timer)
|
||||
if(!GLOB.size_uncapped_mobs.len)
|
||||
deltimer(GLOB.size_uncapped_mobs_timer)
|
||||
GLOB.size_uncapped_mobs_timer = null
|
||||
||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
|
||||
/atom/movable/proc/has_large_resize_bounds()
|
||||
var/area/A = get_area(src) //Get the atom's area to check for size limit.
|
||||
return !A.limit_mob_size
|
||||
|
||||
/proc/is_extreme_size(size)
|
||||
return (size < RESIZE_MINIMUM || size > RESIZE_MAXIMUM)
|
||||
|
||||
/proc/add_to_uncapped_list(var/mob/living/L)
|
||||
if(L.size_uncapped)
|
||||
return
|
||||
if(!GLOB.size_uncapped_mobs.len)
|
||||
//Could be a subsystem but arguably a giant waste of time to make into a subsystem. A subsystem that is paused on and off all the time? Eh.
|
||||
//If you're that worried, make metrics for how often this even runs and then decide.
|
||||
GLOB.size_uncapped_mobs_timer = addtimer(CALLBACK(GLOBAL_PROC, .check_uncapped_list), 2 SECONDS, TIMER_LOOP | TIMER_UNIQUE | TIMER_STOPPABLE)
|
||||
GLOB.size_uncapped_mobs |= weakref(L)
|
||||
|
||||
/proc/remove_from_uncapped_list(var/mob/living/L)
|
||||
if(!GLOB.size_uncapped_mobs.len)
|
||||
return
|
||||
|
||||
GLOB.size_uncapped_mobs -= weakref(L)
|
||||
|
||||
if(!GLOB.size_uncapped_mobs.len)
|
||||
deltimer(GLOB.size_uncapped_mobs_timer)
|
||||
GLOB.size_uncapped_mobs_timer = null
|
||||
|
||||
/proc/check_uncapped_list()
|
||||
for(var/weakref/wr in GLOB.size_uncapped_mobs)
|
||||
var/mob/living/L = wr.resolve()
|
||||
if(!istype(L) || L.size_uncapped)
|
||||
GLOB.size_uncapped_mobs -= wr
|
||||
continue
|
||||
|
||||
// If we get here, you're a mob, and you don't have admin exclusion (size_uncapped) to being big, and you're very likely big.
|
||||
// If you're not abnormally big, the below will do nothing, so it's fine to run anyway.
|
||||
if(!L.has_large_resize_bounds())
|
||||
L.resize(L.size_multiplier, ignore_prefs = TRUE) //Calling this will have resize() clamp it
|
||||
GLOB.size_uncapped_mobs -= wr
|
||||
|
||||
if(!GLOB.size_uncapped_mobs.len)
|
||||
deltimer(GLOB.size_uncapped_mobs_timer)
|
||||
GLOB.size_uncapped_mobs_timer = null
|
||||
=======
|
||||
/atom/movable/proc/has_large_resize_bounds()
|
||||
var/area/A = get_area(src) //Get the atom's area to check for size limit.
|
||||
return !A.limit_mob_size
|
||||
|
||||
/proc/is_extreme_size(size)
|
||||
return (size < RESIZE_MINIMUM || size > RESIZE_MAXIMUM)
|
||||
|
||||
>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
|
||||
|
||||
/mob/living/proc/resize(var/new_size, var/animate = TRUE, var/uncapped = FALSE)
|
||||
if(!uncapped)
|
||||
<<<<<<< HEAD
|
||||
new_size = clamp(new_size, RESIZE_TINY, RESIZE_HUGE)
|
||||
src.size_uncapped = FALSE
|
||||
remove_from_uncapped_list(src)
|
||||
else
|
||||
add_to_uncapped_list(src)
|
||||
||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
|
||||
new_size = clamp(new_size, RESIZE_MINIMUM, RESIZE_MAXIMUM)
|
||||
remove_from_uncapped_list(src)
|
||||
else if(is_extreme_size(new_size))
|
||||
add_to_uncapped_list(src)
|
||||
|
||||
=======
|
||||
new_size = clamp(new_size, RESIZE_MINIMUM, RESIZE_MAXIMUM)
|
||||
var/datum/component/resize_guard/guard = GetComponent(/datum/component/resize_guard)
|
||||
if(guard)
|
||||
qdel(guard)
|
||||
else if(has_large_resize_bounds())
|
||||
if(is_extreme_size(new_size))
|
||||
AddComponent(/datum/component/resize_guard)
|
||||
else
|
||||
var/datum/component/resize_guard/guard = GetComponent(/datum/component/resize_guard)
|
||||
if(guard)
|
||||
qdel(guard)
|
||||
|
||||
>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard
|
||||
if(size_multiplier == new_size)
|
||||
return 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user