diff --git a/tgui/packages/tgui/interfaces/Orbit/constants.ts b/tgui/packages/tgui/interfaces/Orbit/constants.ts index 431c02980f0..cd5348e79ff 100644 --- a/tgui/packages/tgui/interfaces/Orbit/constants.ts +++ b/tgui/packages/tgui/interfaces/Orbit/constants.ts @@ -8,30 +8,51 @@ export const ANTAG2COLOR = { export const ANTAG2GROUP = { 'Abductor Agent': 'Abductors', 'Abductor Scientist': 'Abductors', + 'Ash Walker': 'Ash Walkers', + 'Blob': 'Biohazards', 'Sentient Disease': 'Biohazards', + + 'Admiral': 'CentCom', + 'CentCom Bartender': 'CentCom', 'CentCom Commander': 'CentCom', 'CentCom Head Intern': 'CentCom', 'CentCom Intern': 'CentCom', 'CentCom Official': 'CentCom', 'Central Command': 'CentCom', + 'Custodian': 'CentCom', + 'Private Security Force': 'CentCom', + 'VIP Guest': 'CentCom', + 'Clown Operative': 'Clown Operatives', 'Clown Operative Leader': 'Clown Operatives', + + 'Death Squad Officer': 'Emergency Response Team', + 'Death Squad Trooper': 'Emergency Response Team', + 'Emergency Response Team Commander': 'Emergency Response Team', + 'Security Response Officer': 'Emergency Response Team', + 'Engineering Response Officer': 'Emergency Response Team', + 'Medical Response Officer': 'Emergency Response Team', + 'Religious Response Officer': 'Emergency Response Team', + 'Janitorial Response Officer': 'Emergency Response Team', + 'Entertainment Response Officer': 'Emergency Response Team', + 'Nuclear Operative': 'Nuclear Operatives', 'Nuclear Operative Leader': 'Nuclear Operatives', + 'Space Wizard': 'Wizard Federation', 'Wizard Apprentice': 'Wizard Federation', 'Wizard Minion': 'Wizard Federation', } as const; -export enum THREAT { - Low = 2, - Medium = 5, - High = 8, -} +export const THREAT = { + Low: 1, + Medium: 5, + High: 8, +} as const; -export enum HEALTH { - Good = 69, - Average = 19, -} +export const HEALTH = { + Good: 69, + Average: 19, +} as const; diff --git a/tgui/packages/tgui/interfaces/Orbit/helpers.ts b/tgui/packages/tgui/interfaces/Orbit/helpers.ts index f99d35ab5a4..441fc65ae79 100644 --- a/tgui/packages/tgui/interfaces/Orbit/helpers.ts +++ b/tgui/packages/tgui/interfaces/Orbit/helpers.ts @@ -53,7 +53,7 @@ const getHealthColor = (health: number) => { }; /** Returns the display color based on orbiter numbers */ -const getThreatColor = (orbiters: number) => { +const getThreatColor = (orbiters = 0) => { switch (true) { case orbiters > THREAT.High: return 'violet'; @@ -66,19 +66,13 @@ const getThreatColor = (orbiters: number) => { } }; -/** - * ### getDisplayColor - * Displays color for buttons based on the health or orbiter count. Toggleable. - * @param {Observable} item - The point of interest. - * @param {boolean} heatMap - Whether the user has heat map toggled. - * @param {string} color - OPTIONAL: The color to default to. - */ +/** Displays color for buttons based on the health or orbiter count. */ export const getDisplayColor = ( item: Observable, heatMap: boolean, color?: string ) => { - const { health, orbiters = 0 } = item; + const { health, orbiters } = item; if (typeof health !== 'number') { return color ? 'good' : 'grey'; } diff --git a/tgui/packages/tgui/interfaces/Orbit/index.tsx b/tgui/packages/tgui/interfaces/Orbit/index.tsx index e812c0b6bfe..7aa4cce22d6 100644 --- a/tgui/packages/tgui/interfaces/Orbit/index.tsx +++ b/tgui/packages/tgui/interfaces/Orbit/index.tsx @@ -4,9 +4,9 @@ import { capitalizeFirst, multiline } from 'common/string'; import { useBackend, useLocalState } from 'tgui/backend'; import { Button, Collapsible, Icon, Input, LabeledList, NoticeBox, Section, Stack } from 'tgui/components'; import { Window } from 'tgui/layouts'; -import { collateAntagonists, getDisplayColor, getDisplayName, isJobOrNameMatch } from './helpers'; -import { ANTAG2COLOR } from './constants'; import { JobToIcon } from '../common/JobToIcon'; +import { ANTAG2COLOR } from './constants'; +import { collateAntagonists, getDisplayColor, getDisplayName, isJobOrNameMatch } from './helpers'; import type { AntagGroup, Observable, OrbitData } from './types'; export const Orbit = (props, context) => { @@ -39,6 +39,7 @@ const ObservableSearch = (props, context) => { misc = [], npcs = [], } = data; + const [autoObserve, setAutoObserve] = useLocalState( context, 'autoObserve', @@ -54,6 +55,7 @@ const ObservableSearch = (props, context) => { 'searchQuery', '' ); + /** Gets a list of Observables, then filters the most relevant to orbit */ const orbitMostRelevant = (searchQuery: string) => { /** Returns the most orbited observable that matches the search. */ @@ -66,6 +68,7 @@ const ObservableSearch = (props, context) => { sortBy((observable) => -(observable.orbiters || 0)), // Makes a single Observables list for an easy search ])([alive, antagonists, dead, ghosts, misc, npcs].flat())[0]; + if (mostRelevant !== undefined) { act('orbit', { ref: mostRelevant.ref, @@ -140,7 +143,9 @@ const ObservableContent = (props, context) => { misc = [], npcs = [], } = data; - let collatedAntagonists: Array = []; + + let collatedAntagonists: AntagGroup[] = []; + if (antagonists.length) { collatedAntagonists = collateAntagonists(antagonists); } @@ -173,17 +178,20 @@ const ObservableContent = (props, context) => { const ObservableSection = ( props: { color?: string; - section: Array; + section: Observable[]; title: string; }, context ) => { const { color, section = [], title } = props; + if (!section.length) { return null; } + const [searchQuery] = useLocalState(context, 'searchQuery', ''); - const filteredSection: Array = flow([ + + const filteredSection: Observable[] = flow([ filter((observable) => isJobOrNameMatch(observable, searchQuery) ), @@ -193,6 +201,7 @@ const ObservableSection = ( .toLowerCase() ), ])(section); + if (!filteredSection.length) { return null; } @@ -220,6 +229,7 @@ const ObservableItem = ( const { act } = useBackend(context); const { color, item } = props; const { extra, full_name, job, job_icon, health, name, orbiters, ref } = item; + const [autoObserve] = useLocalState(context, 'autoObserve', false); const [heatMap] = useLocalState(context, 'heatMap', false); @@ -247,6 +257,7 @@ const ObservableTooltip = (props: { item: Observable }) => { const { item: { extra, full_name, job, health }, } = props; + const extraInfo = extra?.split(':'); const displayHealth = !!health && health >= 0 ? `${health}%` : 'Critical'; diff --git a/tgui/packages/tgui/interfaces/Orbit/types.ts b/tgui/packages/tgui/interfaces/Orbit/types.ts index 1d49a5178ac..c34d38d131e 100644 --- a/tgui/packages/tgui/interfaces/Orbit/types.ts +++ b/tgui/packages/tgui/interfaces/Orbit/types.ts @@ -1,14 +1,14 @@ -export type AntagGroup = [string, Antags]; - export type Antags = Array; +export type AntagGroup = [string, Antags]; + export type OrbitData = { - alive: Array; + alive: Observable[]; antagonists: Antags; - dead: Array; - ghosts: Array; - misc: Array; - npcs: Array; + dead: Observable[]; + ghosts: Observable[]; + misc: Observable[]; + npcs: Observable[]; }; export type Observable = {