mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 15:17:01 +01:00
Adds arctangent 2 component to circuits (#79892)
## About The Pull Request Adds an arctangent 2 component (atan2) ## Why It's Good For The Game It's made to convert offsets into angles, something thats pretty useful in a coordinate based game ## Changelog 🆑 add: Adds an arctangent2 component to circuitry! /🆑
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* # Arctangent 2 function
|
||||
* A variant of arctan. When given a deltaX and deltaY, returns the angle. I will blow you out of the sky
|
||||
*/
|
||||
/obj/item/circuit_component/arctan2
|
||||
display_name = "Arctangent 2 Component"
|
||||
desc = "A two parameter arctan2 component, for calculating any angle you want."
|
||||
category = "Math"
|
||||
|
||||
/// The input port for the x-offset
|
||||
var/datum/port/input/input_port_x
|
||||
/// The input port for the y-offset
|
||||
var/datum/port/input/input_port_y
|
||||
|
||||
/// The result from the output
|
||||
var/datum/port/output/output
|
||||
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
|
||||
|
||||
/obj/item/circuit_component/arctan2/populate_ports()
|
||||
input_port_x = add_input_port("Delta X", PORT_TYPE_NUMBER)
|
||||
input_port_y = add_input_port("Delta Y", PORT_TYPE_NUMBER)
|
||||
output = add_output_port("Angle", PORT_TYPE_NUMBER)
|
||||
|
||||
/obj/item/circuit_component/arctan2/input_received(datum/port/input/port)
|
||||
output.set_output(arctan(input_port_x.value, input_port_y.value))
|
||||
Reference in New Issue
Block a user