mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 21:18:37 +01:00
Merge pull request #51701 from SteelSlayer/intercom-refactor
Intercom refactor/code cleanup
This commit is contained in:
@@ -5,49 +5,44 @@
|
||||
anchored = TRUE
|
||||
w_class = WEIGHT_CLASS_BULKY
|
||||
canhear_range = 2
|
||||
var/number = 0
|
||||
var/anyai = 1
|
||||
var/mob/living/silicon/ai/ai = list()
|
||||
var/last_tick //used to delay the powercheck
|
||||
dog_fashion = null
|
||||
var/unfastened = FALSE
|
||||
unscrewed = FALSE
|
||||
|
||||
/obj/item/radio/intercom/unscrewed
|
||||
unfastened = TRUE
|
||||
unscrewed = TRUE
|
||||
|
||||
/obj/item/radio/intercom/Initialize(mapload, ndir, building)
|
||||
. = ..()
|
||||
if(building)
|
||||
setDir(ndir)
|
||||
START_PROCESSING(SSobj, src)
|
||||
|
||||
/obj/item/radio/intercom/Destroy()
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
return ..()
|
||||
var/area/current_area = get_area(src)
|
||||
if(!current_area)
|
||||
return
|
||||
RegisterSignal(current_area, COMSIG_AREA_POWER_CHANGE, .proc/AreaPowerCheck)
|
||||
|
||||
/obj/item/radio/intercom/examine(mob/user)
|
||||
. = ..()
|
||||
. += "<span class='notice'>Use [MODE_TOKEN_INTERCOM] when nearby to speak into it.</span>"
|
||||
if(!unfastened)
|
||||
if(!unscrewed)
|
||||
. += "<span class='notice'>It's <b>screwed</b> and secured to the wall.</span>"
|
||||
else
|
||||
. += "<span class='notice'>It's <i>unscrewed</i> from the wall, and can be <b>detached</b>.</span>"
|
||||
|
||||
/obj/item/radio/intercom/attackby(obj/item/I, mob/living/user, params)
|
||||
if(I.tool_behaviour == TOOL_SCREWDRIVER)
|
||||
if(unfastened)
|
||||
if(unscrewed)
|
||||
user.visible_message("<span class='notice'>[user] starts tightening [src]'s screws...</span>", "<span class='notice'>You start screwing in [src]...</span>")
|
||||
if(I.use_tool(src, user, 30, volume=50))
|
||||
user.visible_message("<span class='notice'>[user] tightens [src]'s screws!</span>", "<span class='notice'>You tighten [src]'s screws.</span>")
|
||||
unfastened = FALSE
|
||||
unscrewed = FALSE
|
||||
else
|
||||
user.visible_message("<span class='notice'>[user] starts loosening [src]'s screws...</span>", "<span class='notice'>You start unscrewing [src]...</span>")
|
||||
if(I.use_tool(src, user, 40, volume=50))
|
||||
user.visible_message("<span class='notice'>[user] loosens [src]'s screws!</span>", "<span class='notice'>You unscrew [src], loosening it from the wall.</span>")
|
||||
unfastened = TRUE
|
||||
unscrewed = TRUE
|
||||
return
|
||||
else if(I.tool_behaviour == TOOL_WRENCH)
|
||||
if(!unfastened)
|
||||
if(!unscrewed)
|
||||
to_chat(user, "<span class='warning'>You need to unscrew [src] from the wall first!</span>")
|
||||
return
|
||||
user.visible_message("<span class='notice'>[user] starts unsecuring [src]...</span>", "<span class='notice'>You start unsecuring [src]...</span>")
|
||||
@@ -82,45 +77,52 @@
|
||||
var/turf/position = get_turf(src)
|
||||
if(isnull(position) || !(position.z in level))
|
||||
return FALSE
|
||||
if(!src.listening)
|
||||
if(!listening)
|
||||
return FALSE
|
||||
if(freq == FREQ_SYNDICATE)
|
||||
if(!(src.syndie))
|
||||
if(!(syndie))
|
||||
return FALSE//Prevents broadcast of messages over devices lacking the encryption
|
||||
|
||||
return TRUE
|
||||
|
||||
|
||||
/obj/item/radio/intercom/Hear(message, atom/movable/speaker, message_langs, raw_message, radio_freq, list/spans, message_mode)
|
||||
if (message_mode == MODE_INTERCOM)
|
||||
if(message_mode == MODE_INTERCOM)
|
||||
return // Avoid hearing the same thing twice
|
||||
if(!anyai && !(speaker in ai))
|
||||
return
|
||||
..()
|
||||
return ..()
|
||||
|
||||
/obj/item/radio/intercom/process()
|
||||
if(((world.timeofday - last_tick) > 30) || ((world.timeofday - last_tick) < 0))
|
||||
last_tick = world.timeofday
|
||||
|
||||
var/area/A = get_area(src)
|
||||
if(!A || emped)
|
||||
on = FALSE
|
||||
else
|
||||
on = A.powered(AREA_USAGE_EQUIP) // set "on" to the power status
|
||||
|
||||
if(!on)
|
||||
icon_state = "intercom-p"
|
||||
else
|
||||
icon_state = initial(icon_state)
|
||||
|
||||
/obj/item/radio/intercom/add_blood_DNA(list/blood_dna)
|
||||
return FALSE
|
||||
/obj/item/radio/intercom/emp_act(severity)
|
||||
. = ..() // Parent call here will set `on` to FALSE.
|
||||
update_icon()
|
||||
|
||||
/obj/item/radio/intercom/end_emp_effect(curremp)
|
||||
. = ..()
|
||||
if(!.)
|
||||
return
|
||||
on = FALSE
|
||||
AreaPowerCheck() // Make sure the area/local APC is powered first before we actually turn back on.
|
||||
|
||||
/obj/item/radio/intercom/update_icon()
|
||||
. = ..()
|
||||
if(on)
|
||||
icon_state = initial(icon_state)
|
||||
else
|
||||
icon_state = "intercom-p"
|
||||
|
||||
/**
|
||||
* Proc called whenever the intercom's area loses or gains power. Responsible for setting the `on` variable and calling `update_icon()`.
|
||||
*
|
||||
* Normally called after the intercom's area recieves the `COMSIG_AREA_POWER_CHANGE` signal, but it can also be called directly.
|
||||
* Arguments:
|
||||
* * source - the area that just had a power change.
|
||||
*/
|
||||
/obj/item/radio/intercom/proc/AreaPowerCheck(datum/source)
|
||||
var/area/current_area = get_area(src)
|
||||
if(!current_area)
|
||||
on = FALSE
|
||||
else
|
||||
on = current_area.powered(AREA_USAGE_EQUIP) // set "on" to the equipment power status of our area.
|
||||
update_icon()
|
||||
|
||||
/obj/item/radio/intercom/add_blood_DNA(list/blood_dna)
|
||||
return FALSE
|
||||
|
||||
//Created through the autolathe or through deconstructing intercoms. Can be applied to wall to make a new intercom on it!
|
||||
/obj/item/wallframe/intercom
|
||||
|
||||
Reference in New Issue
Block a user