mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-24 20:47:43 +01:00
Merge pull request #7827 from VOREStation/aro-intercoms
Make intercom power change stateful
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// Observer Pattern Implementation: Area Power Change
|
||||
// Registration type: /area
|
||||
//
|
||||
// Raised when: An /area has a power change (the APC powers up/down or some channels are enabled/disabled)
|
||||
//
|
||||
// Arguments that the called proc should expect:
|
||||
// /area: The area experiencing the power change
|
||||
|
||||
GLOBAL_DATUM_INIT(apc_event, /decl/observ/area_power_change, new)
|
||||
|
||||
/decl/observ/area_power_change
|
||||
name = "Area Power Change"
|
||||
expected_type = /area
|
||||
|
||||
/********************
|
||||
* Movement Handling *
|
||||
********************/
|
||||
|
||||
/area/power_change()
|
||||
. = ..()
|
||||
GLOB.apc_event.raise_event(src)
|
||||
@@ -11,9 +11,20 @@
|
||||
flags = NOBLOODY
|
||||
var/circuit = /obj/item/weapon/circuitboard/intercom
|
||||
var/number = 0
|
||||
var/last_tick //used to delay the powercheck
|
||||
var/wiresexposed = 0
|
||||
|
||||
/obj/item/device/radio/intercom/Initialize()
|
||||
. = ..()
|
||||
var/area/A = get_area(src)
|
||||
if(A)
|
||||
GLOB.apc_event.register(A, src, /obj/update_icon)
|
||||
|
||||
/obj/item/device/radio/intercom/Destroy()
|
||||
var/area/A = get_area(src)
|
||||
if(A)
|
||||
GLOB.apc_event.unregister(A, src, /obj/update_icon)
|
||||
return ..()
|
||||
|
||||
/obj/item/device/radio/intercom/custom
|
||||
name = "station intercom (Custom)"
|
||||
broadcasting = 0
|
||||
@@ -60,7 +71,6 @@
|
||||
|
||||
/obj/item/device/radio/intercom/New()
|
||||
..()
|
||||
START_PROCESSING(SSobj, src)
|
||||
circuit = new circuit(src)
|
||||
|
||||
/obj/item/device/radio/intercom/department/medbay/New()
|
||||
@@ -103,10 +113,6 @@
|
||||
..()
|
||||
internal_channels[num2text(RAID_FREQ)] = list(access_syndicate)
|
||||
|
||||
/obj/item/device/radio/intercom/Destroy()
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
return ..()
|
||||
|
||||
/obj/item/device/radio/intercom/attack_ai(mob/user as mob)
|
||||
src.add_fingerprint(user)
|
||||
spawn (0)
|
||||
@@ -123,15 +129,8 @@
|
||||
wiresexposed = !wiresexposed
|
||||
to_chat(user, "The wires have been [wiresexposed ? "exposed" : "unexposed"]")
|
||||
playsound(src, W.usesound, 50, 1)
|
||||
if(wiresexposed)
|
||||
if(!on)
|
||||
icon_state = "intercom-p_open"
|
||||
else
|
||||
icon_state = "intercom_open"
|
||||
else
|
||||
icon_state = "intercom"
|
||||
return
|
||||
if(wiresexposed && W.is_wirecutter())
|
||||
update_icon()
|
||||
else if(wiresexposed && W.is_wirecutter())
|
||||
user.visible_message("<span class='warning'>[user] has cut the wires inside \the [src]!</span>", "You have cut the wires inside \the [src].")
|
||||
playsound(src, W.usesound, 50, 1)
|
||||
new/obj/item/stack/cable_coil(get_turf(src), 5)
|
||||
@@ -149,7 +148,6 @@
|
||||
qdel(src)
|
||||
else
|
||||
src.attack_hand(user)
|
||||
return
|
||||
|
||||
/obj/item/device/radio/intercom/receive_range(freq, level)
|
||||
if (!on)
|
||||
@@ -166,29 +164,21 @@
|
||||
|
||||
return canhear_range
|
||||
|
||||
/obj/item/device/radio/intercom/process()
|
||||
if(((world.timeofday - last_tick) > 30) || ((world.timeofday - last_tick) < 0))
|
||||
last_tick = world.timeofday
|
||||
/obj/item/device/radio/intercom/update_icon()
|
||||
var/area/A = get_area(src)
|
||||
on = A?.powered(EQUIP)
|
||||
|
||||
if(!src.loc)
|
||||
on = 0
|
||||
if(!on)
|
||||
if(wiresexposed)
|
||||
icon_state = "intercom-p_open"
|
||||
else
|
||||
var/area/A = get_area(src)
|
||||
if(!A)
|
||||
on = 0
|
||||
else
|
||||
on = A.powered(EQUIP) // set "on" to the power status
|
||||
icon_state = "intercom-p"
|
||||
else
|
||||
if(wiresexposed)
|
||||
icon_state = "intercom_open"
|
||||
else
|
||||
icon_state = initial(icon_state)
|
||||
|
||||
if(!on)
|
||||
if(wiresexposed)
|
||||
icon_state = "intercom-p_open"
|
||||
else
|
||||
icon_state = "intercom-p"
|
||||
else
|
||||
if(wiresexposed)
|
||||
icon_state = "intercom_open"
|
||||
else
|
||||
icon_state = initial(icon_state)
|
||||
//VOREStation Add Start
|
||||
/obj/item/device/radio/intercom/AICtrlClick(var/mob/user)
|
||||
ToggleBroadcast()
|
||||
|
||||
Reference in New Issue
Block a user