Files
Bubberstation/code/modules/wiremod/components/ntnet/ntnet_send.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

41 lines
1.3 KiB
Plaintext

/**
* # NTNet Transmitter Component
*
* Sends a data package through NTNet
*/
/obj/item/circuit_component/ntnet_send
display_name = "NTNet Transmitter"
desc = "Sends a data package through NTNet. If Encryption Key is set then transmitted data will be only picked up by receivers with the same Encryption Key."
category = "NTNet"
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL
/// The list type
var/datum/port/input/option/list_options
/// Data being sent
var/datum/port/input/data_package
/// Encryption key
var/datum/port/input/enc_key
/obj/item/circuit_component/ntnet_send/Initialize(mapload)
. = ..()
init_network_id(__NETWORK_CIRCUITS)
/obj/item/circuit_component/ntnet_send/populate_options()
list_options = add_option_port("List Type", GLOB.wiremod_basic_types)
/obj/item/circuit_component/ntnet_send/populate_ports()
data_package = add_input_port("Data Package", PORT_TYPE_LIST(PORT_TYPE_ANY))
enc_key = add_input_port("Encryption Key", PORT_TYPE_STRING)
/obj/item/circuit_component/ntnet_send/pre_input_received(datum/port/input/port)
if(port == list_options)
var/new_datatype = list_options.value
data_package.set_datatype(PORT_TYPE_LIST(new_datatype))
/obj/item/circuit_component/ntnet_send/input_received(datum/port/input/port)
ntnet_send(list("data" = data_package.value, "enc_key" = enc_key.value, "port" = WEAKREF(data_package)))