mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
[MIRROR] Adds the MMI circuit component. Allows inputting signals into circuit component ports (#6493)
* Adds the MMI circuit component. Allows inputting signals into circuit component ports (#59743) Adds the MMI component which outputs signals whenever they click somewhere/try to move. Allows inputting signals into ports, making it easier to debug integrated components. * Adds the MMI circuit component. Allows inputting signals into circuit component ports Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com>
This commit is contained in:
@@ -1271,6 +1271,9 @@
|
||||
///from /obj/item/assembly/proc/pulsed()
|
||||
#define COMSIG_ASSEMBLY_PULSED "assembly_pulsed"
|
||||
|
||||
///from base of /obj/item/mmi/set_brainmob(): (mob/living/brain/new_brainmob)
|
||||
#define COMSIG_MMI_SET_BRAINMOB "mmi_set_brainmob"
|
||||
|
||||
/// Exoprobe adventure finished: (result) result is ADVENTURE_RESULT_??? values
|
||||
#define COMSIG_ADVENTURE_FINISHED "adventure_done"
|
||||
|
||||
|
||||
@@ -461,6 +461,9 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
|
||||
///Trait applied to turfs when an atmos holosign is placed on them. It will stop firedoors from closing.
|
||||
#define TRAIT_FIREDOOR_STOP "firedoor_stop"
|
||||
|
||||
/// Trait applied when the MMI component is added to an [/obj/item/integrated_circuit]
|
||||
#define TRAIT_COMPONENT_MMI "component_mmi"
|
||||
|
||||
//Medical Categories for quirks
|
||||
#define CAT_QUIRK_ALL 0
|
||||
#define CAT_QUIRK_NOTES 1
|
||||
|
||||
@@ -162,6 +162,7 @@
|
||||
if(brainmob == new_brainmob)
|
||||
return FALSE
|
||||
. = brainmob
|
||||
SEND_SIGNAL(src, COMSIG_MMI_SET_BRAINMOB, new_brainmob)
|
||||
brainmob = new_brainmob
|
||||
if(new_brainmob)
|
||||
if(mecha)
|
||||
|
||||
@@ -173,6 +173,11 @@
|
||||
id = "comp_pull"
|
||||
build_path = /obj/item/circuit_component/pull
|
||||
|
||||
/datum/design/component/mmi
|
||||
name = "MMI Component"
|
||||
id = "comp_mmi"
|
||||
build_path = /obj/item/circuit_component/mmi
|
||||
|
||||
/datum/design/component/multiplexer
|
||||
name = "Multiplexer Component"
|
||||
id = "comp_multiplexer"
|
||||
|
||||
@@ -223,6 +223,7 @@
|
||||
"comp_length",
|
||||
"comp_light",
|
||||
"comp_logic",
|
||||
"comp_mmi",
|
||||
"comp_multiplexer",
|
||||
"comp_not",
|
||||
"comp_radio",
|
||||
|
||||
@@ -196,6 +196,14 @@
|
||||
if((circuit_flags & CIRCUIT_FLAG_INPUT_SIGNAL) && !COMPONENT_TRIGGERED_BY(trigger_input, port))
|
||||
return TRUE
|
||||
|
||||
/// Called when this component is about to be added to an integrated_circuit.
|
||||
/obj/item/circuit_component/proc/add_to(obj/item/integrated_circuit/added_to)
|
||||
return TRUE
|
||||
|
||||
/// Called when this component is removed from an integrated_circuit.
|
||||
/obj/item/circuit_component/proc/removed_from(obj/item/integrated_circuit/removed_from)
|
||||
return
|
||||
|
||||
/**
|
||||
* Gets the UI notices to be displayed on the CircuitInfo panel.
|
||||
*
|
||||
|
||||
183
code/modules/wiremod/components/action/mmi.dm
Normal file
183
code/modules/wiremod/components/action/mmi.dm
Normal file
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* # Man-Machine Interface Component
|
||||
*
|
||||
* Allows an MMI to be inserted into a shell, allowing it to be linked up. Requires a shell.
|
||||
*/
|
||||
/obj/item/circuit_component/mmi
|
||||
display_name = "Man-Machine Interface"
|
||||
display_desc = "A component that allows MMI to enter shells to send output signals."
|
||||
|
||||
/// The message to send to the MMI in the shell.
|
||||
var/datum/port/input/message
|
||||
/// Sends the current MMI a message
|
||||
var/datum/port/input/send
|
||||
/// Ejects the current MMI
|
||||
var/datum/port/input/eject
|
||||
|
||||
/// Called when the MMI tries moving north
|
||||
var/datum/port/output/north
|
||||
/// Called when the MMI tries moving east
|
||||
var/datum/port/output/east
|
||||
/// Called when the MMI tries moving south
|
||||
var/datum/port/output/south
|
||||
/// Called when the MMI tries moving west
|
||||
var/datum/port/output/west
|
||||
|
||||
/// Returns what the MMI last clicked on.
|
||||
var/datum/port/output/clicked_atom
|
||||
/// Called when the MMI clicks.
|
||||
var/datum/port/output/attack
|
||||
/// Called when the MMI right clicks.
|
||||
var/datum/port/output/secondary_attack
|
||||
|
||||
/// The current MMI card
|
||||
var/obj/item/mmi/brain
|
||||
|
||||
/// Maximum length of the message that can be sent to the MMI
|
||||
var/max_length = 300
|
||||
|
||||
/obj/item/circuit_component/mmi/Initialize()
|
||||
. = ..()
|
||||
message = add_input_port("Message", PORT_TYPE_STRING)
|
||||
send = add_input_port("Send Message", PORT_TYPE_SIGNAL)
|
||||
eject = add_input_port("Eject", PORT_TYPE_SIGNAL)
|
||||
|
||||
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)
|
||||
|
||||
attack = add_output_port("Attack", PORT_TYPE_SIGNAL)
|
||||
secondary_attack = add_output_port("Secondary Attack", PORT_TYPE_SIGNAL)
|
||||
clicked_atom = add_output_port("Target Entity", PORT_TYPE_ATOM)
|
||||
|
||||
/obj/item/circuit_component/mmi/Destroy()
|
||||
remove_current_brain()
|
||||
message = null
|
||||
send = null
|
||||
eject = null
|
||||
north = null
|
||||
east = null
|
||||
south = null
|
||||
west = null
|
||||
attack = null
|
||||
secondary_attack = null
|
||||
clicked_atom = null
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/mmi/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
if(!brain)
|
||||
return
|
||||
|
||||
if(COMPONENT_TRIGGERED_BY(eject, port))
|
||||
remove_current_brain()
|
||||
if(COMPONENT_TRIGGERED_BY(send, port))
|
||||
if(!message.input_value)
|
||||
return
|
||||
|
||||
var/msg_str = copytext(html_encode(message.input_value), 1, max_length)
|
||||
|
||||
var/mob/living/target = brain.brainmob
|
||||
if(!target)
|
||||
return
|
||||
|
||||
to_chat(target, "[span_bold("You hear a message in your ear: ")][msg_str]")
|
||||
|
||||
|
||||
/obj/item/circuit_component/mmi/register_shell(atom/movable/shell)
|
||||
. = ..()
|
||||
RegisterSignal(shell, COMSIG_PARENT_ATTACKBY, .proc/handle_attack_by)
|
||||
|
||||
/obj/item/circuit_component/mmi/unregister_shell(atom/movable/shell)
|
||||
UnregisterSignal(shell, COMSIG_PARENT_ATTACKBY)
|
||||
remove_current_brain()
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/mmi/proc/handle_attack_by(atom/movable/shell, obj/item/item, mob/living/attacker)
|
||||
SIGNAL_HANDLER
|
||||
if(istype(item, /obj/item/mmi))
|
||||
var/obj/item/mmi/target_mmi = item
|
||||
if(!target_mmi.brainmob)
|
||||
return
|
||||
add_mmi(item)
|
||||
return COMPONENT_NO_AFTERATTACK
|
||||
|
||||
/obj/item/circuit_component/mmi/proc/add_mmi(obj/item/mmi/to_add)
|
||||
remove_current_brain()
|
||||
|
||||
to_add.forceMove(src)
|
||||
if(to_add.brainmob)
|
||||
update_mmi_mob(to_add, null, to_add.brainmob)
|
||||
brain = to_add
|
||||
RegisterSignal(to_add, COMSIG_PARENT_QDELETING, .proc/remove_current_brain)
|
||||
RegisterSignal(to_add, COMSIG_MOVABLE_MOVED, .proc/mmi_moved)
|
||||
|
||||
/obj/item/circuit_component/mmi/proc/mmi_moved(atom/movable/mmi)
|
||||
if(mmi.loc != src)
|
||||
remove_current_brain()
|
||||
|
||||
/obj/item/circuit_component/mmi/proc/remove_current_brain()
|
||||
SIGNAL_HANDLER
|
||||
if(!brain)
|
||||
return
|
||||
|
||||
if(brain.brainmob)
|
||||
update_mmi_mob(brain, brain.brainmob)
|
||||
UnregisterSignal(brain, list(
|
||||
COMSIG_PARENT_QDELETING,
|
||||
COMSIG_MOVABLE_MOVED
|
||||
))
|
||||
if(brain.loc == src)
|
||||
brain.forceMove(drop_location())
|
||||
brain = null
|
||||
|
||||
/obj/item/circuit_component/mmi/proc/update_mmi_mob(datum/source, mob/living/old_mmi, mob/living/new_mmi)
|
||||
SIGNAL_HANDLER
|
||||
if(old_mmi)
|
||||
old_mmi.remote_control = null
|
||||
UnregisterSignal(old_mmi, COMSIG_MOB_CLICKON)
|
||||
if(new_mmi)
|
||||
new_mmi.remote_control = src
|
||||
RegisterSignal(new_mmi, COMSIG_MOB_CLICKON, .proc/handle_mmi_attack)
|
||||
|
||||
/obj/item/circuit_component/mmi/relaymove(mob/living/user, direct)
|
||||
if(user != brain.brainmob)
|
||||
return ..()
|
||||
|
||||
if(direct & NORTH)
|
||||
north.set_output(COMPONENT_SIGNAL)
|
||||
if(direct & WEST)
|
||||
west.set_output(COMPONENT_SIGNAL)
|
||||
if(direct & EAST)
|
||||
east.set_output(COMPONENT_SIGNAL)
|
||||
if(direct & SOUTH)
|
||||
south.set_output(COMPONENT_SIGNAL)
|
||||
|
||||
return TRUE
|
||||
|
||||
/obj/item/circuit_component/mmi/proc/handle_mmi_attack(mob/living/source, atom/target, list/mods)
|
||||
SIGNAL_HANDLER
|
||||
var/list/modifiers = params2list(mods)
|
||||
if(modifiers[RIGHT_CLICK])
|
||||
clicked_atom.set_output(target)
|
||||
secondary_attack.set_output(COMPONENT_SIGNAL)
|
||||
. = COMSIG_MOB_CANCEL_CLICKON
|
||||
else if(modifiers[LEFT_CLICK] && !modifiers[SHIFT_CLICK] && !modifiers[ALT_CLICK] && !modifiers[CTRL_CLICK])
|
||||
clicked_atom.set_output(target)
|
||||
attack.set_output(COMPONENT_SIGNAL)
|
||||
. = COMSIG_MOB_CANCEL_CLICKON
|
||||
|
||||
/obj/item/circuit_component/mmi/add_to(obj/item/integrated_circuit/add_to)
|
||||
. = ..()
|
||||
if(HAS_TRAIT(add_to, TRAIT_COMPONENT_MMI))
|
||||
return FALSE
|
||||
ADD_TRAIT(add_to, TRAIT_COMPONENT_MMI, src)
|
||||
|
||||
/obj/item/circuit_component/mmi/removed_from(obj/item/integrated_circuit/removed_from)
|
||||
REMOVE_TRAIT(removed_from, TRAIT_COMPONENT_MMI, src)
|
||||
remove_current_brain()
|
||||
return ..()
|
||||
@@ -146,6 +146,9 @@
|
||||
if(SEND_SIGNAL(src, COMSIG_CIRCUIT_ADD_COMPONENT, to_add, user) & COMPONENT_CANCEL_ADD_COMPONENT)
|
||||
return
|
||||
|
||||
if(!to_add.add_to(src))
|
||||
return
|
||||
|
||||
var/success = FALSE
|
||||
if(user)
|
||||
success = user.transferItemToLoc(to_add, src)
|
||||
@@ -194,6 +197,7 @@
|
||||
to_remove.parent = null
|
||||
SEND_SIGNAL(to_remove, COMSIG_CIRCUIT_COMPONENT_REMOVED, src)
|
||||
SStgui.update_uis(src)
|
||||
to_remove.removed_from(src)
|
||||
|
||||
/obj/item/integrated_circuit/get_cell()
|
||||
return cell
|
||||
@@ -385,6 +389,9 @@
|
||||
port.set_input(text2num(any_type) || any_type)
|
||||
if(PORT_TYPE_STRING)
|
||||
port.set_input(copytext(user_input, 1, PORT_MAX_STRING_LENGTH))
|
||||
if(PORT_TYPE_SIGNAL)
|
||||
balloon_alert(usr, "triggered [port.name]")
|
||||
port.set_input(COMPONENT_SIGNAL)
|
||||
. = TRUE
|
||||
if("get_component_value")
|
||||
var/component_id = text2num(params["component_id"])
|
||||
|
||||
@@ -3608,6 +3608,7 @@
|
||||
#include "code\modules\wiremod\usb_cable.dm"
|
||||
#include "code\modules\wiremod\components\abstract\compare.dm"
|
||||
#include "code\modules\wiremod\components\action\light.dm"
|
||||
#include "code\modules\wiremod\components\action\mmi.dm"
|
||||
#include "code\modules\wiremod\components\action\pull.dm"
|
||||
#include "code\modules\wiremod\components\action\radio.dm"
|
||||
#include "code\modules\wiremod\components\action\speech.dm"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useBackend, useLocalState } from '../../backend';
|
||||
import { Box, Stack, Icon, Button, Input, Flex, NumberInput, Dropdown, InfinitePlane, Tooltip } from '../../components';
|
||||
import { Box, Stack, Icon, Button, Input, Flex, NumberInput, Dropdown, InfinitePlane } from '../../components';
|
||||
import { Component, createRef } from 'inferno';
|
||||
import { Window } from '../../layouts';
|
||||
import { CSS_COLORS } from '../../constants';
|
||||
@@ -91,6 +91,17 @@ const FUNDAMENTAL_DATA_TYPES = {
|
||||
/>
|
||||
);
|
||||
},
|
||||
"signal": (props, context) => {
|
||||
const { name, setValue } = props;
|
||||
return (
|
||||
<Button
|
||||
content={name}
|
||||
color="transparent"
|
||||
compact
|
||||
onClick={() => setValue()}
|
||||
/>
|
||||
);
|
||||
},
|
||||
"any": (props, context) => {
|
||||
const { name, value, setValue, color } = props;
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user