initial commit - cross reference with 5th port - obviously has compile errors
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
var/datum/events/keycard_events = new()
|
||||
|
||||
/obj/machinery/keycard_auth
|
||||
name = "Keycard Authentication Device"
|
||||
desc = "This device is used to trigger station functions, which require more than one ID card to authenticate."
|
||||
icon = 'icons/obj/monitors.dmi'
|
||||
icon_state = "auth_off"
|
||||
anchored = 1
|
||||
use_power = 1
|
||||
idle_power_usage = 2
|
||||
active_power_usage = 6
|
||||
power_channel = ENVIRON
|
||||
req_access = list(access_keycard_auth)
|
||||
var/datum/event/ev
|
||||
var/event = ""
|
||||
var/obj/machinery/keycard_auth/event_source
|
||||
var/mob/triggerer = null
|
||||
var/waiting = 0
|
||||
|
||||
/obj/machinery/keycard_auth/New()
|
||||
. = ..()
|
||||
ev = keycard_events.addEvent("triggerEvent", src, "triggerEvent")
|
||||
|
||||
/obj/machinery/keycard_auth/Destroy()
|
||||
keycard_events.clearEvent("triggerEvent", ev)
|
||||
qdel(ev)
|
||||
. = ..()
|
||||
|
||||
/obj/machinery/keycard_auth/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \
|
||||
datum/tgui/master_ui = null, datum/ui_state/state = physical_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "keycard_auth", name, 375, 125, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/keycard_auth/ui_data()
|
||||
var/list/data = list()
|
||||
data["waiting"] = waiting
|
||||
data["auth_required"] = event_source ? event_source.event : 0
|
||||
data["red_alert"] = (seclevel2num(get_security_level()) >= SEC_LEVEL_RED) ? 1 : 0
|
||||
data["emergency_maint"] = emergency_access
|
||||
return data
|
||||
|
||||
/obj/machinery/keycard_auth/ui_status(mob/user)
|
||||
if(isanimal(user))
|
||||
user << "<span class='warning'>You are too primitive to use this device!</span>"
|
||||
else
|
||||
return ..()
|
||||
return UI_CLOSE
|
||||
|
||||
/obj/machinery/keycard_auth/ui_act(action, params)
|
||||
if(..() || waiting || !allowed(usr))
|
||||
return
|
||||
switch(action)
|
||||
if("red_alert")
|
||||
if(!event_source)
|
||||
sendEvent("Red Alert")
|
||||
. = TRUE
|
||||
if("emergency_maint")
|
||||
if(!event_source)
|
||||
sendEvent("Emergency Maintenance Access")
|
||||
. = TRUE
|
||||
if("auth_swipe")
|
||||
if(event_source)
|
||||
event_source.trigger_event(usr)
|
||||
event_source = null
|
||||
. = TRUE
|
||||
|
||||
/obj/machinery/keycard_auth/proc/sendEvent(event_type)
|
||||
triggerer = usr
|
||||
event = event_type
|
||||
waiting = 1
|
||||
keycard_events.fireEvent("triggerEvent", src)
|
||||
addtimer(src, "eventSent", 20)
|
||||
|
||||
/obj/machinery/keycard_auth/proc/eventSent()
|
||||
triggerer = null
|
||||
event = ""
|
||||
waiting = 0
|
||||
|
||||
/obj/machinery/keycard_auth/proc/triggerEvent(source)
|
||||
icon_state = "auth_on"
|
||||
event_source = source
|
||||
addtimer(src, "eventTriggered", 20)
|
||||
|
||||
/obj/machinery/keycard_auth/proc/eventTriggered()
|
||||
icon_state = "auth_off"
|
||||
event_source = null
|
||||
|
||||
/obj/machinery/keycard_auth/proc/trigger_event(confirmer)
|
||||
log_game("[key_name(triggerer)] triggered and [key_name(confirmer)] confirmed event [event]")
|
||||
message_admins("[key_name(triggerer)] triggered and [key_name(confirmer)] confirmed event [event]")
|
||||
switch(event)
|
||||
if("Red Alert")
|
||||
set_security_level(SEC_LEVEL_RED)
|
||||
feedback_inc("alert_keycard_auth_red",1)
|
||||
if("Emergency Maintenance Access")
|
||||
make_maint_all_access()
|
||||
feedback_inc("alert_keycard_auth_maint",1)
|
||||
|
||||
|
||||
/var/emergency_access = 0
|
||||
/proc/make_maint_all_access()
|
||||
for(var/area/maintenance/A in world)
|
||||
for(var/obj/machinery/door/airlock/D in A)
|
||||
D.emergency = 1
|
||||
D.update_icon(0)
|
||||
minor_announce("Access restrictions on maintenance and external airlocks have been lifted.", "Attention! Station-wide emergency declared!",1)
|
||||
emergency_access = 1
|
||||
|
||||
/proc/revoke_maint_all_access()
|
||||
for(var/area/maintenance/A in world)
|
||||
for(var/obj/machinery/door/airlock/D in A)
|
||||
D.emergency = 0
|
||||
D.update_icon(0)
|
||||
minor_announce("Access restrictions in maintenance areas have been restored.", "Attention! Station-wide emergency rescinded:")
|
||||
emergency_access = 0
|
||||
@@ -0,0 +1,109 @@
|
||||
/var/security_level = 0
|
||||
//0 = code green
|
||||
//1 = code blue
|
||||
//2 = code red
|
||||
//3 = code delta
|
||||
|
||||
//config.alert_desc_blue_downto
|
||||
|
||||
/proc/set_security_level(level)
|
||||
switch(level)
|
||||
if("green")
|
||||
level = SEC_LEVEL_GREEN
|
||||
if("blue")
|
||||
level = SEC_LEVEL_BLUE
|
||||
if("red")
|
||||
level = SEC_LEVEL_RED
|
||||
if("delta")
|
||||
level = SEC_LEVEL_DELTA
|
||||
|
||||
//Will not be announced if you try to set to the same level as it already is
|
||||
if(level >= SEC_LEVEL_GREEN && level <= SEC_LEVEL_DELTA && level != security_level)
|
||||
switch(level)
|
||||
if(SEC_LEVEL_GREEN)
|
||||
minor_announce(config.alert_desc_green, "Attention! Security level lowered to green:")
|
||||
security_level = SEC_LEVEL_GREEN
|
||||
for(var/obj/machinery/firealarm/FA in machines)
|
||||
if(FA.z == ZLEVEL_STATION)
|
||||
FA.update_icon()
|
||||
if(SEC_LEVEL_BLUE)
|
||||
if(security_level < SEC_LEVEL_BLUE)
|
||||
minor_announce(config.alert_desc_blue_upto, "Attention! Security level elevated to blue:",1)
|
||||
else
|
||||
minor_announce(config.alert_desc_blue_downto, "Attention! Security level lowered to blue:")
|
||||
security_level = SEC_LEVEL_BLUE
|
||||
for(var/obj/machinery/firealarm/FA in machines)
|
||||
if(FA.z == ZLEVEL_STATION)
|
||||
FA.update_icon()
|
||||
if(SEC_LEVEL_RED)
|
||||
if(security_level < SEC_LEVEL_RED)
|
||||
minor_announce(config.alert_desc_red_upto, "Attention! Code red!",1)
|
||||
else
|
||||
minor_announce(config.alert_desc_red_downto, "Attention! Code red!")
|
||||
security_level = SEC_LEVEL_RED
|
||||
|
||||
/* - At the time of commit, setting status displays didn't work properly
|
||||
var/obj/machinery/computer/communications/CC = locate(/obj/machinery/computer/communications,world)
|
||||
if(CC)
|
||||
CC.post_status("alert", "redalert")*/
|
||||
|
||||
for(var/obj/machinery/firealarm/FA in machines)
|
||||
if(FA.z == ZLEVEL_STATION)
|
||||
FA.update_icon()
|
||||
for(var/obj/machinery/computer/shuttle/pod/pod in machines)
|
||||
pod.admin_controlled = 0
|
||||
if(SEC_LEVEL_DELTA)
|
||||
minor_announce(config.alert_desc_delta, "Attention! Delta security level reached!",1)
|
||||
security_level = SEC_LEVEL_DELTA
|
||||
for(var/obj/machinery/firealarm/FA in machines)
|
||||
if(FA.z == ZLEVEL_STATION)
|
||||
FA.update_icon()
|
||||
for(var/obj/machinery/computer/shuttle/pod/pod in machines)
|
||||
pod.admin_controlled = 0
|
||||
else
|
||||
return
|
||||
|
||||
/proc/get_security_level()
|
||||
switch(security_level)
|
||||
if(SEC_LEVEL_GREEN)
|
||||
return "green"
|
||||
if(SEC_LEVEL_BLUE)
|
||||
return "blue"
|
||||
if(SEC_LEVEL_RED)
|
||||
return "red"
|
||||
if(SEC_LEVEL_DELTA)
|
||||
return "delta"
|
||||
|
||||
/proc/num2seclevel(num)
|
||||
switch(num)
|
||||
if(SEC_LEVEL_GREEN)
|
||||
return "green"
|
||||
if(SEC_LEVEL_BLUE)
|
||||
return "blue"
|
||||
if(SEC_LEVEL_RED)
|
||||
return "red"
|
||||
if(SEC_LEVEL_DELTA)
|
||||
return "delta"
|
||||
|
||||
/proc/seclevel2num(seclevel)
|
||||
switch( lowertext(seclevel) )
|
||||
if("green")
|
||||
return SEC_LEVEL_GREEN
|
||||
if("blue")
|
||||
return SEC_LEVEL_BLUE
|
||||
if("red")
|
||||
return SEC_LEVEL_RED
|
||||
if("delta")
|
||||
return SEC_LEVEL_DELTA
|
||||
|
||||
|
||||
/*DEBUG
|
||||
/mob/verb/set_thing0()
|
||||
set_security_level(0)
|
||||
/mob/verb/set_thing1()
|
||||
set_security_level(1)
|
||||
/mob/verb/set_thing2()
|
||||
set_security_level(2)
|
||||
/mob/verb/set_thing3()
|
||||
set_security_level(3)
|
||||
*/
|
||||
Reference in New Issue
Block a user