mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-09 16:14:13 +00:00
Speeds up lights on at roundstart (#36623)
* Speeds up lights on at roundstart * cleaner * for all of em * this was faster * speeds this up too * updates desc * updates the area if used * even more speed cutdown!!! * makes it do itself too * moar logging * adds moody light * unnecessary addition * correct name * kills this * makes brighter * back to pre conflict merge state
This commit is contained in:
@@ -76,6 +76,7 @@
|
||||
var/copy_logs = null
|
||||
var/cargo_forwarding_on_roundstart = 0
|
||||
var/cargo_forwarding_amount_override = 0
|
||||
var/roundstart_lights_on = 0
|
||||
|
||||
// BSQL things
|
||||
var/bsql_debug = 0
|
||||
@@ -282,6 +283,9 @@
|
||||
|
||||
if ("cargo_forwarding_amount_override")
|
||||
cargo_forwarding_amount_override = text2num(value)
|
||||
|
||||
if("roundstart_lights_on")
|
||||
roundstart_lights_on = 1
|
||||
|
||||
if ("use_recursive_explosions")
|
||||
use_recursive_explosions = 1
|
||||
|
||||
@@ -9,6 +9,8 @@ var/area/space_area
|
||||
var/uid
|
||||
var/obj/machinery/power/apc/areaapc = null
|
||||
var/list/obj/machinery/alarm/air_alarms = list()
|
||||
var/list/obj/machinery/light_switch/lightswitches = list()
|
||||
var/list/obj/machinery/light/lights = list()
|
||||
var/list/area_turfs
|
||||
plane = ABOVE_LIGHTING_PLANE
|
||||
layer = MAPPING_AREA_LAYER
|
||||
|
||||
@@ -128,6 +128,7 @@ var/datum/controller/gameticker/ticker
|
||||
theme.update_icon()
|
||||
|
||||
/datum/controller/gameticker/proc/setup()
|
||||
var/total_tick = get_game_time()
|
||||
//Create and announce mode
|
||||
if(master_mode=="secret")
|
||||
hide_mode = 1
|
||||
@@ -215,27 +216,28 @@ var/datum/controller/gameticker/ticker
|
||||
CHECK_TICK
|
||||
|
||||
//Now that we have all of the occupied areas, we handle the lights being on or off, before actually putting the players into their bodies.
|
||||
if(roundstart_occupied_area_paths.len)
|
||||
var/tick = get_game_time()
|
||||
var/obj/machinery/light_switch/LS
|
||||
var/obj/machinery/light/lightykun
|
||||
var/obj/item/device/flashlight/lamp/lampychan
|
||||
for(var/area/A in areas)
|
||||
if(A.type in roundstart_occupied_area_paths)
|
||||
for(var/obj/O in A)
|
||||
LS = O
|
||||
lightykun = O
|
||||
lampychan = O
|
||||
if(istype(LS))
|
||||
LS.toggle_switch(1, playsound = FALSE)
|
||||
else if(istype(lightykun))
|
||||
lightykun.on = 1
|
||||
lightykun.update()
|
||||
else if(istype(lampychan))
|
||||
lampychan.toggle_onoff(1)
|
||||
if(config.roundstart_lights_on || roundstart_occupied_area_paths.len)
|
||||
var/light_tick = get_game_time()
|
||||
var/area/A
|
||||
for(var/obj/item/device/flashlight/lamp/lampychan in lamps)
|
||||
A = get_area(lampychan)
|
||||
if(config.roundstart_lights_on || (A.type in roundstart_occupied_area_paths))
|
||||
lampychan.toggle_onoff(1)
|
||||
for(var/obj/machinery/light_switch/LS in lightswitches)
|
||||
A = get_area(LS)
|
||||
if(config.roundstart_lights_on || (A.type in roundstart_occupied_area_paths))
|
||||
LS.toggle_switch(1, FALSE, FALSE)
|
||||
roundstart_occupied_area_paths -= A.type // lights are covered by this so skip these areas
|
||||
if(roundstart_occupied_area_paths.len)
|
||||
for(var/obj/machinery/light/lightykun in alllights)
|
||||
A = get_area(lightykun)
|
||||
if(config.roundstart_lights_on || (A.type in roundstart_occupied_area_paths))
|
||||
lightykun.on = 1
|
||||
lightykun.update()
|
||||
//Force the lighting subsystem to update.
|
||||
SSlighting.fire(FALSE, FALSE)
|
||||
log_admin("Turned the lights on in [(get_game_time() - tick) / 10] seconds.")
|
||||
log_admin("Turned the lights on in [(get_game_time() - light_tick) / 10] seconds.")
|
||||
message_admins("Turned the lights on in [(get_game_time() - light_tick) / 10] seconds.")
|
||||
|
||||
var/list/clowns = list()
|
||||
var/already_an_ai = FALSE
|
||||
@@ -313,6 +315,8 @@ var/datum/controller/gameticker/ticker
|
||||
Master.RoundStart()
|
||||
wageSetup()
|
||||
post_roundstart()
|
||||
log_admin("Roundstart complete in [(get_game_time() - total_tick) / 10] seconds.")
|
||||
message_admins("Roundstart complete in [(get_game_time() - total_tick) / 10] seconds.")
|
||||
return 1
|
||||
|
||||
/mob/living/carbon/human/proc/make_fake_ai()
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// the light switch
|
||||
// can have multiple per area
|
||||
// can also operate on non-loc area through "otherarea" var
|
||||
|
||||
var/list/obj/machinery/light_switch/lightswitches = list()
|
||||
|
||||
/obj/machinery/light_switch
|
||||
name = "light switch"
|
||||
desc = "It turns lights on and off. What are you, simple?"
|
||||
@@ -10,41 +13,37 @@
|
||||
var/buildstage = 2
|
||||
var/on = 0
|
||||
var/image/overlay
|
||||
var/area/controlled_area
|
||||
|
||||
/obj/machinery/light_switch/supports_holomap()
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/light_switch/New(var/loc, var/ndir, var/building = 2)
|
||||
..()
|
||||
var/area/this_area = get_area(src)
|
||||
name = "[this_area.name] light switch"
|
||||
controlled_area = get_area(src)
|
||||
name = "[controlled_area.name] light switch"
|
||||
buildstage = building
|
||||
this_area.haslightswitch = TRUE
|
||||
controlled_area.haslightswitch = TRUE
|
||||
lightswitches += src
|
||||
controlled_area.lightswitches += src
|
||||
if(!buildstage)
|
||||
pixel_x = (ndir & 3)? 0 : (ndir == 4 ? 28 * PIXEL_MULTIPLIER: -28 * PIXEL_MULTIPLIER)
|
||||
pixel_y = (ndir & 3)? (ndir ==1 ? 28 * PIXEL_MULTIPLIER: -28 * PIXEL_MULTIPLIER) : 0
|
||||
dir = ndir
|
||||
updateicon()
|
||||
update_moody_light('icons/lighting/moody_lights.dmi', "overlay_lightswitch")
|
||||
add_self_to_holomap()
|
||||
|
||||
/obj/machinery/light_switch/proc/updateicon()
|
||||
if(!overlay)
|
||||
overlay = image(icon, "light1-overlay")
|
||||
overlay.plane = ABOVE_LIGHTING_PLANE
|
||||
overlay.layer = ABOVE_LIGHTING_LAYER
|
||||
/obj/machinery/light_switch/Destroy()
|
||||
lightswitches -= src
|
||||
controlled_area.lightswitches -= src
|
||||
..()
|
||||
|
||||
overlays.Cut()
|
||||
/obj/machinery/light_switch/proc/updateicon()
|
||||
if((stat & (FORCEDISABLE|NOPOWER)) || buildstage != 2)
|
||||
icon_state = "light-p"
|
||||
set_light(0)
|
||||
else
|
||||
icon_state = on ? "light1" : "light0"
|
||||
overlay.icon_state = "[icon_state]-overlay"
|
||||
overlays += overlay
|
||||
//If the lightswitch itself is in total darkness, even the overlay won't render, so we gotta light up the lightswitch just a tiny bit.
|
||||
//...which, sadly, thanks to goonlights means "oops we have to softlight up the entire 3x3 around the lightswitch because we can't handle one-tile lights anymore"
|
||||
//Maybe vis-contents will bring a more elegant solution when we support them?
|
||||
set_light(1, 0.5, on ? "#82ff4c" : "#f86060")
|
||||
|
||||
/obj/machinery/light_switch/examine(mob/user)
|
||||
..()
|
||||
@@ -114,28 +113,32 @@
|
||||
/obj/machinery/light_switch/attack_hand(mob/user)
|
||||
toggle_switch()
|
||||
|
||||
/obj/machinery/light_switch/proc/toggle_switch(var/newstate = null, var/playsound = TRUE)
|
||||
if(buildstage != 2)
|
||||
/obj/machinery/light_switch/proc/toggle_switch(var/newstate = null, var/playsound = TRUE, var/non_instant = TRUE)
|
||||
if(on == newstate)
|
||||
return
|
||||
|
||||
if(isnull(newstate))
|
||||
on = !on
|
||||
else if(on != newstate)
|
||||
on = newstate
|
||||
else
|
||||
on = newstate
|
||||
|
||||
if(buildstage != 2)
|
||||
return
|
||||
|
||||
if(playsound)
|
||||
playsound(src,'sound/misc/click.ogg',30,0,-1)
|
||||
|
||||
var/area/this_area = get_area(src)
|
||||
this_area.updateicon()
|
||||
if(controlled_area)
|
||||
controlled_area.lightswitches -= src
|
||||
controlled_area = get_area(src)
|
||||
controlled_area.lightswitches |= src
|
||||
controlled_area.updateicon()
|
||||
|
||||
for(var/obj/machinery/light_switch/L in this_area)
|
||||
for(var/obj/machinery/light_switch/L in controlled_area.lightswitches)
|
||||
L.on = on
|
||||
L.updateicon()
|
||||
|
||||
this_area.power_change()
|
||||
for(var/obj/machinery/L2 in controlled_area.lights)
|
||||
L2.power_change(non_instant)
|
||||
|
||||
/obj/machinery/light_switch/power_change()
|
||||
if(powered(LIGHT))
|
||||
|
||||
@@ -242,14 +242,20 @@
|
||||
on = onoff
|
||||
update_brightness(playsound = FALSE)
|
||||
|
||||
var/list/obj/item/device/flashlight/lamp/lamps = list()
|
||||
//Lamps draw power from the area they're in, unlike flashlights.
|
||||
/obj/item/device/flashlight/lamp/New()
|
||||
lamps += src
|
||||
if(drawspower)
|
||||
pwrconn = new(src)
|
||||
pwrconn.channel = LIGHT
|
||||
pwrconn.active_usage = 60 * brightness_on / 5 //power usage scales with brightness
|
||||
update_brightness(playsound = FALSE)
|
||||
|
||||
/obj/item/device/flashlight/lamp/Destroy()
|
||||
lamps -= src
|
||||
..()
|
||||
|
||||
/obj/item/device/flashlight/lamp/update_brightness(var/mob/user = null, var/playsound = TRUE)
|
||||
if(drawspower)
|
||||
if(on)
|
||||
|
||||
@@ -863,8 +863,8 @@ var/global/floorIsLava = 0
|
||||
<A href='?src=\ref[src];secretsfun=makelink'>Fix the station's link with Central Command</A><BR>
|
||||
<A href='?src=\ref[src];secretsfun=blackout'>Break all lights</A><BR>
|
||||
<A href='?src=\ref[src];secretsfun=whiteout'>Fix all lights</A><BR>
|
||||
<A href='?src=\ref[src];secretsfun=switchoff'>Flip all (ALL Z-LEVELS) light switches to off (Lags briefly)</A><BR>
|
||||
<A href='?src=\ref[src];secretsfun=switchon'>Flip all (ALL Z-LEVELS) light switches to on (Lags briefly)</A><BR>
|
||||
<A href='?src=\ref[src];secretsfun=switchoff'>Flip all (ALL Z-LEVELS) light switches to off</A><BR>
|
||||
<A href='?src=\ref[src];secretsfun=switchon'>Flip all (ALL Z-LEVELS) light switches to on</A><BR>
|
||||
<A href='?src=\ref[src];secretsfun=create_artifact'>Create custom artifact</A><BR>
|
||||
<BR>
|
||||
<A href='?src=\ref[src];secretsfun=athfthrowing'>Toggle thrown items exploding on stop</A><BR>
|
||||
|
||||
@@ -3572,13 +3572,13 @@
|
||||
if("switchoff")
|
||||
feedback_inc("admin_secrets_fun_used",1)
|
||||
feedback_add_details("admin_secrets_fun_used","WO")
|
||||
for(var/obj/machinery/light_switch/LS in all_machines)
|
||||
for(var/obj/machinery/light_switch/LS in lightswitches)
|
||||
LS.toggle_switch(0)
|
||||
message_admins("[key_name_admin(usr)] switched off all lights", 1)
|
||||
if("switchon")
|
||||
feedback_inc("admin_secrets_fun_used",1)
|
||||
feedback_add_details("admin_secrets_fun_used","WO")
|
||||
for(var/obj/machinery/light_switch/LS in all_machines)
|
||||
for(var/obj/machinery/light_switch/LS in lightswitches)
|
||||
LS.toggle_switch(1)
|
||||
message_admins("[key_name_admin(usr)] switched on all lights", 1)
|
||||
if("floorlava")
|
||||
|
||||
@@ -136,6 +136,7 @@ var/global/list/obj/machinery/light/alllights = list()
|
||||
var/static_power_used = 0
|
||||
var/flickering = 0
|
||||
var/obj/item/weapon/light/current_bulb = null
|
||||
var/area/lights_area
|
||||
var/spawn_with_bulb = /obj/item/weapon/light/tube
|
||||
var/fitting = "tube"
|
||||
var/rgb_upgrade = FALSE //add plastic to enable RGB mode
|
||||
@@ -154,6 +155,9 @@ var/global/list/obj/machinery/light/alllights = list()
|
||||
else
|
||||
update(0)
|
||||
alllights += src
|
||||
lights_area = get_area(src)
|
||||
if(lights_area)
|
||||
lights_area.lights += src
|
||||
|
||||
if(map.broken_lights)
|
||||
switch(fitting)
|
||||
@@ -240,6 +244,8 @@ var/global/list/obj/machinery/light/alllights = list()
|
||||
seton(0)
|
||||
..()
|
||||
alllights -= src
|
||||
if(lights_area)
|
||||
lights_area.lights -= src
|
||||
|
||||
/obj/machinery/light/update_icon()
|
||||
|
||||
@@ -462,7 +468,7 @@ var/global/list/obj/machinery/light/alllights = list()
|
||||
return FALSE
|
||||
if(!this_area.haslightswitch || !this_area.requires_power)
|
||||
return TRUE
|
||||
for(var/obj/machinery/light_switch/L in this_area)
|
||||
for(var/obj/machinery/light_switch/L in this_area.lightswitches)
|
||||
if(L.on)
|
||||
success = TRUE
|
||||
break
|
||||
@@ -628,8 +634,8 @@ var/global/list/obj/machinery/light/alllights = list()
|
||||
/*
|
||||
* Called when area power state changes.
|
||||
*/
|
||||
/obj/machinery/light/power_change()
|
||||
spawn(10)
|
||||
/obj/machinery/light/power_change(var/non_instant = TRUE)
|
||||
spawn(10 * non_instant)
|
||||
seton(has_power())
|
||||
|
||||
// called when on fire
|
||||
|
||||
@@ -37,6 +37,9 @@ JOBS_HAVE_MINIMAL_ACCESS
|
||||
## Remove # here if you wish to have cargo forwards sent always be a set amount (for debugging)
|
||||
#CARGO_FORWARDING_AMOUNT_OVERRIDE 5
|
||||
|
||||
## Remove # here if you wish to have all lights on by default at roundstart
|
||||
ROUNDSTART_LIGHTS_ON
|
||||
|
||||
## (SECURITY RISK ON PUBLIC SERVERS) Automatically give localhost clients +HOST access.
|
||||
LOCALHOST_AUTOADMIN
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 34 KiB |
Reference in New Issue
Block a user