mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 05:30:05 +01:00
Speeds up area power usage handling, and apc process(). Cleans up related code (#51002)
About The Pull Request /area/proc/usage() attempts to give list-like access to a bunch of vars. Why not make it a list instead and avoid all the proc calls? Might be room for followup here, to do something to powered(), use_power() etc. Some legacy machinery was ignoring the default machinery use_power pulling from the machine's power channel by default Total power usage was unused, APCs ignored it in favor of calculating it themselves :) I also renamed the defines because they were in the danger zone of being very common words. Changelog cl Naksu code: optimized area power usage calculations. /cl
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
// channel numbers for power
|
||||
#define EQUIP 1
|
||||
#define LIGHT 2
|
||||
#define ENVIRON 3
|
||||
#define TOTAL 4 //for total power used only
|
||||
#define STATIC_EQUIP 5
|
||||
#define STATIC_LIGHT 6
|
||||
#define STATIC_ENVIRON 7
|
||||
// These are indexes in a list, and indexes for "dynamic" and static channels should be kept contiguous
|
||||
#define AREA_USAGE_EQUIP 1
|
||||
#define AREA_USAGE_LIGHT 2
|
||||
#define AREA_USAGE_ENVIRON 3
|
||||
#define AREA_USAGE_STATIC_EQUIP 4
|
||||
#define AREA_USAGE_STATIC_LIGHT 5
|
||||
#define AREA_USAGE_STATIC_ENVIRON 6
|
||||
#define AREA_USAGE_LEN AREA_USAGE_STATIC_ENVIRON // largest idx
|
||||
/// Index of the first dynamic usage channel
|
||||
#define AREA_USAGE_DYNAMIC_START AREA_USAGE_EQUIP
|
||||
/// Index of the last dynamic usage channel
|
||||
#define AREA_USAGE_DYNAMIC_END AREA_USAGE_ENVIRON
|
||||
/// Index of the first static usage channel
|
||||
#define AREA_USAGE_STATIC_START AREA_USAGE_STATIC_EQUIP
|
||||
/// Index of the last static usage channel
|
||||
#define AREA_USAGE_STATIC_END AREA_USAGE_STATIC_ENVIRON
|
||||
|
||||
|
||||
//Power use
|
||||
#define NO_POWER_USE 0
|
||||
|
||||
+17
-49
@@ -43,12 +43,6 @@
|
||||
var/power_equip = TRUE
|
||||
var/power_light = TRUE
|
||||
var/power_environ = TRUE
|
||||
var/used_equip = 0
|
||||
var/used_light = 0
|
||||
var/used_environ = 0
|
||||
var/static_equip
|
||||
var/static_light = 0
|
||||
var/static_environ
|
||||
|
||||
var/has_gravity = 0
|
||||
///Are you forbidden from teleporting to the area? (centcom, mobs, wizard, hand teleporter)
|
||||
@@ -76,6 +70,9 @@
|
||||
/// typecache to limit the areas that atoms in this area can smooth with, used for shuttles IIRC
|
||||
var/list/canSmoothWithAreas
|
||||
|
||||
var/list/power_usage
|
||||
|
||||
|
||||
/**
|
||||
* A list of teleport locations
|
||||
*
|
||||
@@ -118,6 +115,7 @@ GLOBAL_LIST_EMPTY(teleportlocs)
|
||||
// rather than waiting for atoms to initialize.
|
||||
if (unique)
|
||||
GLOB.areas_by_type[type] = src
|
||||
power_usage = new /list(AREA_USAGE_LEN) // Some atoms would like to use power in Initialize()
|
||||
return ..()
|
||||
|
||||
/**
|
||||
@@ -464,11 +462,11 @@ GLOBAL_LIST_EMPTY(teleportlocs)
|
||||
if(always_unpowered)
|
||||
return 0
|
||||
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 0
|
||||
@@ -489,44 +487,19 @@ GLOBAL_LIST_EMPTY(teleportlocs)
|
||||
M.power_change() // reverify power status (to update icons etc.)
|
||||
update_icon()
|
||||
|
||||
/**
|
||||
* Return the usage of power per channel
|
||||
*/
|
||||
/area/proc/usage(chan)
|
||||
var/used = 0
|
||||
switch(chan)
|
||||
if(LIGHT)
|
||||
used += used_light
|
||||
if(EQUIP)
|
||||
used += used_equip
|
||||
if(ENVIRON)
|
||||
used += used_environ
|
||||
if(TOTAL)
|
||||
used += used_light + used_equip + used_environ
|
||||
if(STATIC_EQUIP)
|
||||
used += static_equip
|
||||
if(STATIC_LIGHT)
|
||||
used += static_light
|
||||
if(STATIC_ENVIRON)
|
||||
used += static_environ
|
||||
return used
|
||||
|
||||
/**
|
||||
* Add a static amount of power load to an area
|
||||
*
|
||||
* Possible channels
|
||||
* *STATIC_EQUIP
|
||||
* *STATIC_LIGHT
|
||||
* *STATIC_ENVIRON
|
||||
* *AREA_USAGE_STATIC_EQUIP
|
||||
* *AREA_USAGE_STATIC_LIGHT
|
||||
* *AREA_USAGE_STATIC_ENVIRON
|
||||
*/
|
||||
/area/proc/addStaticPower(value, powerchannel)
|
||||
switch(powerchannel)
|
||||
if(STATIC_EQUIP)
|
||||
static_equip += value
|
||||
if(STATIC_LIGHT)
|
||||
static_light += value
|
||||
if(STATIC_ENVIRON)
|
||||
static_environ += value
|
||||
if(AREA_USAGE_STATIC_START to AREA_USAGE_STATIC_END)
|
||||
power_usage[powerchannel] += value
|
||||
|
||||
/**
|
||||
* Clear all power usage in area
|
||||
@@ -534,22 +507,17 @@ GLOBAL_LIST_EMPTY(teleportlocs)
|
||||
* Clears all power used for equipment, light and environment channels
|
||||
*/
|
||||
/area/proc/clear_usage()
|
||||
used_equip = 0
|
||||
used_light = 0
|
||||
used_environ = 0
|
||||
for(var/i in AREA_USAGE_DYNAMIC_START to AREA_USAGE_DYNAMIC_END)
|
||||
power_usage[i] = 0
|
||||
|
||||
/**
|
||||
* Add a power value amount to the stored used_x variables
|
||||
*/
|
||||
/area/proc/use_power(amount, chan)
|
||||
|
||||
switch(chan)
|
||||
if(EQUIP)
|
||||
used_equip += amount
|
||||
if(LIGHT)
|
||||
used_light += amount
|
||||
if(ENVIRON)
|
||||
used_environ += amount
|
||||
if(AREA_USAGE_DYNAMIC_START to AREA_USAGE_DYNAMIC_END)
|
||||
power_usage[chan] += amount
|
||||
|
||||
|
||||
/**
|
||||
* Call back when an atom enters an area
|
||||
|
||||
@@ -24,26 +24,19 @@
|
||||
ASSERT(!istype(A, /area/holodeck))
|
||||
return A.powered(chan)
|
||||
|
||||
/area/holodeck/usage(var/chan)
|
||||
if(!linked)
|
||||
return 0
|
||||
var/area/A = get_area(linked)
|
||||
ASSERT(!istype(A, /area/holodeck))
|
||||
return A.usage(chan)
|
||||
|
||||
/area/holodeck/addStaticPower(value, powerchannel)
|
||||
if(!linked)
|
||||
return
|
||||
var/area/A = get_area(linked)
|
||||
ASSERT(!istype(A, /area/holodeck))
|
||||
return A.addStaticPower(value,powerchannel)
|
||||
return ..()
|
||||
|
||||
/area/holodeck/use_power(amount, chan)
|
||||
if(!linked)
|
||||
return 0
|
||||
var/area/A = get_area(linked)
|
||||
ASSERT(!istype(A, /area/holodeck))
|
||||
return A.use_power(amount,chan)
|
||||
return ..()
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -21,9 +21,9 @@ Class Variables:
|
||||
power_channel (num)
|
||||
What channel to draw from when drawing power for power mode
|
||||
Possible Values:
|
||||
EQUIP:0 -- Equipment Channel
|
||||
LIGHT:2 -- Lighting Channel
|
||||
ENVIRON:3 -- Environment Channel
|
||||
AREA_USAGE_EQUIP:0 -- Equipment Channel
|
||||
AREA_USAGE_LIGHT:2 -- Lighting Channel
|
||||
AREA_USAGE_ENVIRON:3 -- Environment Channel
|
||||
|
||||
component_parts (list)
|
||||
A list of component parts of machine used by frame based machines.
|
||||
@@ -53,11 +53,11 @@ Class Procs:
|
||||
Default definition uses 'use_power', 'power_channel', 'active_power_usage',
|
||||
'idle_power_usage', 'powered()', and 'use_power()' implement behavior.
|
||||
|
||||
powered(chan = EQUIP) 'modules/power/power.dm'
|
||||
powered(chan = -1) 'modules/power/power.dm'
|
||||
Checks to see if area that contains the object has power available for power
|
||||
channel given in 'chan'.
|
||||
channel given in 'chan'. -1 defaults to power_channel
|
||||
|
||||
use_power(amount, chan=EQUIP) 'modules/power/power.dm'
|
||||
use_power(amount, chan=-1) 'modules/power/power.dm'
|
||||
Deducts 'amount' from the power channel 'chan' of the area that contains the object.
|
||||
|
||||
power_change() 'modules/power/power.dm'
|
||||
@@ -105,8 +105,8 @@ Class Procs:
|
||||
//2 = run auto, use active
|
||||
var/idle_power_usage = 0
|
||||
var/active_power_usage = 0
|
||||
var/power_channel = EQUIP
|
||||
//EQUIP,ENVIRON or LIGHT
|
||||
var/power_channel = AREA_USAGE_EQUIP
|
||||
//AREA_USAGE_EQUIP,AREA_USAGE_ENVIRON or AREA_USAGE_LIGHT
|
||||
var/wire_compatible = FALSE
|
||||
|
||||
var/list/component_parts = null //list of all the parts used to build it, if made from certain kinds of frames.
|
||||
@@ -416,7 +416,7 @@ Class Procs:
|
||||
|
||||
/obj/machinery/CanAllowThrough(atom/movable/mover, turf/target)
|
||||
. = ..()
|
||||
|
||||
|
||||
if(mover.pass_flags & PASSMACHINE)
|
||||
return TRUE
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
name = "airlock sensor"
|
||||
resistance_flags = FIRE_PROOF
|
||||
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
|
||||
var/id_tag
|
||||
var/master_tag
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
icon = 'icons/obj/stationobjs.dmi'
|
||||
icon_state = "doorctrl"
|
||||
var/skin = "doorctrl"
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
var/obj/item/assembly/device
|
||||
var/obj/item/electronics/airlock/board
|
||||
var/device_type = null
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
use_power = IDLE_POWER_USE
|
||||
idle_power_usage = 5
|
||||
active_power_usage = 60
|
||||
power_channel = EQUIP
|
||||
power_channel = AREA_USAGE_EQUIP
|
||||
circuit = /obj/item/circuitboard/machine/cell_charger
|
||||
pass_flags = PASSTABLE
|
||||
var/obj/item/stock_parts/cell/charging = null
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
density = FALSE
|
||||
use_power = IDLE_POWER_USE
|
||||
idle_power_usage = 0
|
||||
power_channel = EQUIP
|
||||
power_channel = AREA_USAGE_EQUIP
|
||||
req_one_access = list(ACCESS_MEDICAL, ACCESS_HEADS, ACCESS_SECURITY) //used to control clamps
|
||||
/// The mount's defib
|
||||
var/obj/item/defibrillator/defib
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
density = TRUE
|
||||
move_resist = MOVE_FORCE_VERY_STRONG
|
||||
layer = OPEN_DOOR_LAYER
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
max_integrity = 350
|
||||
armor = list("melee" = 30, "bullet" = 30, "laser" = 20, "energy" = 20, "bomb" = 10, "bio" = 100, "rad" = 100, "fire" = 80, "acid" = 70)
|
||||
CanAtmosPass = ATMOS_PASS_DENSITY
|
||||
@@ -148,7 +148,7 @@
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
|
||||
if(istype(mover) && (mover.pass_flags & PASSGLASS))
|
||||
return !opacity
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define CYCLE_INTERIOR 5
|
||||
|
||||
/obj/machinery/doorButtons
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
use_power = IDLE_POWER_USE
|
||||
idle_power_usage = 2
|
||||
active_power_usage = 4
|
||||
|
||||
@@ -201,7 +201,7 @@
|
||||
density = FALSE
|
||||
|
||||
frequency = FREQ_AIRLOCK_CONTROL
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
|
||||
// Setup parameters only
|
||||
var/id_tag
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
density = FALSE
|
||||
|
||||
frequency = FREQ_ATMOS_CONTROL
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
|
||||
// Setup parameters only
|
||||
var/airpump_tag
|
||||
|
||||
@@ -118,12 +118,12 @@
|
||||
else
|
||||
. += "[icon_state]_door_off"
|
||||
if(occupant)
|
||||
if(powered(EQUIP))
|
||||
if(powered())
|
||||
. += "[icon_state]_stack"
|
||||
. += "[icon_state]_yellow"
|
||||
else
|
||||
. += "[icon_state]_red"
|
||||
else if(powered(EQUIP))
|
||||
else if(powered())
|
||||
. += "[icon_state]_red"
|
||||
if(panel_open)
|
||||
. += "[icon_state]_panel"
|
||||
@@ -131,7 +131,7 @@
|
||||
/obj/machinery/fat_sucker/process()
|
||||
if(!processing)
|
||||
return
|
||||
if(!powered(EQUIP) || !occupant || !iscarbon(occupant))
|
||||
if(!powered() || !occupant || !iscarbon(occupant))
|
||||
open_machine()
|
||||
return
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
use_power(500)
|
||||
|
||||
/obj/machinery/fat_sucker/proc/start_extracting()
|
||||
if(state_open || !occupant || processing || !powered(EQUIP))
|
||||
if(state_open || !occupant || processing || !powered())
|
||||
return
|
||||
if(iscarbon(occupant))
|
||||
var/mob/living/carbon/C = occupant
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
use_power = IDLE_POWER_USE
|
||||
idle_power_usage = 2
|
||||
active_power_usage = 6
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
resistance_flags = FIRE_PROOF
|
||||
|
||||
light_power = 0
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
start_harvest()
|
||||
|
||||
/obj/machinery/harvester/proc/can_harvest()
|
||||
if(!powered(EQUIP) || state_open || !occupant || !iscarbon(occupant))
|
||||
if(!powered() || state_open || !occupant || !iscarbon(occupant))
|
||||
return
|
||||
var/mob/living/carbon/C = occupant
|
||||
if(!allow_clothing)
|
||||
@@ -95,7 +95,7 @@
|
||||
/obj/machinery/harvester/proc/harvest()
|
||||
warming_up = FALSE
|
||||
update_icon()
|
||||
if(!harvesting || state_open || !powered(EQUIP) || !occupant || !iscarbon(occupant))
|
||||
if(!harvesting || state_open || !powered() || !occupant || !iscarbon(occupant))
|
||||
return
|
||||
playsound(src, 'sound/machines/juicer.ogg', 20, TRUE)
|
||||
var/mob/living/carbon/C = occupant
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
icon = 'icons/obj/power.dmi'
|
||||
icon_state = "light1"
|
||||
desc = "Make dark."
|
||||
power_channel = LIGHT
|
||||
power_channel = AREA_USAGE_LIGHT
|
||||
/// Set this to a string, path, or area instance to control that area
|
||||
/// instead of the switch's location.
|
||||
var/area/area = null
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
idle_power_usage = 50 //when inactive, this turret takes up constant 50 Equipment power
|
||||
active_power_usage = 300 //when active, this turret takes up constant 300 Equipment power
|
||||
req_access = list(ACCESS_SEC_DOORS)
|
||||
power_channel = EQUIP //drains power from the EQUIPMENT channel
|
||||
power_channel = AREA_USAGE_EQUIP //drains power from the EQUIPMENT channel
|
||||
|
||||
var/base_icon_state = "standard"
|
||||
var/scan_range = 7
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
icon_state = "close"
|
||||
use_power = ACTIVE_POWER_USE
|
||||
active_power_usage = 60
|
||||
power_channel = EQUIP
|
||||
power_channel = AREA_USAGE_EQUIP
|
||||
density = TRUE
|
||||
max_integrity = 250
|
||||
ui_x = 400
|
||||
|
||||
@@ -280,7 +280,7 @@
|
||||
energy_drain = 0
|
||||
range = 0
|
||||
var/coeff = 100
|
||||
var/list/use_channels = list(EQUIP,ENVIRON,LIGHT)
|
||||
var/list/use_channels = list(AREA_USAGE_EQUIP,AREA_USAGE_ENVIRON,AREA_USAGE_LIGHT)
|
||||
selectable = 0
|
||||
|
||||
/obj/item/mecha_parts/mecha_equipment/tesla_energy_relay/Destroy()
|
||||
@@ -343,7 +343,7 @@
|
||||
var/area/A = get_area(chassis)
|
||||
if(A)
|
||||
var/pow_chan
|
||||
for(var/c in list(EQUIP,ENVIRON,LIGHT))
|
||||
for(var/c in use_channels)
|
||||
if(A.powered(c))
|
||||
pow_chan = c
|
||||
break
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
if(!A || emped)
|
||||
on = FALSE
|
||||
else
|
||||
on = A.powered(EQUIP) // set "on" to the power status
|
||||
on = A.powered(AREA_USAGE_EQUIP) // set "on" to the power status
|
||||
|
||||
if(!on)
|
||||
icon_state = "intercom-p"
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
var/area/A = get_area(src)
|
||||
if(!isarea(A))
|
||||
return
|
||||
if(!A.powered(EQUIP))
|
||||
if(!A.powered(AREA_USAGE_EQUIP))
|
||||
return
|
||||
A.use_power(EQUIP, 5000)
|
||||
A.use_power(AREA_USAGE_EQUIP, 5000)
|
||||
|
||||
flick("echair_shock", src)
|
||||
var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
use_power = IDLE_POWER_USE
|
||||
idle_power_usage = 4
|
||||
active_power_usage = 8
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
req_access = list(ACCESS_ATMOSPHERICS)
|
||||
max_integrity = 250
|
||||
integrity_failure = 0.33
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
move_resist = INFINITY //Moving a connected machine without actually doing the normal (dis)connection things will probably cause a LOT of issues.
|
||||
idle_power_usage = 0
|
||||
active_power_usage = 0
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
layer = GAS_PIPE_HIDDEN_LAYER //under wires
|
||||
resistance_flags = FIRE_PROOF
|
||||
max_integrity = 200
|
||||
|
||||
@@ -295,7 +295,7 @@
|
||||
|
||||
/obj/machinery/atmospherics/components/unary/vent_pump/high_volume
|
||||
name = "large air vent"
|
||||
power_channel = EQUIP
|
||||
power_channel = AREA_USAGE_EQUIP
|
||||
|
||||
/obj/machinery/atmospherics/components/unary/vent_pump/high_volume/New()
|
||||
..()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
icon = 'icons/obj/atmospherics/pipes/meter.dmi'
|
||||
icon_state = "meterX"
|
||||
layer = GAS_PUMP_LAYER
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
use_power = IDLE_POWER_USE
|
||||
idle_power_usage = 2
|
||||
active_power_usage = 4
|
||||
|
||||
@@ -67,6 +67,11 @@
|
||||
return
|
||||
else
|
||||
linked.linked = src
|
||||
var/area/my_area = get_area(src)
|
||||
if(my_area)
|
||||
linked.power_usage = my_area.power_usage
|
||||
else
|
||||
linked.power_usage = new /list(AREA_USAGE_LEN)
|
||||
|
||||
generate_program_list()
|
||||
load_program(offline_program, FALSE, FALSE)
|
||||
@@ -75,6 +80,7 @@
|
||||
emergency_shutdown()
|
||||
if(linked)
|
||||
linked.linked = null
|
||||
linked.power_usage = new /list(AREA_USAGE_LEN)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/computer/holodeck/power_change()
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
use_power = IDLE_POWER_USE
|
||||
idle_power_usage = 2
|
||||
active_power_usage = 6
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
|
||||
/obj/machinery/readybutton/attack_ai(mob/user as mob)
|
||||
to_chat(user, "<span class='warning'>The station AI is not to interact with these devices!</span>")
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
|
||||
if(!lacks_power())
|
||||
var/area/home = get_area(src)
|
||||
if(home.powered(EQUIP))
|
||||
home.use_power(1000, EQUIP)
|
||||
if(home.powered(AREA_USAGE_EQUIP))
|
||||
home.use_power(1000, AREA_USAGE_EQUIP)
|
||||
|
||||
if(aiRestorePowerRoutine >= POWER_RESTORATION_SEARCH_APC)
|
||||
ai_restore_power()
|
||||
|
||||
@@ -1,91 +1,91 @@
|
||||
/obj/item/computer_hardware/recharger
|
||||
critical = 1
|
||||
enabled = 1
|
||||
var/charge_rate = 100
|
||||
device_type = MC_CHARGE
|
||||
|
||||
/obj/item/computer_hardware/recharger/proc/use_power(amount, charging=0)
|
||||
if(charging)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/item/computer_hardware/recharger/process()
|
||||
..()
|
||||
var/obj/item/computer_hardware/battery/battery_module = holder.all_components[MC_CELL]
|
||||
if(!holder || !battery_module || !battery_module.battery)
|
||||
return
|
||||
|
||||
var/obj/item/stock_parts/cell/cell = battery_module.battery
|
||||
if(cell.charge >= cell.maxcharge)
|
||||
return
|
||||
|
||||
if(use_power(charge_rate, charging=1))
|
||||
holder.give_power(charge_rate * GLOB.CELLRATE)
|
||||
|
||||
|
||||
/obj/item/computer_hardware/recharger/APC
|
||||
name = "area power connector"
|
||||
desc = "A device that wirelessly recharges connected device from nearby APC."
|
||||
icon_state = "charger_APC"
|
||||
w_class = WEIGHT_CLASS_SMALL // Can't be installed into tablets/PDAs
|
||||
|
||||
/obj/item/computer_hardware/recharger/APC/use_power(amount, charging=0)
|
||||
if(ismachinery(holder.physical))
|
||||
var/obj/machinery/M = holder.physical
|
||||
if(M.powered())
|
||||
M.use_power(amount)
|
||||
return 1
|
||||
|
||||
else
|
||||
var/area/A = get_area(src)
|
||||
if(!istype(A))
|
||||
return 0
|
||||
|
||||
if(A.powered(EQUIP))
|
||||
A.use_power(amount, EQUIP)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/item/computer_hardware/recharger/wired
|
||||
name = "wired power connector"
|
||||
desc = "A power connector that recharges connected device from nearby power wire. Incompatible with portable computers."
|
||||
icon_state = "charger_wire"
|
||||
w_class = WEIGHT_CLASS_NORMAL
|
||||
|
||||
/obj/item/computer_hardware/recharger/wired/can_install(obj/item/modular_computer/M, mob/living/user = null)
|
||||
if(ismachinery(M.physical) && M.physical.anchored)
|
||||
return ..()
|
||||
to_chat(user, "<span class='warning'>\The [src] is incompatible with portable computers!</span>")
|
||||
return 0
|
||||
|
||||
/obj/item/computer_hardware/recharger/wired/use_power(amount, charging=0)
|
||||
if(ismachinery(holder.physical) && holder.physical.anchored)
|
||||
var/obj/machinery/M = holder.physical
|
||||
var/turf/T = M.loc
|
||||
if(!T || !istype(T))
|
||||
return 0
|
||||
|
||||
var/obj/structure/cable/C = T.get_cable_node()
|
||||
if(!C || !C.powernet)
|
||||
return 0
|
||||
|
||||
var/power_in_net = C.powernet.avail-C.powernet.load
|
||||
|
||||
if(power_in_net && power_in_net > amount)
|
||||
C.powernet.load += amount
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
// This is not intended to be obtainable in-game. Intended for adminbus and debugging purposes.
|
||||
/obj/item/computer_hardware/recharger/lambda
|
||||
name = "lambda coil"
|
||||
desc = "A very complex device that draws power from its own bluespace dimension."
|
||||
icon_state = "charger_lambda"
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
charge_rate = 100000
|
||||
|
||||
/obj/item/computer_hardware/recharger/lambda/use_power(amount, charging=0)
|
||||
return 1
|
||||
/obj/item/computer_hardware/recharger
|
||||
critical = 1
|
||||
enabled = 1
|
||||
var/charge_rate = 100
|
||||
device_type = MC_CHARGE
|
||||
|
||||
/obj/item/computer_hardware/recharger/proc/use_power(amount, charging=0)
|
||||
if(charging)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/item/computer_hardware/recharger/process()
|
||||
..()
|
||||
var/obj/item/computer_hardware/battery/battery_module = holder.all_components[MC_CELL]
|
||||
if(!holder || !battery_module || !battery_module.battery)
|
||||
return
|
||||
|
||||
var/obj/item/stock_parts/cell/cell = battery_module.battery
|
||||
if(cell.charge >= cell.maxcharge)
|
||||
return
|
||||
|
||||
if(use_power(charge_rate, charging=1))
|
||||
holder.give_power(charge_rate * GLOB.CELLRATE)
|
||||
|
||||
|
||||
/obj/item/computer_hardware/recharger/APC
|
||||
name = "area power connector"
|
||||
desc = "A device that wirelessly recharges connected device from nearby APC."
|
||||
icon_state = "charger_APC"
|
||||
w_class = WEIGHT_CLASS_SMALL // Can't be installed into tablets/PDAs
|
||||
|
||||
/obj/item/computer_hardware/recharger/APC/use_power(amount, charging=0)
|
||||
if(ismachinery(holder.physical))
|
||||
var/obj/machinery/M = holder.physical
|
||||
if(M.powered())
|
||||
M.use_power(amount)
|
||||
return 1
|
||||
|
||||
else
|
||||
var/area/A = get_area(src)
|
||||
if(!istype(A))
|
||||
return 0
|
||||
|
||||
if(A.powered(AREA_USAGE_EQUIP))
|
||||
A.use_power(amount, AREA_USAGE_EQUIP)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/item/computer_hardware/recharger/wired
|
||||
name = "wired power connector"
|
||||
desc = "A power connector that recharges connected device from nearby power wire. Incompatible with portable computers."
|
||||
icon_state = "charger_wire"
|
||||
w_class = WEIGHT_CLASS_NORMAL
|
||||
|
||||
/obj/item/computer_hardware/recharger/wired/can_install(obj/item/modular_computer/M, mob/living/user = null)
|
||||
if(ismachinery(M.physical) && M.physical.anchored)
|
||||
return ..()
|
||||
to_chat(user, "<span class='warning'>\The [src] is incompatible with portable computers!</span>")
|
||||
return 0
|
||||
|
||||
/obj/item/computer_hardware/recharger/wired/use_power(amount, charging=0)
|
||||
if(ismachinery(holder.physical) && holder.physical.anchored)
|
||||
var/obj/machinery/M = holder.physical
|
||||
var/turf/T = M.loc
|
||||
if(!T || !istype(T))
|
||||
return 0
|
||||
|
||||
var/obj/structure/cable/C = T.get_cable_node()
|
||||
if(!C || !C.powernet)
|
||||
return 0
|
||||
|
||||
var/power_in_net = C.powernet.avail-C.powernet.load
|
||||
|
||||
if(power_in_net && power_in_net > amount)
|
||||
C.powernet.load += amount
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
// This is not intended to be obtainable in-game. Intended for adminbus and debugging purposes.
|
||||
/obj/item/computer_hardware/recharger/lambda
|
||||
name = "lambda coil"
|
||||
desc = "A very complex device that draws power from its own bluespace dimension."
|
||||
icon_state = "charger_lambda"
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
charge_rate = 100000
|
||||
|
||||
/obj/item/computer_hardware/recharger/lambda/use_power(amount, charging=0)
|
||||
return 1
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
use_power = IDLE_POWER_USE
|
||||
idle_power_usage = 30
|
||||
active_power_usage = 200
|
||||
power_channel = EQUIP
|
||||
power_channel = AREA_USAGE_EQUIP
|
||||
max_integrity = 300
|
||||
integrity_failure = 0.33
|
||||
var/obj/item/paper/copy = null //what's in the copier!
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
/obj/machinery/photocopier/ui_interact(mob/user)
|
||||
. = ..()
|
||||
var/dat = "Photocopier<BR><BR>"
|
||||
var/list/dat = list("Photocopier<BR><BR>")
|
||||
if(copy || photocopy || doccopy || (ass && (ass.loc == src.loc)))
|
||||
dat += "<a href='byond://?src=[REF(src)];remove=1'>Remove Paper</a><BR>"
|
||||
if(toner)
|
||||
@@ -48,7 +48,7 @@
|
||||
dat += "Current toner level: [toner]"
|
||||
if(!toner)
|
||||
dat +="<BR>Please insert a new toner cartridge!"
|
||||
user << browse(dat, "window=copier")
|
||||
user << browse(dat.Join(""), "window=copier")
|
||||
onclose(user, "copier")
|
||||
|
||||
/obj/machinery/photocopier/Topic(href, href_list)
|
||||
|
||||
@@ -1188,12 +1188,9 @@
|
||||
force_update = 1
|
||||
return
|
||||
|
||||
lastused_light = area.usage(STATIC_LIGHT)
|
||||
lastused_light += area.usage(LIGHT)
|
||||
lastused_equip = area.usage(EQUIP)
|
||||
lastused_equip += area.usage(STATIC_EQUIP)
|
||||
lastused_environ = area.usage(ENVIRON)
|
||||
lastused_environ += area.usage(STATIC_ENVIRON)
|
||||
lastused_light = area.power_usage[AREA_USAGE_LIGHT] + area.power_usage[AREA_USAGE_STATIC_LIGHT]
|
||||
lastused_equip = area.power_usage[AREA_USAGE_EQUIP] + area.power_usage[AREA_USAGE_STATIC_EQUIP]
|
||||
lastused_environ = area.power_usage[AREA_USAGE_ENVIRON] + area.power_usage[AREA_USAGE_STATIC_ENVIRON]
|
||||
area.clear_usage()
|
||||
|
||||
lastused_total = lastused_light + lastused_equip + lastused_environ
|
||||
|
||||
@@ -112,7 +112,7 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne
|
||||
icon_state = "on_8"
|
||||
idle_power_usage = 0
|
||||
active_power_usage = 3000
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
sprite_number = 8
|
||||
use_power = IDLE_POWER_USE
|
||||
interaction_flags_machine = INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OFFLINE
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
use_power = ACTIVE_POWER_USE
|
||||
idle_power_usage = 2
|
||||
active_power_usage = 20
|
||||
power_channel = LIGHT //Lights are calc'd via area so they dont need to be in the machine list
|
||||
power_channel = AREA_USAGE_LIGHT //Lights are calc'd via area so they dont need to be in the machine list
|
||||
var/on = FALSE // 1 if on, 0 if off
|
||||
var/on_gs = FALSE
|
||||
var/static_power_used = 0
|
||||
@@ -390,9 +390,9 @@
|
||||
on_gs = on
|
||||
if(on)
|
||||
static_power_used = brightness * 20 //20W per unit luminosity
|
||||
addStaticPower(static_power_used, STATIC_LIGHT)
|
||||
addStaticPower(static_power_used, AREA_USAGE_STATIC_LIGHT)
|
||||
else
|
||||
removeStaticPower(static_power_used, STATIC_LIGHT)
|
||||
removeStaticPower(static_power_used, AREA_USAGE_STATIC_LIGHT)
|
||||
|
||||
broken_sparks(start_only=TRUE)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ GLOBAL_DATUM_INIT(keycard_events, /datum/events, new)
|
||||
use_power = IDLE_POWER_USE
|
||||
idle_power_usage = 2
|
||||
active_power_usage = 6
|
||||
power_channel = ENVIRON
|
||||
power_channel = AREA_USAGE_ENVIRON
|
||||
req_access = list(ACCESS_KEYCARD_AUTH)
|
||||
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
|
||||
ui_x = 375
|
||||
|
||||
Reference in New Issue
Block a user