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

Use element for red alert access #1638

Merged
merged 3 commits into from
Nov 7, 2024
Merged
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
5 changes: 4 additions & 1 deletion modular_ss220/_defines220/code/signals_obj.dm
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/// from base of [/obj/proc/atom_destruction]: (damage_flag)
/// from base of /obj/proc/atom_destruction: (damage_flag)
#define COMSIG_OBJ_DESTRUCTION "atom_destruction"

/// from base of /obj/item/card/id: (list/access)
#define COMSIG_ID_GET_ACCESS "id_get_access"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/datum/modpack/security_redalert_accesses
name = "Доступы СБ в красный код"
desc = "Добавляет доступы СБ в красный код."
author = "dj-34, Vallat"
author = "dj-34, Vallat, larentoun"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "_security_redalert_accesses.dm"

#include "code/security_redalert_accesses.dm"
#include "code/security_redalert_element.dm"
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
/obj/item/card/id
var/list/red_alert_given_access // Accesses that were given on red alert

/obj/item/card/id/Initialize(mapload)
. = ..()
red_alert_given_access = list()
RegisterSignal(SSsecurity_level, COMSIG_SECURITY_LEVEL_CHANGED, PROC_REF(on_security_level_update))

/obj/item/card/id/Destroy()
return ..()

/obj/item/card/id/proc/on_red_alert()
if(!has_access(list(), list(ACCESS_SECURITY), access))
return
red_alert_given_access = get_region_accesses(REGION_ALL) - get_region_accesses(REGION_COMMAND)
red_alert_given_access -= access

access |= red_alert_given_access

/obj/item/card/id/proc/after_red_alert()
if(!has_access(list(), list(ACCESS_SECURITY), access))
return
access -= red_alert_given_access
red_alert_given_access.Cut()
AddElement(/datum/element/red_alert_access)

/obj/item/card/id/proc/on_security_level_update()
if(SSsecurity_level.current_security_level.number_level > SEC_LEVEL_BLUE)
on_red_alert()
else
after_red_alert()
/obj/item/card/id/GetAccess()
var/list/current_access = ..()
. = current_access.Copy()
SEND_SIGNAL(src, COMSIG_ID_GET_ACCESS, .)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/datum/element/red_alert_access

/datum/element/red_alert_access/Attach(datum/target, list/access = list())
. = ..()
if(!istype(target, /obj/item/card/id))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_ID_GET_ACCESS, PROC_REF(add_access))
RegisterSignal(target, COMSIG_PARENT_EXAMINE, PROC_REF(examine))

/datum/element/red_alert_access/Detach(obj/item/card/id/source, force)
UnregisterSignal(source, COMSIG_ID_GET_ACCESS)
UnregisterSignal(source, COMSIG_PARENT_EXAMINE)
return ..()

/datum/element/red_alert_access/proc/add_access(obj/item/card/id/source, list/new_access = list())
SIGNAL_HANDLER
if(!should_give_access(source.access))
return
var/static/list/red_alert_access = get_region_accesses(REGION_ALL) - get_region_accesses(REGION_COMMAND)
new_access |= red_alert_access

/datum/element/red_alert_access/proc/examine(obj/item/card/id/source, mob/user, list/examine_list)
SIGNAL_HANDLER
if(!should_give_access(source.access))
return
examine_list += span_notice("Мигает красная лампочка с надписью \"Расширенный доступ\".")

/datum/element/red_alert_access/proc/should_give_access(list/access)
if(SSsecurity_level.current_security_level.number_level <= SEC_LEVEL_BLUE)
return FALSE
if(!has_access(list(), list(ACCESS_SECURITY), access))
m-dzianishchyts marked this conversation as resolved.
Show resolved Hide resolved
return FALSE
return TRUE
Loading