tgui backend
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* # Direction Component
|
||||
*
|
||||
* Return the direction of a mob relative to the component
|
||||
*/
|
||||
/obj/item/circuit_component/direction
|
||||
display_name = "Get Direction"
|
||||
desc = "A component that returns the direction of itself and an entity."
|
||||
|
||||
/// The input port
|
||||
var/datum/port/input/input_port
|
||||
|
||||
/// The result from the output
|
||||
var/datum/port/output/output
|
||||
|
||||
// Directions outputs
|
||||
var/datum/port/output/north
|
||||
var/datum/port/output/south
|
||||
var/datum/port/output/east
|
||||
var/datum/port/output/west
|
||||
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/// Maximum range for a valid direction to be returned
|
||||
var/max_range = 7
|
||||
|
||||
/obj/item/circuit_component/direction/get_ui_notices()
|
||||
. = ..()
|
||||
. += create_ui_notice("Maximum Range: [max_range] tiles", "orange", "info")
|
||||
|
||||
/obj/item/circuit_component/direction/Initialize()
|
||||
. = ..()
|
||||
input_port = add_input_port("Organism", PORT_TYPE_ATOM)
|
||||
|
||||
output = add_output_port("Direction", PORT_TYPE_STRING)
|
||||
|
||||
north = add_output_port("North", PORT_TYPE_SIGNAL)
|
||||
east = add_output_port("East", PORT_TYPE_SIGNAL)
|
||||
south = add_output_port("South", PORT_TYPE_SIGNAL)
|
||||
west = add_output_port("West", PORT_TYPE_SIGNAL)
|
||||
|
||||
/obj/item/circuit_component/direction/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/atom/object = input_port.value
|
||||
if(!object)
|
||||
return
|
||||
var/turf/location = get_turf(src)
|
||||
|
||||
if(object.z != location.z || get_dist(location, object) > max_range)
|
||||
output.set_output(null)
|
||||
return
|
||||
|
||||
var/direction = get_dir(location, get_turf(object))
|
||||
output.set_output(dir2text(direction))
|
||||
|
||||
if(direction & NORTH)
|
||||
north.set_output(COMPONENT_SIGNAL)
|
||||
if(direction & SOUTH)
|
||||
south.set_output(COMPONENT_SIGNAL)
|
||||
if(direction & EAST)
|
||||
east.set_output(COMPONENT_SIGNAL)
|
||||
if(direction & WEST)
|
||||
west.set_output(COMPONENT_SIGNAL)
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* # GPS Component
|
||||
*
|
||||
* Return the location of this
|
||||
*/
|
||||
/obj/item/circuit_component/gps
|
||||
display_name = "Internal GPS"
|
||||
desc = "A component that returns the xyz co-ordinates of itself."
|
||||
|
||||
/// The result from the output
|
||||
var/datum/port/output/x_pos
|
||||
var/datum/port/output/y_pos
|
||||
var/datum/port/output/z_pos
|
||||
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/obj/item/circuit_component/gps/Initialize()
|
||||
. = ..()
|
||||
|
||||
x_pos = add_output_port("X", PORT_TYPE_NUMBER)
|
||||
y_pos = add_output_port("Y", PORT_TYPE_NUMBER)
|
||||
z_pos = add_output_port("Z", PORT_TYPE_NUMBER)
|
||||
|
||||
/obj/item/circuit_component/gps/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/turf/location = get_turf(src)
|
||||
|
||||
x_pos.set_output(location?.x)
|
||||
y_pos.set_output(location?.y)
|
||||
z_pos.set_output(location?.z)
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* # Get Health Component
|
||||
*
|
||||
* Return the health of a mob
|
||||
*/
|
||||
/obj/item/circuit_component/health
|
||||
display_name = "Get Health"
|
||||
desc = "A component that returns the health of an organism."
|
||||
|
||||
/// The input port
|
||||
var/datum/port/input/input_port
|
||||
|
||||
/// Brute damage
|
||||
var/datum/port/output/brute
|
||||
/// Burn damage
|
||||
var/datum/port/output/burn
|
||||
/// Toxin damage
|
||||
var/datum/port/output/toxin
|
||||
/// Oxyloss damage
|
||||
var/datum/port/output/oxy
|
||||
/// Health
|
||||
var/datum/port/output/health
|
||||
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
var/max_range = 5
|
||||
|
||||
/obj/item/circuit_component/health/get_ui_notices()
|
||||
. = ..()
|
||||
. += create_ui_notice("Maximum Range: [max_range] tiles", "orange", "info")
|
||||
|
||||
/obj/item/circuit_component/health/Initialize()
|
||||
. = ..()
|
||||
input_port = add_input_port("Organism", PORT_TYPE_ATOM)
|
||||
|
||||
brute = add_output_port("Brute Damage", PORT_TYPE_NUMBER)
|
||||
burn = add_output_port("Burn Damage", PORT_TYPE_NUMBER)
|
||||
toxin = add_output_port("Toxin Damage", PORT_TYPE_NUMBER)
|
||||
oxy = add_output_port("Suffocation Damage", PORT_TYPE_NUMBER)
|
||||
health = add_output_port("Health", PORT_TYPE_NUMBER)
|
||||
|
||||
/obj/item/circuit_component/health/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/mob/living/organism = input_port.value
|
||||
var/turf/current_turf = get_turf(src)
|
||||
if(!istype(organism) || get_dist(current_turf, organism) > max_range || current_turf.z != organism.z)
|
||||
brute.set_output(null)
|
||||
burn.set_output(null)
|
||||
toxin.set_output(null)
|
||||
oxy.set_output(null)
|
||||
health.set_output(null)
|
||||
return
|
||||
|
||||
brute.set_output(organism.getBruteLoss())
|
||||
burn.set_output(organism.getFireLoss())
|
||||
toxin.set_output(organism.getToxLoss())
|
||||
oxy.set_output(organism.getOxyLoss())
|
||||
health.set_output(organism.health)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* # Hear Component
|
||||
*
|
||||
* Listens for messages. Requires a shell.
|
||||
*/
|
||||
/obj/item/circuit_component/hear
|
||||
display_name = "Voice Activator"
|
||||
desc = "A component that listens for messages. Requires a shell."
|
||||
|
||||
/// The message heard
|
||||
var/datum/port/output/message_port
|
||||
/// The language heard
|
||||
var/datum/port/output/language_port
|
||||
/// The speaker
|
||||
var/datum/port/output/speaker_port
|
||||
/// The trigger sent when this event occurs
|
||||
var/datum/port/output/trigger_port
|
||||
|
||||
/obj/item/circuit_component/hear/Initialize()
|
||||
. = ..()
|
||||
message_port = add_output_port("Message", PORT_TYPE_STRING)
|
||||
language_port = add_output_port("Language", PORT_TYPE_STRING)
|
||||
speaker_port = add_output_port("Speaker", PORT_TYPE_ATOM)
|
||||
trigger_port = add_output_port("Triggered", PORT_TYPE_SIGNAL)
|
||||
become_hearing_sensitive(ROUNDSTART_TRAIT)
|
||||
|
||||
/obj/item/circuit_component/hear/Hear(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, list/message_mods)
|
||||
if(speaker == parent?.shell)
|
||||
return
|
||||
|
||||
message_port.set_output(raw_message)
|
||||
if(message_language)
|
||||
language_port.set_output(initial(message_language.name))
|
||||
speaker_port.set_output(speaker)
|
||||
trigger_port.set_output(COMPONENT_SIGNAL)
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* # Self Component
|
||||
*
|
||||
* Return the current shell.
|
||||
*/
|
||||
/obj/item/circuit_component/self
|
||||
display_name = "Self"
|
||||
desc = "A component that returns the current shell."
|
||||
|
||||
/// The shell this component is attached to.
|
||||
var/datum/port/output/output
|
||||
|
||||
/obj/item/circuit_component/self/Initialize()
|
||||
. = ..()
|
||||
output = add_output_port("Self", PORT_TYPE_ATOM)
|
||||
|
||||
/obj/item/circuit_component/self/register_shell(atom/movable/shell)
|
||||
output.set_output(shell)
|
||||
|
||||
/obj/item/circuit_component/self/unregister_shell(atom/movable/shell)
|
||||
output.set_output(null)
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* # Get Species Component
|
||||
*
|
||||
* Return the species of a mob
|
||||
*/
|
||||
/obj/item/circuit_component/species
|
||||
display_name = "Get Species"
|
||||
desc = "A component that returns the species of its input."
|
||||
|
||||
/// The input port
|
||||
var/datum/port/input/input_port
|
||||
|
||||
/// The result from the output
|
||||
var/datum/port/output/output
|
||||
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/obj/item/circuit_component/species/Initialize()
|
||||
. = ..()
|
||||
input_port = add_input_port("Organism", PORT_TYPE_ATOM)
|
||||
|
||||
output = add_output_port("Species", PORT_TYPE_STRING)
|
||||
|
||||
/obj/item/circuit_component/species/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/mob/living/carbon/human/human = input_port.value
|
||||
if(!istype(human) || !human.has_dna())
|
||||
output.set_output(null)
|
||||
return
|
||||
|
||||
output.set_output(human.dna.species.name)
|
||||
|
||||
Reference in New Issue
Block a user