Files
Bubberstation/code/modules/wiremod/components/utility/nfc_send.dm
Autisem fec9a5d725 Adds a new NFC component for circuits (#87286)
## About The Pull Request

TODO:
- [x] Main circuit code
- [x] BCI compatibility
- [x] Limiting range in some way(not intended as a private cross map
coms system)


This adds a new NFC component, its similair to NTNet component with the
distinction it will only be received by the shell's circuit you target.
Allowing more targeted networking for things like remotes

I'd love suggestions for a max range, if any. Because im not really
sure. Maby circuit has to be in vision for it to work?

gif is too big so here is direct link to discord embedded gif showing it
off

https://cdn.discordapp.com/attachments/326831214667235328/1296810437295341649/example.gif?ex=6713a455&is=671252d5&hm=f87b282ac71c318eac03b4a53e03ebcfd91e5a0b0a1e9165beb3f87318b96809&

<img
src="https://cdn.discordapp.com/attachments/326831214667235328/1296810437295341649/example.gif?ex=6713a455&is=671252d5&hm=f87b282ac71c318eac03b4a53e03ebcfd91e5a0b0a1e9165beb3f87318b96809&">

## Why It's Good For The Game

NTNet is powerfull for making networked circuits, but I lack a good way
to create a direct "remote" with complex data.
I want to make a circuit that makes it easier to controll other circuits
in a less strictly coupeld way and this seems like a clean way to make
those

## Changelog
🆑
add: A new cirucit component allows NFC communications
/🆑

---------

Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com>
2024-11-02 14:32:54 +01:00

49 lines
1.6 KiB
Plaintext

/**
* # NFC Transmitter Component
*
* Sends a data package through NFC
* Only the targeted shell will receive the message
*/
/obj/item/circuit_component/nfc_send
display_name = "NFC 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 = "Utility"
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL
/// The list type
var/datum/port/input/option/list_options
/// The targeted circuit
var/datum/port/input/target
/// Data being sent
var/datum/port/input/data_package
/// Encryption key
var/datum/port/input/enc_key
/obj/item/circuit_component/nfc_send/populate_options()
list_options = add_option_port("List Type", GLOB.wiremod_basic_types)
/obj/item/circuit_component/nfc_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)
target = add_input_port("Target", PORT_TYPE_ATOM)
/obj/item/circuit_component/nfc_send/should_receive_input(datum/port/input/port)
. = ..()
if(!.)
return FALSE
/obj/item/circuit_component/nfc_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/nfc_send/input_received(datum/port/input/port)
if(isatom(target.value))
var/atom/target_enty = target.value
SEND_SIGNAL(target_enty, COMSIG_CIRCUIT_NFC_DATA_SENT, parent, list("data" = data_package.value, "enc_key" = enc_key.value, "port" = WEAKREF(data_package)))