Files
Bubberstation/code/game/objects/items/control_wand.dm
LemonInTheDark 930c5e635e Moves "catch this var/flag" code from obj/init and datum/new into the types that use it (#69634)
* Optimizes away /obj/Initialize

We were spending like 0.15 seconds just checking for blueprints, obj
flags and network ids
All these things can just be applied where they're wanted, saves time

Oh and I replaced object flags with an emag injector. I'll give it a
sprite and name later I promise

* Requires a GenerateTag() call to set DF_USE_TAG, rather then doing a check in atom New

This is technically harder to use, but I don't really want people using
tags, and it saves 0.15 seconds

* Moves generatetag to /datum

* I am dumb

* Saves 0.5 seconds, makes init emissive blockers actually work

Ok so background. If an overlay is added with add_overlay, and not
"managed" somehow, it will effectively never be removed, because
nothing's tracking it.

Update_overlays uses the managed_overlays list/var (one of those) to do
this.
I'm gonna piggyback off this to make emissive overlays actually like,
respect overlay updates.

Oh and uh, I've saved maybe 0.5 seconds by caching the new emissive, and
not using add_overlay. There's a chance this will lead to overlay
corruption, but since we never readd the flattened, I think we'll be
safe

* Fixes plane not being set right, changes color logic too, since alpha will override past color sets

* Makes it actually work. also makes rand posters update appearance to clear away the overlay, since it shows on right click and looks bad

* Fixes blockers showing as emissives. It turns out alpha sets override the color list we use. Not sure why we pretend to support them

* Makes the injector support traits, adds an amazing sprite
2022-09-06 03:17:17 -07:00

112 lines
3.4 KiB
Plaintext

#define WAND_OPEN "open"
#define WAND_BOLT "bolt"
#define WAND_EMERGENCY "emergency"
/obj/item/door_remote
icon_state = "gangtool-white"
inhand_icon_state = "electronic"
lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi'
righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi'
icon = 'icons/obj/device.dmi'
name = "control wand"
desc = "Remotely controls airlocks."
w_class = WEIGHT_CLASS_TINY
var/mode = WAND_OPEN
var/region_access = REGION_GENERAL
var/list/access_list
/obj/item/door_remote/Initialize(mapload)
. = ..()
init_network_id(NETWORK_DOOR_REMOTES)
access_list = SSid_access.get_region_access_list(list(region_access))
RegisterSignal(src, COMSIG_COMPONENT_NTNET_NAK, .proc/bad_signal)
/obj/item/door_remote/proc/bad_signal(datum/source, datum/netdata/data, error_code)
SIGNAL_HANDLER
if(QDELETED(data.user))
return // can't send a message to a missing user
if(error_code == NETWORK_ERROR_UNAUTHORIZED)
to_chat(data.user, span_notice("This remote is not authorized to modify this door."))
else
to_chat(data.user, span_notice("Error: [error_code]"))
/obj/item/door_remote/attack_self(mob/user)
var/static/list/desc = list(WAND_OPEN = "Open Door", WAND_BOLT = "Toggle Bolts", WAND_EMERGENCY = "Toggle Emergency Access")
switch(mode)
if(WAND_OPEN)
mode = WAND_BOLT
if(WAND_BOLT)
mode = WAND_EMERGENCY
if(WAND_EMERGENCY)
mode = WAND_OPEN
balloon_alert(user, "mode: [desc[mode]]")
// Airlock remote works by sending NTNet packets to whatever it's pointed at.
/obj/item/door_remote/afterattack(atom/A, mob/user)
. = ..()
var/datum/component/ntnet_interface/target_interface = A.GetComponent(/datum/component/ntnet_interface)
// Try to find an airlock in the clicked turf
if(!target_interface)
var/obj/machinery/door/airlock/door = locate() in get_turf(A)
if(door)
target_interface = door.GetComponent(/datum/component/ntnet_interface)
if(!target_interface)
return
user.set_machine(src)
// Generate a control packet.
var/datum/netdata/data = new(list("data" = mode,"data_secondary" = "toggle"))
data.receiver_id = target_interface.hardware_id
data.passkey = access_list
data.user = user // for responce message
ntnet_send(data)
/obj/item/door_remote/omni
name = "omni door remote"
desc = "This control wand can access any door on the station."
icon_state = "gangtool-yellow"
region_access = REGION_ALL_STATION
/obj/item/door_remote/captain
name = "command door remote"
icon_state = "gangtool-yellow"
region_access = REGION_COMMAND
/obj/item/door_remote/chief_engineer
name = "engineering door remote"
icon_state = "gangtool-orange"
region_access = REGION_ENGINEERING
/obj/item/door_remote/research_director
name = "research door remote"
icon_state = "gangtool-purple"
region_access = REGION_RESEARCH
/obj/item/door_remote/head_of_security
name = "security door remote"
icon_state = "gangtool-red"
region_access = REGION_SECURITY
/obj/item/door_remote/quartermaster
name = "supply door remote"
desc = "Remotely controls airlocks. This remote has additional Vault access."
icon_state = "gangtool-green"
region_access = REGION_SUPPLY
/obj/item/door_remote/chief_medical_officer
name = "medical door remote"
icon_state = "gangtool-blue"
region_access = REGION_MEDBAY
/obj/item/door_remote/civilian
name = "civilian door remote"
icon_state = "gangtool-white"
region_access = REGION_GENERAL
#undef WAND_OPEN
#undef WAND_BOLT
#undef WAND_EMERGENCY