From 481dcff5eba797180fcebf8f12c15858014e7d5b Mon Sep 17 00:00:00 2001 From: Bloop <13398309+vinylspiders@users.noreply.github.com> Date: Sat, 22 Jul 2023 01:32:19 -0400 Subject: [PATCH] Allows PAI range restrictions to be toggled on/off (#22624) * Allows PAI range restrictions to be toggled on/off New setting to enable or disable the 'leash' on the PAI. * Adds message when it's been deactivated as well. * Apply suggestions from code review Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com> * Update pai.dm --------- Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com> --- code/__DEFINES/pai.dm | 2 +- .../master_files/code/modules/pai/card.dm | 17 +++++++++++++++++ .../master_files/code/modules/pai/pai.dm | 16 ++++++++++++++++ tgstation.dme | 2 ++ tgui/packages/tgui/interfaces/PaiCard.tsx | 19 +++++++++++++++++-- 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 modular_skyrat/master_files/code/modules/pai/card.dm create mode 100644 modular_skyrat/master_files/code/modules/pai/pai.dm diff --git a/code/__DEFINES/pai.dm b/code/__DEFINES/pai.dm index 5e5e13b1867..ed616a357a6 100644 --- a/code/__DEFINES/pai.dm +++ b/code/__DEFINES/pai.dm @@ -12,7 +12,7 @@ #define PAI_SPAM_TIME (40 SECONDS) /// Maximum distance you can set the holoform leash -#define HOLOFORM_MAX_RANGE 9 +#define HOLOFORM_MAX_RANGE 25 // SKYRAT EDIT CHANGE - ORIGINAL: #define HOLOFORM_MAX_RANGE 9 /// Minimum distance you can set the holoform leash #define HOLOFORM_MIN_RANGE 3 diff --git a/modular_skyrat/master_files/code/modules/pai/card.dm b/modular_skyrat/master_files/code/modules/pai/card.dm new file mode 100644 index 00000000000..b804649d343 --- /dev/null +++ b/modular_skyrat/master_files/code/modules/pai/card.dm @@ -0,0 +1,17 @@ +/obj/item/pai_card/ui_data(mob/user) + . = ..() + if(!pai) + return + + .["pai"]["leash_enabled"] = pai.leashed + +/obj/item/pai_card/ui_act(action, list/params, datum/tgui/ui) + . = ..() + if(.) + return TRUE + + if(pai && action == "toggle_leash") + pai.toggle_leash() + return TRUE + + return FALSE diff --git a/modular_skyrat/master_files/code/modules/pai/pai.dm b/modular_skyrat/master_files/code/modules/pai/pai.dm new file mode 100644 index 00000000000..33fc1cfeacc --- /dev/null +++ b/modular_skyrat/master_files/code/modules/pai/pai.dm @@ -0,0 +1,16 @@ +/mob/living/silicon/pai/ + /// Whether or not the PAI is subject to range limitations and able to roam freely, off by default + var/leashed = FALSE + +/// Enables or disables the leash, allowing or forbidding the PAI from leaving a specified range +/mob/living/silicon/pai/proc/toggle_leash() + leashed = !leashed + to_chat(src, span_warning("Your virtual leash has been [leashed ? "activated" : "deactivated"]!")) + if(leashed) + check_distance() // yoink them back + +/mob/living/silicon/pai/check_distance() + if(!leashed) + return + + return ..() diff --git a/tgstation.dme b/tgstation.dme index fe45bcf8d6c..2350a98ae43 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -5732,6 +5732,8 @@ #include "modular_skyrat\master_files\code\modules\mod\modules\_module.dm" #include "modular_skyrat\master_files\code\modules\mod\modules\modules_antag.dm" #include "modular_skyrat\master_files\code\modules\modular_computers\computers\item\laptop_presets.dm" +#include "modular_skyrat\master_files\code\modules\pai\card.dm" +#include "modular_skyrat\master_files\code\modules\pai\pai.dm" #include "modular_skyrat\master_files\code\modules\paperwork\stamps.dm" #include "modular_skyrat\master_files\code\modules\power\cable.dm" #include "modular_skyrat\master_files\code\modules\power\lighting\light_mapping_helpers.dm" diff --git a/tgui/packages/tgui/interfaces/PaiCard.tsx b/tgui/packages/tgui/interfaces/PaiCard.tsx index 4a15a46e5d1..3a3d6ca114b 100644 --- a/tgui/packages/tgui/interfaces/PaiCard.tsx +++ b/tgui/packages/tgui/interfaces/PaiCard.tsx @@ -28,6 +28,7 @@ type Pai = { transmit: BooleanLike; receive: BooleanLike; range: number; + leash_enabled: BooleanLike; // SKYRAT EDIT ADDITION }; export const PaiCard = (props, context) => { @@ -155,6 +156,7 @@ const PaiOptions = (props, context) => { transmit, receive, range, + leash_enabled /* SKYRAT EDIT ADDITION */, }, } = data; const suppliedLaws = laws[0] ? decodeHtmlEntities(laws[0]) : 'None'; @@ -185,13 +187,25 @@ const PaiOptions = (props, context) => { Toggle + {/* SKYRAT EDIT ADDITION START */} + + + + {/* SKYRAT EDIT ADDITION END */}