mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-10 09:54:52 +00:00
ASYNC EVERYTHING!
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
GLOBAL_LIST_EMPTY(lighting_update_lights) // List of lighting sources queued for update.
|
||||
GLOBAL_LIST_EMPTY(lighting_update_corners) // List of lighting corners queued for update.
|
||||
GLOBAL_LIST_EMPTY(lighting_update_objects) // List of lighting objects queued for update.
|
||||
|
||||
SUBSYSTEM_DEF(lighting)
|
||||
name = "Lighting"
|
||||
wait = 2
|
||||
init_order = INIT_ORDER_LIGHTING
|
||||
flags = SS_TICKER
|
||||
var/static/list/sources_queue = list() // List of lighting sources queued for update.
|
||||
var/static/list/corners_queue = list() // List of lighting corners queued for update.
|
||||
var/static/list/objects_queue = list() // List of lighting objects queued for update.
|
||||
|
||||
/datum/controller/subsystem/lighting/stat_entry(msg)
|
||||
msg = "L:[length(sources_queue)]|C:[length(corners_queue)]|O:[length(objects_queue)]"
|
||||
msg = "L:[length(GLOB.lighting_update_lights)]|C:[length(GLOB.lighting_update_corners)]|O:[length(GLOB.lighting_update_objects)]"
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -31,10 +32,9 @@ SUBSYSTEM_DEF(lighting)
|
||||
MC_SPLIT_TICK_INIT(3)
|
||||
if(!init_tick_checks)
|
||||
MC_SPLIT_TICK
|
||||
var/list/queue = sources_queue
|
||||
var/i = 0
|
||||
for (i in 1 to length(queue))
|
||||
var/datum/light_source/L = queue[i]
|
||||
for (i in 1 to GLOB.lighting_update_lights.len)
|
||||
var/datum/light_source/L = GLOB.lighting_update_lights[i]
|
||||
|
||||
L.update_corners()
|
||||
|
||||
@@ -45,15 +45,14 @@ SUBSYSTEM_DEF(lighting)
|
||||
else if (MC_TICK_CHECK)
|
||||
break
|
||||
if (i)
|
||||
queue.Cut(1, i+1)
|
||||
GLOB.lighting_update_lights.Cut(1, i+1)
|
||||
i = 0
|
||||
|
||||
if(!init_tick_checks)
|
||||
MC_SPLIT_TICK
|
||||
|
||||
queue = corners_queue
|
||||
for (i in 1 to length(queue))
|
||||
var/datum/lighting_corner/C = queue[i]
|
||||
for (i in 1 to GLOB.lighting_update_corners.len)
|
||||
var/datum/lighting_corner/C = GLOB.lighting_update_corners[i]
|
||||
|
||||
C.update_objects()
|
||||
C.needs_update = FALSE
|
||||
@@ -62,16 +61,15 @@ SUBSYSTEM_DEF(lighting)
|
||||
else if (MC_TICK_CHECK)
|
||||
break
|
||||
if (i)
|
||||
queue.Cut(1, i+1)
|
||||
GLOB.lighting_update_corners.Cut(1, i+1)
|
||||
i = 0
|
||||
|
||||
|
||||
if(!init_tick_checks)
|
||||
MC_SPLIT_TICK
|
||||
|
||||
queue = objects_queue
|
||||
for (i in 1 to length(queue))
|
||||
var/atom/movable/lighting_object/O = queue[i]
|
||||
for (i in 1 to GLOB.lighting_update_objects.len)
|
||||
var/atom/movable/lighting_object/O = GLOB.lighting_update_objects[i]
|
||||
|
||||
if (QDELETED(O))
|
||||
continue
|
||||
@@ -83,7 +81,7 @@ SUBSYSTEM_DEF(lighting)
|
||||
else if (MC_TICK_CHECK)
|
||||
break
|
||||
if (i)
|
||||
queue.Cut(1, i+1)
|
||||
GLOB.lighting_update_objects.Cut(1, i+1)
|
||||
|
||||
|
||||
/datum/controller/subsystem/lighting/Recover()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
SUBSYSTEM_DEF(min_spawns)
|
||||
name = "Minimum Spawns" /// this hot steaming pile of garbage makes sure theres a minimum of tendrils scattered around
|
||||
init_order = INIT_ORDER_DEFAULT
|
||||
flags = SS_BACKGROUND | SS_NO_FIRE | SS_ALWAYS_SHOW_STAT
|
||||
flags = SS_BACKGROUND | SS_NO_FIRE
|
||||
wait = 2
|
||||
var/where_we_droppin_boys_iterations = 0
|
||||
var/snaxi_snowflake_check = FALSE
|
||||
@@ -71,7 +71,7 @@ GLOBAL_LIST_INIT(minimum_snow_under_spawns, list(
|
||||
continue
|
||||
if(typesof(/turf/open/lava) in orange(9, TT))
|
||||
continue
|
||||
valid_mining_turfs_2.Add(TT)
|
||||
valid_mining_turfs_2.Add(TT)
|
||||
else
|
||||
for(var/z_level in SSmapping.levels_by_trait(ZTRAIT_LAVA_RUINS))
|
||||
for(var/turf/TT in Z_TURFS(z_level))
|
||||
@@ -103,14 +103,14 @@ GLOBAL_LIST_INIT(minimum_snow_under_spawns, list(
|
||||
for(var/mob/living/simple_animal/hostile/megafauna/H in urange(70,RT)) //prevents mob clumps
|
||||
if((istype(MS_tospawn, /mob/living/simple_animal/hostile/megafauna)) && get_dist(RT, H) <= 70)
|
||||
active_spawns.Add(MS_tospawn)
|
||||
continue //let's try not to dump megas too close to each other?
|
||||
continue //let's try not to dump megas too close to each other?
|
||||
if((istype(MS_tospawn, /obj/structure/spawner)) && get_dist(RT, H) <= 40)
|
||||
active_spawns.Add(MS_tospawn)
|
||||
continue //let's at least /try/ to space these out?
|
||||
for(var/obj/structure/spawner/LT in urange(70,RT)) //prevents tendril/mega clumps
|
||||
if((istype(MS_tospawn, /mob/living/simple_animal/hostile/megafauna)) && get_dist(RT, LT) <= 70)
|
||||
active_spawns.Add(MS_tospawn)
|
||||
continue //let's try not to dump megas too close to each other?
|
||||
continue //let's try not to dump megas too close to each other?
|
||||
if((istype(MS_tospawn, /obj/structure/spawner)) && get_dist(RT, LT) <= 40)
|
||||
active_spawns.Add(MS_tospawn)
|
||||
continue //let's at least /try/ to space these out?
|
||||
@@ -127,7 +127,7 @@ GLOBAL_LIST_INIT(minimum_snow_under_spawns, list(
|
||||
for(var/mob/living/simple_animal/hostile/H in urange(70,RT2)) //prevents mob clumps
|
||||
if((istype(MS2_tospawn, /mob/living/simple_animal/hostile/megafauna) || ismegafauna(H)) && get_dist(RT2, H) <= 70)
|
||||
active_spawns_2.Add(MS2_tospawn)
|
||||
continue //let's try not to dump megas too close to each other?
|
||||
continue //let's try not to dump megas too close to each other?
|
||||
if((istype(MS2_tospawn, /obj/structure/spawner)) && get_dist(RT2, H) <= 40)
|
||||
active_spawns_2.Add(MS2_tospawn)
|
||||
continue //let's at least /try/ to space these out?
|
||||
|
||||
@@ -57,6 +57,7 @@ SUBSYSTEM_DEF(throwing)
|
||||
var/dx
|
||||
var/dy
|
||||
var/force = MOVE_FORCE_DEFAULT
|
||||
var/gentle = FALSE
|
||||
var/pure_diagonal
|
||||
var/diagonal_error
|
||||
var/datum/callback/callback
|
||||
@@ -64,15 +65,42 @@ SUBSYSTEM_DEF(throwing)
|
||||
var/delayed_time = 0
|
||||
var/last_move = 0
|
||||
|
||||
|
||||
/datum/thrownthing/New(thrownthing, target, target_turf, init_dir, maxrange, speed, thrower, diagonals_first, force, gentle, callback, target_zone)
|
||||
. = ..()
|
||||
src.thrownthing = thrownthing
|
||||
RegisterSignal(thrownthing, COMSIG_PARENT_QDELETING, .proc/on_thrownthing_qdel)
|
||||
src.target = target
|
||||
src.target_turf = target_turf
|
||||
src.init_dir = init_dir
|
||||
src.maxrange = maxrange
|
||||
src.speed = speed
|
||||
src.thrower = thrower
|
||||
src.diagonals_first = diagonals_first
|
||||
src.force = force
|
||||
src.gentle = gentle
|
||||
src.callback = callback
|
||||
src.target_zone = target_zone
|
||||
|
||||
|
||||
/datum/thrownthing/Destroy()
|
||||
SSthrowing.processing -= thrownthing
|
||||
thrownthing.throwing = null
|
||||
thrownthing = null
|
||||
target = null
|
||||
thrower = null
|
||||
callback = null
|
||||
if(callback)
|
||||
QDEL_NULL(callback) //It stores a reference to the thrownthing, its source. Let's clean that.
|
||||
return ..()
|
||||
|
||||
|
||||
///Defines the datum behavior on the thrownthing's qdeletion event.
|
||||
/datum/thrownthing/proc/on_thrownthing_qdel(atom/movable/source, force)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
qdel(src)
|
||||
|
||||
|
||||
/datum/thrownthing/proc/tick()
|
||||
var/atom/movable/AM = thrownthing
|
||||
if (!isturf(AM.loc) || !AM.throwing)
|
||||
@@ -112,7 +140,7 @@ SUBSYSTEM_DEF(throwing)
|
||||
finalize()
|
||||
return
|
||||
|
||||
AM.Move(step, get_dir(AM, step))
|
||||
AM.Move(step, get_dir(AM, step), DELAY_TO_GLIDE_SIZE(1 / speed))
|
||||
|
||||
if (!AM.throwing) // we hit something during our move
|
||||
finalize(hit = TRUE)
|
||||
@@ -136,15 +164,21 @@ SUBSYSTEM_DEF(throwing)
|
||||
if (A == target)
|
||||
hit = TRUE
|
||||
thrownthing.throw_impact(A, src)
|
||||
if(QDELETED(thrownthing)) //throw_impact can delete things, such as glasses smashing
|
||||
return //deletion should already be handled by on_thrownthing_qdel()
|
||||
break
|
||||
if (!hit)
|
||||
thrownthing.throw_impact(get_turf(thrownthing), src) // we haven't hit something yet and we still must, let's hit the ground.
|
||||
if(QDELETED(thrownthing)) //throw_impact can delete things, such as glasses smashing
|
||||
return //deletion should already be handled by on_thrownthing_qdel()
|
||||
thrownthing.newtonian_move(init_dir)
|
||||
else
|
||||
thrownthing.newtonian_move(init_dir)
|
||||
|
||||
if(target)
|
||||
thrownthing.throw_impact(target, src)
|
||||
if(QDELETED(thrownthing)) //throw_impact can delete things, such as glasses smashing
|
||||
return //deletion should already be handled by on_thrownthing_qdel()
|
||||
|
||||
if (callback)
|
||||
callback.Invoke()
|
||||
|
||||
@@ -5,10 +5,12 @@ SUBSYSTEM_DEF(vis_overlays)
|
||||
init_order = INIT_ORDER_VIS
|
||||
|
||||
var/list/vis_overlay_cache
|
||||
var/list/unique_vis_overlays
|
||||
var/list/currentrun
|
||||
|
||||
/datum/controller/subsystem/vis_overlays/Initialize()
|
||||
vis_overlay_cache = list()
|
||||
unique_vis_overlays = list()
|
||||
return ..()
|
||||
|
||||
/datum/controller/subsystem/vis_overlays/fire(resumed = FALSE)
|
||||
@@ -29,31 +31,45 @@ SUBSYSTEM_DEF(vis_overlays)
|
||||
return
|
||||
|
||||
//the "thing" var can be anything with vis_contents which includes images
|
||||
/datum/controller/subsystem/vis_overlays/proc/add_vis_overlay(atom/movable/thing, icon, iconstate, layer, plane, dir, alpha = 255, add_appearance_flags = NONE)
|
||||
. = "[icon]|[iconstate]|[layer]|[plane]|[dir]|[alpha]|[add_appearance_flags]"
|
||||
var/obj/effect/overlay/vis/overlay = vis_overlay_cache[.]
|
||||
if(!overlay)
|
||||
overlay = new
|
||||
overlay.icon = icon
|
||||
overlay.icon_state = iconstate
|
||||
overlay.layer = layer
|
||||
overlay.plane = plane
|
||||
overlay.dir = dir
|
||||
overlay.alpha = alpha
|
||||
overlay.appearance_flags |= add_appearance_flags
|
||||
vis_overlay_cache[.] = overlay
|
||||
/datum/controller/subsystem/vis_overlays/proc/add_vis_overlay(atom/movable/thing, icon, iconstate, layer, plane, dir, alpha = 255, add_appearance_flags = NONE, unique = FALSE)
|
||||
var/obj/effect/overlay/vis/overlay
|
||||
if(!unique)
|
||||
. = "[icon]|[iconstate]|[layer]|[plane]|[dir]|[alpha]|[add_appearance_flags]"
|
||||
overlay = vis_overlay_cache[.]
|
||||
if(!overlay)
|
||||
overlay = _create_new_vis_overlay(icon, iconstate, layer, plane, dir, alpha, add_appearance_flags)
|
||||
vis_overlay_cache[.] = overlay
|
||||
else
|
||||
overlay.unused = 0
|
||||
else
|
||||
overlay.unused = 0
|
||||
overlay = _create_new_vis_overlay(icon, iconstate, layer, plane, dir, alpha, add_appearance_flags)
|
||||
overlay.cache_expiration = -1
|
||||
var/cache_id = "\ref[overlay]@{[world.time]}"
|
||||
unique_vis_overlays += overlay
|
||||
vis_overlay_cache[cache_id] = overlay
|
||||
. = overlay
|
||||
thing.vis_contents += overlay
|
||||
|
||||
if(!isatom(thing)) // Automatic rotation is not supported on non atoms
|
||||
return
|
||||
return overlay
|
||||
|
||||
if(!thing.managed_vis_overlays)
|
||||
thing.managed_vis_overlays = list(overlay)
|
||||
RegisterSignal(thing, COMSIG_ATOM_DIR_CHANGE, .proc/rotate_vis_overlay)
|
||||
else
|
||||
thing.managed_vis_overlays += overlay
|
||||
return overlay
|
||||
|
||||
/datum/controller/subsystem/vis_overlays/proc/_create_new_vis_overlay(icon, iconstate, layer, plane, dir, alpha, add_appearance_flags)
|
||||
var/obj/effect/overlay/vis/overlay = new
|
||||
overlay.icon = icon
|
||||
overlay.icon_state = iconstate
|
||||
overlay.layer = layer
|
||||
overlay.plane = plane
|
||||
overlay.dir = dir
|
||||
overlay.alpha = alpha
|
||||
overlay.appearance_flags |= add_appearance_flags
|
||||
return overlay
|
||||
|
||||
|
||||
/datum/controller/subsystem/vis_overlays/proc/remove_vis_overlay(atom/movable/thing, list/overlays)
|
||||
thing.vis_contents -= overlays
|
||||
@@ -62,15 +78,3 @@ SUBSYSTEM_DEF(vis_overlays)
|
||||
thing.managed_vis_overlays -= overlays
|
||||
if(!length(thing.managed_vis_overlays))
|
||||
thing.managed_vis_overlays = null
|
||||
UnregisterSignal(thing, COMSIG_ATOM_DIR_CHANGE)
|
||||
|
||||
/datum/controller/subsystem/vis_overlays/proc/rotate_vis_overlay(atom/thing, old_dir, new_dir)
|
||||
if(old_dir == new_dir)
|
||||
return
|
||||
var/rotation = dir2angle(old_dir) - dir2angle(new_dir)
|
||||
var/list/overlays_to_remove = list()
|
||||
for(var/i in thing.managed_vis_overlays)
|
||||
var/obj/effect/overlay/vis/overlay = i
|
||||
add_vis_overlay(thing, overlay.icon, overlay.icon_state, overlay.layer, overlay.plane, turn(overlay.dir, rotation), overlay.alpha, overlay.appearance_flags)
|
||||
overlays_to_remove += overlay
|
||||
remove_vis_overlay(thing, overlays_to_remove)
|
||||
|
||||
Reference in New Issue
Block a user