Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Area tweaks #20391

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aurorastation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
#include "code\__DEFINES\dcs\flags.dm"
#include "code\__DEFINES\dcs\helpers.dm"
#include "code\__DEFINES\dcs\signals.dm"
#include "code\__DEFINES\dcs\signals\signals_area.dm"
#include "code\__DEFINES\dcs\signals\signals_datum.dm"
#include "code\__DEFINES\dcs\signals\signals_global.dm"
#include "code\__DEFINES\dcs\signals\signals_lore_radio.dm"
Expand Down
14 changes: 14 additions & 0 deletions code/__DEFINES/dcs/signals/signals_area.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Area signals. Format:
// When the signal is called: (signal arguments)
// All signals send the source datum of the signal as the first argument

///from base of area/proc/power_change(): ()
#define COMSIG_AREA_POWER_CHANGE "area_power_change"
///from base of area/Entered(): (atom/movable/arrived, area/old_area)
#define COMSIG_AREA_ENTERED "area_entered"
///from base of area/Exited(): (atom/movable/gone, direction)
#define COMSIG_AREA_EXITED "area_exited"
///from base of area/Entered(): (area/new_area). Sent to "area-sensitive" movables, see __DEFINES/traits.dm for info.
#define COMSIG_ENTER_AREA "enter_area"
///from base of area/Exited(): (area). Sent to "area-sensitive" movables, see __DEFINES/traits.dm for info.
#define COMSIG_EXIT_AREA "exit_area"
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@
/// from base of atom/movable/Process_Spacemove(): (movement_dir, continuous_move)
#define COMSIG_MOVABLE_SPACEMOVE "spacemove"
#define COMSIG_MOVABLE_STOP_SPACEMOVE (1<<0)

/// From base of area/Exited(): (area/left, direction)
#define COMSIG_MOVABLE_EXITED_AREA "movable_exited_area"
8 changes: 4 additions & 4 deletions code/__DEFINES/machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

// Channel numbers for power.
#define POWER_CHAN -1 // Use default
#define EQUIP 1
#define LIGHT 2
#define ENVIRON 3
#define TOTAL 4 // For total power used only.
#define AREA_USAGE_EQUIP 1
#define AREA_USAGE_LIGHT 2
#define AREA_USAGE_ENVIRON 3
#define AREA_USAGE_TOTAL 4 // For total power used only.

#define POWER_USE_OFF 0
#define POWER_USE_IDLE 1
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/turfs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@

if(target)
if(base_area)
ChangeArea(target, get_area(source))
target.change_area(target.loc, get_area(source))
. += transport_turf_contents(source, target, ignore_background)
ChangeArea(source, base_area)
source.change_area(source.loc, base_area)
else
. += transport_turf_contents(source, target, ignore_background)
//change the old turfs
Expand Down
43 changes: 23 additions & 20 deletions code/game/area/area_power.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
#define EQUIP 1
#define LIGHT 2
#define ENVIRON 3
#define AREA_USAGE_EQUIP 1
#define AREA_USAGE_LIGHT 2
#define AREA_USAGE_ENVIRON 3
*/

/area/proc/powered(var/chan) // return true if the area has power to given channel
Expand All @@ -11,32 +11,35 @@
if(always_unpowered)
return FALSE
switch(chan)
if(EQUIP)
if(AREA_USAGE_EQUIP)
return power_equip
if(LIGHT)
if(AREA_USAGE_LIGHT)
return power_light
if(ENVIRON)
if(AREA_USAGE_ENVIRON)
return power_environ

return FALSE

// called when power status changes
/area/proc/power_change()
SEND_SIGNAL(src, COMSIG_AREA_POWER_CHANGE)

//One day, this will only use the signal, but that day is not today
for(var/obj/machinery/M in src) // for each machine in the area
M.power_change() // reverify power status (to update icons etc.)
if (fire || eject || party)
update_icon()

/area/proc/usage(var/chan)
switch(chan)
if(LIGHT)
if(AREA_USAGE_LIGHT)
return used_light + oneoff_light
if(EQUIP)
if(AREA_USAGE_EQUIP)
return used_equip + oneoff_equip
if(ENVIRON)
if(AREA_USAGE_ENVIRON)
return used_environ + oneoff_environ
if(TOTAL)
return .(LIGHT) + .(EQUIP) + .(ENVIRON)
if(AREA_USAGE_TOTAL)
return .(AREA_USAGE_LIGHT) + .(AREA_USAGE_EQUIP) + .(AREA_USAGE_ENVIRON)

/area/proc/clear_usage()
oneoff_equip = 0
Expand All @@ -50,11 +53,11 @@
*/
/area/proc/use_power(var/amount, var/chan)
switch(chan)
if(EQUIP)
if(AREA_USAGE_EQUIP)
used_equip += amount
if(LIGHT)
if(AREA_USAGE_LIGHT)
used_light += amount
if(ENVIRON)
if(AREA_USAGE_ENVIRON)
used_environ += amount

// Used by machines to update the area of power changes.
Expand All @@ -64,11 +67,11 @@
// Use this for one-time power draws from the area, usually for non-machines.
/area/proc/use_power_oneoff(var/amount, var/chan)
switch(chan)
if(EQUIP)
if(AREA_USAGE_EQUIP)
oneoff_equip += amount
if(LIGHT)
if(AREA_USAGE_LIGHT)
oneoff_light += amount
if(ENVIRON)
if(AREA_USAGE_ENVIRON)
oneoff_environ += amount

// This recomputes continued power usage; used for testing or error recovery.
Expand All @@ -79,9 +82,9 @@

for(var/obj/machinery/M in src)
switch(M.power_channel)
if(EQUIP)
if(AREA_USAGE_EQUIP)
used_equip += M.get_power_usage()
if(LIGHT)
if(AREA_USAGE_LIGHT)
used_light += M.get_power_usage()
if(ENVIRON)
if(AREA_USAGE_ENVIRON)
used_environ += M.get_power_usage()
68 changes: 38 additions & 30 deletions code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ var/global/list/area_blurb_stated_to = list()
///Bitflag (Any of `AREA_FLAG_*`). See `code\__DEFINES\misc.dm`.
var/area_flags
var/holomap_color // Color of this area on the holomap. Must be a hex color (as string) or null.
var/fire = null

///Do we have an active fire alarm?
var/fire = FALSE

var/atmosalm = 0
var/poweralm = 1
var/party = null
Expand All @@ -27,6 +30,7 @@ var/global/list/area_blurb_stated_to = list()
layer = AREA_LAYER
luminosity = 0
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
invisibility = INVISIBILITY_LIGHTING

var/obj/machinery/power/apc/apc = null
var/turf/base_turf // The base turf type of the area, which can be used to override the z-level's base turf.
Expand Down Expand Up @@ -317,12 +321,27 @@ var/global/list/area_blurb_stated_to = list()

#undef DO_PARTY

var/list/mob/living/forced_ambiance_list = new
/**
* Call back when an atom enters an area
*
* Sends signals COMSIG_AREA_ENTERED and COMSIG_ENTER_AREA (to a list of atoms)
*
* If the area has ambience, then it plays some ambience music to the ambience channel
*/
/area/Entered(atom/movable/arrived, area/old_area)
SEND_SIGNAL(src, COMSIG_AREA_ENTERED, arrived, old_area)

if(!arrived.important_recursive_contents?[RECURSIVE_CONTENTS_AREA_SENSITIVE])
return
for(var/atom/movable/recipient as anything in arrived.important_recursive_contents[RECURSIVE_CONTENTS_AREA_SENSITIVE])
SEND_SIGNAL(recipient, COMSIG_ENTER_AREA, src)

/area/Entered(mob/living/L)
if(!istype(L, /mob/living) || !ROUND_IS_STARTED)
/* START aurora snowflake code */
if(!istype(arrived, /mob/living) || !ROUND_IS_STARTED)
return

var/mob/living/L = arrived

if(!L.ckey) return

if(!L.lastarea)
Expand Down Expand Up @@ -362,6 +381,21 @@ var/list/mob/living/forced_ambiance_list = new
stop_music(L)
do_area_blurb(L)

/* END aurora snowflake code */

/**
* Called when an atom exits an area
*
* Sends signals COMSIG_AREA_EXITED and COMSIG_EXIT_AREA (to a list of atoms)
*/
/area/Exited(atom/movable/gone, direction)
SEND_SIGNAL(src, COMSIG_AREA_EXITED, gone, direction)
SEND_SIGNAL(gone, COMSIG_MOVABLE_EXITED_AREA, src, direction)
if(!gone.important_recursive_contents?[RECURSIVE_CONTENTS_AREA_SENSITIVE])
return
for(var/atom/movable/recipient as anything in gone.important_recursive_contents[RECURSIVE_CONTENTS_AREA_SENSITIVE])
SEND_SIGNAL(recipient, COMSIG_EXIT_AREA, src)

// Play Ambience
/area/proc/play_ambience(var/mob/living/L)
if((world.time >= L.client.ambience_last_played_time + 5 MINUTES) && prob(20))
Expand Down Expand Up @@ -484,32 +518,6 @@ var/list/mob/living/forced_ambiance_list = new
return pick(turfs)
else return null

// Changes the area of T to A. Do not do this manually.
// Area is expected to be a non-null instance.
/proc/ChangeArea(var/turf/T, var/area/A)
if(!istype(A))
CRASH("Area change attempt failed: invalid area supplied.")
var/old_outside = T.is_outside()
var/area/old_area = get_area(T)
if(old_area == A)
return
A.contents.Add(T)
if(old_area)
old_area.Exited(T, A)
for(var/atom/movable/AM in T)
old_area.Exited(AM, A)
A.Entered(T, old_area)
for(var/atom/movable/AM in T)
A.Entered(AM, old_area)

for(var/obj/machinery/M in T)
M.shuttle_move(T)

T.last_outside_check = OUTSIDE_UNCERTAIN
var/outside_changed = T.is_outside() != old_outside
if(T.is_outside == OUTSIDE_AREA && outside_changed)
T.update_weather()

/**
* Displays an area blurb on a mob's screen.
*
Expand Down
6 changes: 0 additions & 6 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,6 @@
if(src.z == H.z && get_dist(src, H) <= range)
H.intent_listen(src, message)

/atom/proc/change_area(var/area/oldarea, var/area/newarea)
change_area_name(oldarea.name, newarea.name)

/atom/proc/change_area_name(var/oldname, var/newname)
name = replacetext(name,oldname,newname)

/atom/movable/proc/dropInto(var/atom/destination)
while(istype(destination))
var/atom/drop_destination = destination.onDropInto(src)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/abstract/intercom_listener.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/obj/machinery/abstract/intercom_listener
name = "intercom power interface"
desc = DESC_PARENT
power_channel = EQUIP
power_channel = AREA_USAGE_EQUIP

var/obj/item/device/radio/intercom/master

Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/alarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pixel_x = 10;
anchored = 1
idle_power_usage = 90
active_power_usage = 1500 //For heating/cooling rooms. 1000 joules equates to about 1 degree every 2 seconds for a single tile of air.
power_channel = ENVIRON
power_channel = AREA_USAGE_ENVIRON
req_one_access = list(ACCESS_ATMOSPHERICS, ACCESS_ENGINE_EQUIP)
clicksound = /singleton/sound_category/button_sound
clickvol = 30
Expand Down Expand Up @@ -472,7 +472,7 @@ pixel_x = 10;
var/energy_used = min( gas.get_thermal_energy_change(target_temperature) , active_power_usage * seconds_per_tick)

gas.add_thermal_energy(energy_used)
//use_power(energy_used, ENVIRON) //handle by update_use_power instead
//use_power(energy_used, AREA_USAGE_ENVIRON) //handle by update_use_power instead
else //gas cooling
var/heat_transfer = min(abs(gas.get_thermal_energy_change(target_temperature)), active_power_usage * seconds_per_tick)

Expand All @@ -485,7 +485,7 @@ pixel_x = 10;

heat_transfer = -gas.add_thermal_energy(-heat_transfer) //get the actual heat transfer

//use_power(heat_transfer / cop, ENVIRON) //handle by update_use_power instead
//use_power(heat_transfer / cop, AREA_USAGE_ENVIRON) //handle by update_use_power instead

environment.merge(gas)

Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/atmoalter/meter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
icon_state = "meter_base"
var/obj/machinery/atmospherics/pipe/target = null
anchored = 1.0
power_channel = ENVIRON
power_channel = AREA_USAGE_ENVIRON
var/frequency = 0
var/id
idle_power_usage = 15
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/case_button.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
anchored = 1
idle_power_usage = 50 //50W because the forcefield is disabled
active_power_usage = 2000 //2kW because of the forcefield
power_channel = EQUIP
power_channel = AREA_USAGE_EQUIP
req_access = list(ACCESS_KEYCARD_AUTH) //Access required to unlock the cover
//Style variables
var/case = 1 //What case to use - c value
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/cell_charger.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
anchored = TRUE
idle_power_usage = 5
active_power_usage = 90 KILO WATTS
power_channel = EQUIP
power_channel = AREA_USAGE_EQUIP
update_icon_on_init = TRUE

var/obj/item/cell/charging = null
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/crusher_piston.dm
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@

var/image_overlay
var/emissive_overlay
if(powered(EQUIP))
if(powered(AREA_USAGE_EQUIP))
if(blocked == 1)
image_overlay = image(icon, "[asmtype]-overlay-red")
emissive_overlay = emissive_appearance(icon, "[asmtype]-overlay-red")
Expand Down Expand Up @@ -193,7 +193,7 @@
if(action == "idle")
action_start_time = world.time
initial = 1
else if(action == "extend" && blocked == 0 && powered(EQUIP))
else if(action == "extend" && blocked == 0 && powered(AREA_USAGE_EQUIP))
//If we are idle, flash the warning lights and then put us into pre_start once we are done
if(status == "idle")
if(initial)
Expand Down Expand Up @@ -271,7 +271,7 @@
update_icon()

//Retract the pistons
else if(action == "retract" && blocked == 0 && powered(EQUIP)) //Only retract if unblocked
else if(action == "retract" && blocked == 0 && powered(AREA_USAGE_EQUIP)) //Only retract if unblocked
update_icon()
num_progress = 0

Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/deployable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Deployable Kits

/obj/item/deployable_kit/remote_mech/attack_self(mob/user)
var/area/A = get_area(user)
if(!A.powered(EQUIP))
if(!A.powered(AREA_USAGE_EQUIP))
to_chat(user, SPAN_WARNING("\The [src] can not be deployed in an unpowered area."))
return FALSE
..()
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/door_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "remote object control"
desc = "It controls objects, remotely."
icon_state = "doorctrl0"
power_channel = ENVIRON
power_channel = AREA_USAGE_ENVIRON
var/desiredstate = 0
var/exposedwires = 0
var/wires = 3
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
name = "airlock"
icon = 'icons/obj/doors/basic/single/generic/door.dmi'
icon_state = "preview"
power_channel = ENVIRON
power_channel = AREA_USAGE_ENVIRON

explosion_resistance = 10
autoclose = TRUE
Expand Down
Loading
Loading