From ca0c0977c66b71a0b0a13a8d87332ce09df0843d Mon Sep 17 00:00:00 2001 From: DreamySkrell <107256943+DreamySkrell@users.noreply.github.com> Date: Tue, 2 Jan 2024 21:40:04 +0100 Subject: [PATCH] Ghost Spawner Manifest - follow mob button (#18104) * a * a * tests rerun please --------- Co-authored-by: DreamySkrell <> --- code/controllers/subsystems/ghostroles.dm | 15 +++- ...krell-ghostspawner-manifest-follow-mob.yml | 41 +++++++++++ .../packages/tgui/interfaces/GhostSpawner.tsx | 69 ++++++++++++++----- 3 files changed, 108 insertions(+), 17 deletions(-) create mode 100644 html/changelogs/DreamySkrell-ghostspawner-manifest-follow-mob.yml diff --git a/code/controllers/subsystems/ghostroles.dm b/code/controllers/subsystems/ghostroles.dm index a77049cae47..3899e87d038 100644 --- a/code/controllers/subsystems/ghostroles.dm +++ b/code/controllers/subsystems/ghostroles.dm @@ -179,7 +179,7 @@ SUBSYSTEM_DEF(ghostroles) . = TRUE if("jump_to") - var/spawner_id = params["jump_to"] + var/spawner_id = params["spawner_id"] var/datum/ghostspawner/human/spawner = spawners[spawner_id] var/mob/abstract/observer/observer = usr if(spawner && istype(observer) && spawner.can_jump_to(observer)) @@ -187,6 +187,19 @@ SUBSYSTEM_DEF(ghostroles) if(isturf(turf)) observer.on_mob_jump() observer.forceMove(turf) + + if("follow_manifest_entry") + var/spawner_id = params["spawner_id"] + var/spawned_mob_name = params["spawned_mob_name"] + var/datum/ghostspawner/human/spawner = spawners[spawner_id] + var/mob/abstract/observer/observer = usr + if(istype(observer) && spawner.can_jump_to(observer) && spawner && LAZYLEN(spawner.spawned_mobs)) + for(var/datum/weakref/mob_ref in spawner.spawned_mobs) + var/mob/spawned_mob = mob_ref.resolve() + if(spawned_mob && spawned_mob.real_name == spawned_mob_name) + observer.ManualFollow(spawned_mob) + break + if("enable") var/datum/ghostspawner/S = spawners[params["enable"]] if(!S) diff --git a/html/changelogs/DreamySkrell-ghostspawner-manifest-follow-mob.yml b/html/changelogs/DreamySkrell-ghostspawner-manifest-follow-mob.yml new file mode 100644 index 00000000000..63e2d2e177d --- /dev/null +++ b/html/changelogs/DreamySkrell-ghostspawner-manifest-follow-mob.yml @@ -0,0 +1,41 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: DreamySkrell + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Mobs listed in ghost spawner manifest can be followed." diff --git a/tgui/packages/tgui/interfaces/GhostSpawner.tsx b/tgui/packages/tgui/interfaces/GhostSpawner.tsx index ceedbc4db74..21b0ab23bfa 100644 --- a/tgui/packages/tgui/interfaces/GhostSpawner.tsx +++ b/tgui/packages/tgui/interfaces/GhostSpawner.tsx @@ -1,6 +1,7 @@ +import { paginate } from 'common/collections'; import { BooleanLike } from '../../common/react'; import { useBackend, useLocalState } from '../backend'; -import { Box, Button, Input, Section, Table, Tabs } from '../components'; +import { Box, Button, Input, Section, Table, Tabs, Tooltip } from '../components'; import { TableCell, TableRow } from '../components/Table'; import { Window } from '../layouts'; @@ -26,6 +27,55 @@ type Spawner = { manifest: string[]; }; +const ManifestTable = function (act, spawner: Spawner) { + return ( + + {paginate(spawner.manifest, 2).map((page) => { + const spawned_mob_name_1 = page[0]; + const spawned_mob_name_2 = page[1]; + + const ManifestCell = function ( + act, + spawner: Spawner, + spawned_mob_name: string + ) { + if (spawned_mob_name) { + return ( + + {' - ' + spawned_mob_name + ' '} + {spawner.can_jump_to ? ( + +
+ ); +}; + export const GhostSpawner = (props, context) => { const { act, data } = useBackend(context); const [tab, setTab] = useLocalState(context, 'tab', 'All'); @@ -99,20 +149,7 @@ export const GhostSpawner = (props, context) => { Manifest - - {spawner.manifest.map((spawned_mob_name) => { - return ( - - - {' - ' + spawned_mob_name} - - - ); - })} -
+ {ManifestTable(act, spawner)} ) : null} @@ -139,7 +176,7 @@ export const GhostSpawner = (props, context) => {