From bc787f6225b007c47097cf0930e630214d7c29f2 Mon Sep 17 00:00:00 2001 From: Paul Mullen <101871009+mullenpaul@users.noreply.github.com> Date: Mon, 25 Dec 2023 02:38:47 +0000 Subject: [PATCH] Dropship weapons console TGUI (#4812) # About the pull request Migrates the dropship weapons panel to TGUI. Design is primarily inspired by the MultiFunction Displays used in modern aircraft. The UI consists of two identical and independent panels. The pilot can choose which panels to display. Code wise this PR introduces the MFD which is a reusable component. # Explain why it's good for the game nanoui bad tgui good # Testing Photographs and Procedure
Screenshots & Videos Put screenshots and videos here with an empty line between the screenshots and the `
` tags. ## Update - Some styling improvements Improving the overall look and feel, making the background a dark grey over a black, rounding the edges. Making inactive buttons appear greyed out. ![image](https://github.com/cmss13-devs/cmss13/assets/101871009/0965b5cb-21b0-4b7f-84ea-40651e83a02e) ## Welcome screen - blurb for lore ![image](https://github.com/cmss13-devs/cmss13/assets/101871009/5872dcb6-ba87-485e-a736-8de0b3e5e36d) ## Equipment panel and map ![image](https://github.com/cmss13-devs/cmss13/assets/101871009/85fde5cc-e4a8-439e-8c55-d010a4780d8c) ## Equipment panel with camera ![image](https://github.com/cmss13-devs/cmss13/assets/101871009/034a2833-d37c-4c6b-8b08-64e3e09aefb0) ## Weapon panel and Camera ![image](https://github.com/cmss13-devs/cmss13/assets/101871009/ce246258-a879-4220-b481-3d5fbc800651) ## Target Acquisition with camera ![image](https://github.com/cmss13-devs/cmss13/assets/101871009/2778b9da-76f9-4c37-b3ba-9d45a1bdc625) ## Medevac lift with stretcher camera ![image](https://github.com/cmss13-devs/cmss13/assets/101871009/7e9ef10b-811c-4922-9f24-ae805bae24d9)
# Changelog :cl: ui: tgui dropship weapons console refactor: added MFD panel refactor: creates datum component to manage camera code qol: CAS weapons operator can see camera in UI add: CAS can offset in X and Y coordinates refactor: CAS can offset in different direction to attack vector /:cl: --------- Co-authored-by: fira --- code/__DEFINES/__game.dm | 1 + .../dcs/signals/atom/signals_item.dm | 9 + .../__DEFINES/dcs/signals/atom/signals_obj.dm | 2 + code/__DEFINES/layers.dm | 1 + code/_onclick/hud/rendering/plane_master.dm | 8 + code/game/camera_manager/camera_manager.dm | 235 +++ .../cas_manager/datums/cas_fire_envelope.dm | 139 +- .../cas_manager/datums/cas_fire_mission.dm | 70 +- .../machinery/computer/dropship_weapons.dm | 1259 +++++++++-------- .../structures/stool_bed_chair_nest/bed.dm | 9 + code/modules/client/client_procs.dm | 8 +- code/modules/cm_marines/dropship_equipment.dm | 224 ++- .../dropships/attach_points/attach_point.dm | 2 +- .../dropships/cas/fire_mission_record.dm | 5 + .../shuttle/computers/dropship_computer.dm | 2 +- code/modules/shuttle/shuttles/dropship.dm | 16 + colonialmarines.dme | 1 + maps/shuttles/dropship_alamo.dmm | 145 +- maps/shuttles/dropship_normandy.dmm | 124 +- nano/templates/dropship_weapons_console.tmpl | 245 ---- tgui/packages/tgui/interfaces/CasSim.js | 109 -- tgui/packages/tgui/interfaces/CasSim.tsx | 106 ++ tgui/packages/tgui/interfaces/CrtPanel.tsx | 20 + .../interfaces/DropshipWeaponsConsole.tsx | 366 +++++ .../tgui/interfaces/MfdPanels/CameraPanel.tsx | 37 + .../interfaces/MfdPanels/EquipmentPanel.tsx | 350 +++++ .../interfaces/MfdPanels/FiremissionPanel.tsx | 580 ++++++++ .../tgui/interfaces/MfdPanels/FultonPanel.tsx | 161 +++ .../tgui/interfaces/MfdPanels/MGPanel.tsx | 69 + .../tgui/interfaces/MfdPanels/MapPanel.tsx | 37 + .../interfaces/MfdPanels/MedevacPanel.tsx | 208 +++ .../MfdPanels/MultifunctionDisplay.tsx | 152 ++ .../tgui/interfaces/MfdPanels/SentryPanel.tsx | 89 ++ .../interfaces/MfdPanels/SpotlightPanel.tsx | 60 + .../interfaces/MfdPanels/SupportPanel.tsx | 62 + .../interfaces/MfdPanels/TargetAquisition.tsx | 519 +++++++ .../tgui/interfaces/MfdPanels/WeaponPanel.tsx | 179 +++ .../interfaces/MfdPanels/stateManagers.ts | 109 ++ .../tgui/interfaces/MfdPanels/types.ts | 112 ++ tgui/packages/tgui/interfaces/common/Dpad.tsx | 113 ++ .../tgui/styles/interfaces/CasSim.scss | 17 + .../tgui/styles/interfaces/CrtPanel.scss | 72 + .../styles/interfaces/DropshipWeapons.scss | 253 ++++ .../tgui/styles/interfaces/SidePanel.scss | 21 + .../tgui/styles/interfaces/common/Dpad.scss | 26 + .../tgui/styles/layouts/SplitWindow.scss | 13 + tgui/packages/tgui/styles/main.scss | 6 + 47 files changed, 5142 insertions(+), 1209 deletions(-) create mode 100644 code/game/camera_manager/camera_manager.dm delete mode 100644 nano/templates/dropship_weapons_console.tmpl delete mode 100644 tgui/packages/tgui/interfaces/CasSim.js create mode 100644 tgui/packages/tgui/interfaces/CasSim.tsx create mode 100644 tgui/packages/tgui/interfaces/CrtPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/DropshipWeaponsConsole.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/CameraPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/EquipmentPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/FiremissionPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/FultonPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/MGPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/MapPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/MedevacPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/MultifunctionDisplay.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/SentryPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/SpotlightPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/SupportPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/TargetAquisition.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/WeaponPanel.tsx create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/stateManagers.ts create mode 100644 tgui/packages/tgui/interfaces/MfdPanels/types.ts create mode 100644 tgui/packages/tgui/interfaces/common/Dpad.tsx create mode 100644 tgui/packages/tgui/styles/interfaces/CasSim.scss create mode 100644 tgui/packages/tgui/styles/interfaces/CrtPanel.scss create mode 100644 tgui/packages/tgui/styles/interfaces/DropshipWeapons.scss create mode 100644 tgui/packages/tgui/styles/interfaces/SidePanel.scss create mode 100644 tgui/packages/tgui/styles/interfaces/common/Dpad.scss create mode 100644 tgui/packages/tgui/styles/layouts/SplitWindow.scss diff --git a/code/__DEFINES/__game.dm b/code/__DEFINES/__game.dm index 11c6e335d932..7cb7440ba8da 100644 --- a/code/__DEFINES/__game.dm +++ b/code/__DEFINES/__game.dm @@ -392,6 +392,7 @@ block( \ #define FIRE_MISSION_WEAPON_REMOVED 8 #define FIRE_MISSION_WEAPON_UNUSABLE 16 #define FIRE_MISSION_WEAPON_OUT_OF_AMMO 32 +#define FIRE_MISSION_BAD_DIRECTION 64 #define FIRE_MISSION_NOT_EXECUTABLE -1 //Defines for firemission state diff --git a/code/__DEFINES/dcs/signals/atom/signals_item.dm b/code/__DEFINES/dcs/signals/atom/signals_item.dm index 6024c0524992..7b3b218e658a 100644 --- a/code/__DEFINES/dcs/signals/atom/signals_item.dm +++ b/code/__DEFINES/dcs/signals/atom/signals_item.dm @@ -68,3 +68,12 @@ //from /datum/authority/branch/role/proc/equip_role() #define COMSIG_POST_SPAWN_UPDATE "post_spawn_update" + +#define COMSIG_CAMERA_MAPNAME_ASSIGNED "camera_manager_mapname_assigned" +#define COMSIG_CAMERA_REGISTER_UI "camera_manager_register_ui" +#define COMSIG_CAMERA_UNREGISTER_UI "camera_manager_unregister_ui" +#define COMSIG_CAMERA_SET_NVG "camera_manager_set_nvg" +#define COMSIG_CAMERA_CLEAR_NVG "camera_manager_clear_nvg" +#define COMSIG_CAMERA_SET_TARGET "camera_manager_set_target" +#define COMSIG_CAMERA_SET_AREA "camera_manager_set_area" +#define COMSIG_CAMERA_CLEAR "camera_manager_clear_target" diff --git a/code/__DEFINES/dcs/signals/atom/signals_obj.dm b/code/__DEFINES/dcs/signals/atom/signals_obj.dm index 93579e068ec7..b5f2bb3ff6a9 100644 --- a/code/__DEFINES/dcs/signals/atom/signals_obj.dm +++ b/code/__DEFINES/dcs/signals/atom/signals_obj.dm @@ -30,4 +30,6 @@ /// from /obj/proc/afterbuckle() #define COSMIG_OBJ_AFTER_BUCKLE "signal_obj_after_buckle" +#define COMSIG_DROPSHIP_ADD_EQUIPMENT "dropship_add_equipment" +#define COMSIG_DROPSHIP_REMOVE_EQUIPMENT "dropship_remove_equipment" #define COMSIG_STRUCTURE_CRATE_SQUAD_LAUNCHED "structure_crate_squad_launched" diff --git a/code/__DEFINES/layers.dm b/code/__DEFINES/layers.dm index c0ccd5164b0b..5628395d7ffb 100644 --- a/code/__DEFINES/layers.dm +++ b/code/__DEFINES/layers.dm @@ -230,6 +230,7 @@ ///--------------- FULLSCREEN RUNECHAT BUBBLES ------------ #define LIGHTING_PLANE 100 #define EXTERIOR_LIGHTING_PLANE 101 +#define NVG_PLANE 110 ///Popup Chat Messages #define RUNECHAT_PLANE 501 diff --git a/code/_onclick/hud/rendering/plane_master.dm b/code/_onclick/hud/rendering/plane_master.dm index 91c0e24fae1f..d4181d7e9953 100644 --- a/code/_onclick/hud/rendering/plane_master.dm +++ b/code/_onclick/hud/rendering/plane_master.dm @@ -149,6 +149,14 @@ remove_filter("AO") add_filter("AO", 1, drop_shadow_filter(x = 0, y = -2, size = 4, color = "#04080FAA")) +/atom/movable/screen/plane_master/nvg_plane + name = "NVG plane" + plane = NVG_PLANE + render_relay_plane = RENDER_PLANE_GAME + blend_mode_override = BLEND_MULTIPLY + //icon = 'icons/mob/hud/screen1.dmi' + //icon_state = "noise" + /atom/movable/screen/plane_master/fullscreen name = "fullscreen alert plane" plane = FULLSCREEN_PLANE diff --git a/code/game/camera_manager/camera_manager.dm b/code/game/camera_manager/camera_manager.dm new file mode 100644 index 000000000000..93d56aca443c --- /dev/null +++ b/code/game/camera_manager/camera_manager.dm @@ -0,0 +1,235 @@ +#define DEFAULT_MAP_SIZE 15 + +#define RENDER_MODE_TARGET 1 +#define RENDER_MODE_AREA 2 + +/datum/component/camera_manager + var/map_name + var/obj/structure/machinery/camera/current + var/datum/shape/rectangle/current_area + var/atom/movable/screen/map_view/cam_screen + var/atom/movable/screen/background/cam_background + var/list/range_turfs = list() + /// The turf where the camera was last updated. + var/turf/last_camera_turf + var/target_x + var/target_y + var/target_z + var/target_width + var/target_height + var/list/cam_plane_masters + var/isXRay = FALSE + var/render_mode = RENDER_MODE_TARGET + +/datum/component/camera_manager/Initialize() + . = ..() + map_name = "camera_manager_[REF(src)]_map" + cam_screen = new + cam_screen.name = "screen" + cam_screen.assigned_map = map_name + cam_screen.del_on_map_removal = FALSE + cam_screen.screen_loc = "[map_name]:1,1" + cam_background = new + cam_background.assigned_map = map_name + cam_background.del_on_map_removal = FALSE + + cam_plane_masters = list() + for(var/plane in subtypesof(/atom/movable/screen/plane_master) - /atom/movable/screen/plane_master/blackness) + var/atom/movable/screen/plane_master/instance = new plane() + add_plane(instance) + +/datum/component/camera_manager/Destroy(force, ...) + . = ..() + range_turfs = null + current_area = null + cam_plane_masters = null + QDEL_NULL(cam_background) + QDEL_NULL(cam_screen) + if(current) + UnregisterSignal(current, COMSIG_PARENT_QDELETING) + +/datum/component/camera_manager/proc/add_plane(atom/movable/screen/plane_master/instance) + instance.assigned_map = map_name + instance.del_on_map_removal = FALSE + if(instance.blend_mode_override) + instance.blend_mode = instance.blend_mode_override + instance.screen_loc = "[map_name]:CENTER" + cam_plane_masters["[instance.plane]"] = instance + +/datum/component/camera_manager/proc/register(source, mob/user) + SIGNAL_HANDLER + var/client/user_client = user.client + if(!user_client) + return + user_client.register_map_obj(cam_background) + user_client.register_map_obj(cam_screen) + for(var/plane_id in cam_plane_masters) + user_client.register_map_obj(cam_plane_masters[plane_id]) + +/datum/component/camera_manager/proc/unregister(source, mob/user) + SIGNAL_HANDLER + var/client/user_client = user.client + if(!user_client) + return + user_client.clear_map(cam_background) + user_client.clear_map(cam_screen) + for(var/plane_id in cam_plane_masters) + user_client.clear_map(cam_plane_masters[plane_id]) + +/datum/component/camera_manager/RegisterWithParent() + . = ..() + START_PROCESSING(SSdcs, src) + SEND_SIGNAL(parent, COMSIG_CAMERA_MAPNAME_ASSIGNED, map_name) + RegisterSignal(parent, COMSIG_CAMERA_REGISTER_UI, PROC_REF(register)) + RegisterSignal(parent, COMSIG_CAMERA_UNREGISTER_UI, PROC_REF(unregister)) + RegisterSignal(parent, COMSIG_CAMERA_SET_NVG, PROC_REF(enable_nvg)) + RegisterSignal(parent, COMSIG_CAMERA_CLEAR_NVG, PROC_REF(disable_nvg)) + RegisterSignal(parent, COMSIG_CAMERA_SET_AREA, PROC_REF(set_camera_rect)) + RegisterSignal(parent, COMSIG_CAMERA_SET_TARGET, PROC_REF(set_camera)) + RegisterSignal(parent, COMSIG_CAMERA_CLEAR, PROC_REF(clear_camera)) + +/datum/component/camera_manager/UnregisterFromParent() + . = ..() + STOP_PROCESSING(SSdcs, src) + + UnregisterSignal(parent, COMSIG_CAMERA_REGISTER_UI) + UnregisterSignal(parent, COMSIG_CAMERA_UNREGISTER_UI) + UnregisterSignal(parent, COMSIG_CAMERA_SET_NVG) + UnregisterSignal(parent, COMSIG_CAMERA_CLEAR_NVG) + UnregisterSignal(parent, COMSIG_CAMERA_SET_AREA) + UnregisterSignal(parent, COMSIG_CAMERA_SET_TARGET) + UnregisterSignal(parent, COMSIG_CAMERA_CLEAR) + +/datum/component/camera_manager/proc/clear_camera() + SIGNAL_HANDLER + if(current) + UnregisterSignal(current, COMSIG_PARENT_QDELETING) + current_area = null + current = null + target_x = null + target_y = null + target_z = null + target_width = null + target_height = null + show_camera_static() + +/datum/component/camera_manager/proc/set_camera(source, atom/target, w, h) + SIGNAL_HANDLER + render_mode = RENDER_MODE_TARGET + if(current) + UnregisterSignal(current, COMSIG_PARENT_QDELETING) + current = target + target_width = w + target_height = h + RegisterSignal(current, COMSIG_PARENT_QDELETING, PROC_REF(show_camera_static)) + update_target_camera() + +/datum/component/camera_manager/proc/set_camera_rect(source, x, y, z, w, h) + SIGNAL_HANDLER + render_mode = RENDER_MODE_AREA + if(current) + UnregisterSignal(current, COMSIG_PARENT_QDELETING) + current = null + current_area = RECT(x, y, w, h) + target_x = x + target_y = y + target_z = z + update_area_camera() + +/datum/component/camera_manager/proc/enable_nvg(source, power, matrixcol) + SIGNAL_HANDLER + for(var/plane_id in cam_plane_masters) + var/atom/movable/screen/plane_master/plane = cam_plane_masters["[plane_id]"] + plane.add_filter("nvg", 1, color_matrix_filter(color_matrix_from_string(matrixcol))) + sync_lighting_plane_alpha(LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE) + +/datum/component/camera_manager/proc/disable_nvg() + SIGNAL_HANDLER + for(var/plane_id in cam_plane_masters) + var/atom/movable/screen/plane_master/plane = cam_plane_masters["[plane_id]"] + plane.remove_filter("nvg") + sync_lighting_plane_alpha(LIGHTING_PLANE_ALPHA_VISIBLE) + +/datum/component/camera_manager/proc/sync_lighting_plane_alpha(lighting_alpha) + var/atom/movable/screen/plane_master/lighting/lighting = cam_plane_masters["[LIGHTING_PLANE]"] + if (lighting) + lighting.alpha = lighting_alpha + var/atom/movable/screen/plane_master/lighting/exterior_lighting = cam_plane_masters["[EXTERIOR_LIGHTING_PLANE]"] + if (exterior_lighting) + exterior_lighting.alpha = min(GLOB.minimum_exterior_lighting_alpha, lighting_alpha) + +/** + * Set the displayed camera to the static not-connected. + */ +/datum/component/camera_manager/proc/show_camera_static() + cam_screen.vis_contents.Cut() + last_camera_turf = null + cam_background.icon_state = "scanline2" + cam_background.fill_rect(1, 1, DEFAULT_MAP_SIZE, DEFAULT_MAP_SIZE) + +/datum/component/camera_manager/proc/update_target_camera() + // Show static if can't use the camera + if(!current?.can_use()) + show_camera_static() + return + + // Is this camera located in or attached to a living thing, Vehicle or helmet? If so, assume the camera's loc is the living (or non) thing. + var/cam_location = current + if(isliving(current.loc) || isVehicle(current.loc)) + cam_location = current.loc + else if(istype(current.loc, /obj/item/clothing/head/helmet/marine)) + var/obj/item/clothing/head/helmet/marine/helmet = current.loc + cam_location = helmet.loc + + // If we're not forcing an update for some reason and the cameras are in the same location, + // we don't need to update anything. + // Most security cameras will end here as they're not moving. + var/newturf = get_turf(cam_location) + if(last_camera_turf == newturf) + return + + // Cameras that get here are moving, and are likely attached to some moving atom such as cyborgs. + last_camera_turf = get_turf(cam_location) + + var/list/visible_things = current.isXRay() ? range(current.view_range, cam_location) : view(current.view_range, cam_location) + render_objects(visible_things) + +/datum/component/camera_manager/proc/update_area_camera() + // Show static if can't use the camera + if(!current_area || !target_z) + show_camera_static() + return + + // If we're not forcing an update for some reason and the cameras are in the same location, + // we don't need to update anything. + // Most security cameras will end here as they're not moving. + var/turf/new_location = locate(target_x, target_y, target_z) + if(last_camera_turf == new_location) + return + + // Cameras that get here are moving, and are likely attached to some moving atom such as cyborgs. + last_camera_turf = new_location + + var/x_size = current_area.width + var/y_size = current_area.height + var/turf/target = locate(current_area.center_x, current_area.center_y, target_z) + + var/list/visible_things = isXRay ? range("[x_size]x[y_size]", target) : view("[x_size]x[y_size]", target) + src.render_objects(visible_things) + +/datum/component/camera_manager/proc/render_objects(list/visible_things) + var/list/visible_turfs = list() + for(var/turf/visible_turf in visible_things) + visible_turfs += visible_turf + + var/list/bbox = get_bbox_of_atoms(visible_turfs) + var/size_x = bbox[3] - bbox[1] + 1 + var/size_y = bbox[4] - bbox[2] + 1 + + cam_screen.vis_contents = visible_turfs + cam_background.icon_state = "clear" + cam_background.fill_rect(1, 1, size_x, size_y) + +#undef DEFAULT_MAP_SIZE +#undef RENDER_MODE_TARGET +#undef RENDER_MODE_AREA diff --git a/code/game/cas_manager/datums/cas_fire_envelope.dm b/code/game/cas_manager/datums/cas_fire_envelope.dm index 330521f34e36..04cd688194dd 100644 --- a/code/game/cas_manager/datums/cas_fire_envelope.dm +++ b/code/game/cas_manager/datums/cas_fire_envelope.dm @@ -1,7 +1,6 @@ /datum/cas_fire_envelope var/obj/structure/machinery/computer/dropship_weapons/linked_console var/list/datum/cas_fire_mission/missions - var/max_mission_len = 5 var/fire_length var/grace_period //how much time you have after initiating fire mission and before you can't change firemissions var/flyto_period //how much time it takes from sound alarm start to first hit. CAS is vulnerable here @@ -30,35 +29,36 @@ linked_console = null return ..() +/datum/cas_fire_envelope/ui_data(mob/user) + . = list() + .["missions"] = list() + for(var/datum/cas_fire_mission/mission in missions) + .["missions"] += list(mission.ui_data(user)) + + /datum/cas_fire_envelope/proc/get_total_duration() return grace_period+flyto_period+flyoff_period +/datum/cas_fire_envelope/proc/update_weapons(list/obj/structure/dropship_equipment/weapon/weapons) + for(var/datum/cas_fire_mission/mission in missions) + mission.update_weapons(weapons, fire_length) + /datum/cas_fire_envelope/proc/generate_mission(firemission_name, length) - if(!missions || !linked_console || missions.len>max_mission_len || !fire_length) + if(!missions || !linked_console || !fire_length) return null - var/list/obj/structure/dropship_equipment/weapons = list() - for(var/X in linked_console.shuttle_equipments) - var/obj/structure/dropship_equipment/E = X - if(E.is_weapon) - weapons += E + var/shuttle_tag = linked_console.shuttle_tag + var/obj/docking_port/mobile/marine_dropship/dropship = SSshuttle.getShuttle(shuttle_tag) + for(var/obj/structure/dropship_equipment/equipment as anything in dropship.equipments) + if(equipment.is_weapon) + weapons += equipment var/datum/cas_fire_mission/fm = new() - - if(weapons.len==0) - return null //why bother? - for(var/obj/structure/dropship_equipment/weapon/wp in weapons) - var/datum/cas_fire_mission_record/record = new() - record.weapon = wp - record.offsets = new /list(fire_length) - for(var/idx = 1; idx<=fire_length; idx++) - record.offsets[idx] = "-" - fm.records += record + fm.build_new_record(wp, fire_length) fm.name = firemission_name fm.mission_length = length - missions += fm return fm @@ -67,67 +67,61 @@ mission_error = null if(stat > FIRE_MISSION_STATE_IN_TRANSIT && stat < FIRE_MISSION_STATE_COOLDOWN) mission_error = "Fire Mission is under way already." - return 0 + return FIRE_MISSION_NOT_EXECUTABLE if(!missions[mission_id]) - return -1 + return FIRE_MISSION_NOT_EXECUTABLE var/datum/cas_fire_mission/mission = missions[mission_id] if(!mission) - return -1 - if(!mission.records[weapon_id]) - return -1 - var/datum/cas_fire_mission_record/fmr = mission.records[weapon_id] + return FIRE_MISSION_NOT_EXECUTABLE + + var/datum/cas_fire_mission_record/fmr = mission.record_for_weapon(weapon_id) + if(!fmr) + return FIRE_MISSION_NOT_EXECUTABLE if(!fmr.offsets || isnull(fmr.offsets[offset_step])) - return -1 + return FIRE_MISSION_NOT_EXECUTABLE var/old_offset = fmr.offsets[offset_step] + if(offset == null) + offset = "-" fmr.offsets[offset_step] = offset var/check_result = mission.check(linked_console) if(check_result == FIRE_MISSION_CODE_ERROR) - return -1 + return FIRE_MISSION_NOT_EXECUTABLE if(check_result == FIRE_MISSION_ALL_GOOD) - return 1 + return FIRE_MISSION_ALL_GOOD if(check_result == FIRE_MISSION_WEAPON_OUT_OF_AMMO) - return 1 + return FIRE_MISSION_ALL_GOOD mission_error = mission.error_message(check_result) if(skip_checks) - return 0 + return FIRE_MISSION_ALL_GOOD //we have mission error. Fill the thing and restore previous state fmr.offsets[offset_step] = old_offset - return 0 + return FIRE_MISSION_ALL_GOOD -/datum/cas_fire_envelope/proc/execute_firemission(datum/cas_signal/target_turf, offset, dir, mission_id) - if(!istype(target_turf)) - mission_error = "No target." - return 0 +/datum/cas_fire_envelope/proc/execute_firemission(datum/cas_signal/signal, target_turf,dir, mission_id) if(stat != FIRE_MISSION_STATE_IDLE) mission_error = "Fire Mission is under way already." - return 0 + return FIRE_MISSION_NOT_EXECUTABLE if(!missions[mission_id]) - return -1 - if(offset<0) - mission_error = "Can't have negative offsets." - return 0 - if(offset>max_offset) - mission_error = "[max_offset] is the maximum possible offset." - return 0 + return FIRE_MISSION_NOT_EXECUTABLE if(dir!=NORTH && dir!=SOUTH && dir!=WEST && dir!=EAST) mission_error = "Incorrect direction." - return 0 + return FIRE_MISSION_BAD_DIRECTION mission_error = null var/datum/cas_fire_mission/mission = missions[mission_id] var/check_result = mission.check(linked_console) if(check_result == FIRE_MISSION_CODE_ERROR) - return -1 + return FIRE_MISSION_CODE_ERROR if(check_result != FIRE_MISSION_ALL_GOOD) mission_error = mission.error_message(check_result) - return 0 + return FIRE_MISSION_CODE_ERROR //actual firemission code - execute_firemission_unsafe(target_turf, offset, dir, mission) - return 1 + execute_firemission_unsafe(signal, target_turf, dir, mission) + return FIRE_MISSION_ALL_GOOD /datum/cas_fire_envelope/proc/firemission_status_message() switch(stat) @@ -167,6 +161,7 @@ if(!guidance) guidance = new /obj/effect/firemission_guidance() guidance.forceMove(location) + guidance.updateCameras(linked_console) /datum/cas_fire_envelope/proc/user_is_guided(user) return guidance && (user in guidance.users) @@ -183,7 +178,6 @@ guidance.users += user RegisterSignal(user, COMSIG_MOB_RESISTED, PROC_REF(exit_cam_resist)) - /datum/cas_fire_envelope/proc/apply_upgrade(user) var/mob/M = user if(linked_console.upgraded == MATRIX_NVG) @@ -193,8 +187,6 @@ M.overlay_fullscreen("matrix", /atom/movable/screen/fullscreen/flash/noise/nvg) M.lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE M.sync_lighting_plane_alpha() - else if (linked_console.upgraded == MATRIX_WIDE) - M.client?.change_view(linked_console.power + 5, M) /datum/cas_fire_envelope/proc/remove_upgrades(user) @@ -221,6 +213,7 @@ remove_upgrades(user) guidance.users -= user UnregisterSignal(user, COMSIG_MOB_RESISTED) + guidance.clearCameras(linked_console) /datum/cas_fire_envelope/proc/exit_cam_resist(mob/user) SIGNAL_HANDLER @@ -231,54 +224,36 @@ /datum/cas_fire_envelope/proc/check_firemission_loc(datum/cas_signal/target_turf) return TRUE //redefined in child class -/datum/cas_fire_envelope/proc/execute_firemission_unsafe(datum/cas_signal/target_turf, offset, dir, datum/cas_fire_mission/mission) - var/sx = 0 - var/sy = 0 - - recorded_dir = dir - recorded_offset = offset - +/** + * Execute firemission. + */ +/datum/cas_fire_envelope/proc/execute_firemission_unsafe(datum/cas_signal/signal, turf/target_turf, dir, datum/cas_fire_mission/mission) stat = FIRE_MISSION_STATE_IN_TRANSIT + to_chat(usr, SPAN_ALERT("Firemission underway!")) sleep(grace_period) stat = FIRE_MISSION_STATE_ON_TARGET - switch(recorded_dir) - if(NORTH) //default direction - sx = 0 - sy = 1 - if(SOUTH) - sx = 0 - sy = -1 - if(EAST) - sx = 1 - sy = 0 - if(WEST) - sx = -1 - sy = 0 if(!target_turf) stat = FIRE_MISSION_STATE_IDLE mission_error = "Target Lost." return - var/turf/tt_turf = get_turf(target_turf.signal_loc) - if(!tt_turf || !check_firemission_loc(target_turf)) + if(!target_turf || !check_firemission_loc(signal)) stat = FIRE_MISSION_STATE_IDLE mission_error = "Target is off bounds or obstructed." return - var/turf/shootloc = locate(tt_turf.x + sx*recorded_offset, tt_turf.y + sy*recorded_offset,tt_turf.z) - if(!shootloc || !istype(shootloc)) - stat = FIRE_MISSION_STATE_IDLE - mission_error = "Target is off bounds." - return - change_current_loc(shootloc) - playsound(shootloc, soundeffect, 70, TRUE, 50) + change_current_loc(target_turf) + playsound(target_turf, soundeffect, 70, TRUE, 50) sleep(flyto_period) stat = FIRE_MISSION_STATE_FIRING - mission.execute_firemission(linked_console, shootloc, recorded_dir, fire_length, step_delay, src) + mission.execute_firemission(linked_console, target_turf, dir, fire_length, step_delay, src) stat = FIRE_MISSION_STATE_OFF_TARGET sleep(flyoff_period) stat = FIRE_MISSION_STATE_COOLDOWN sleep(cooldown_period) stat = FIRE_MISSION_STATE_IDLE +/** + * Change attack vector for firemission + */ /datum/cas_fire_envelope/proc/change_direction(new_dir) if(stat > FIRE_MISSION_STATE_IN_TRANSIT) mission_error = "Fire Mission is under way already." @@ -346,13 +321,13 @@ /obj/structure/machinery/computer/dropship_weapons/proc/update_mission(mission_id, weapon_id, offset_step, offset) var/result = firemission_envelope.update_mission(mission_id, weapon_id, offset_step, offset) - if(result<1) + if(result != FIRE_MISSION_ALL_GOOD) return firemission_envelope.mission_error return "OK" // Used in the simulation room for firemission testing. /obj/structure/machinery/computer/dropship_weapons/proc/execute_firemission(obj/location, offset, dir, mission_id) var/result = firemission_envelope.execute_firemission(get_turf(location), offset, dir, mission_id) - if(result<1) + if(result != FIRE_MISSION_ALL_GOOD) return firemission_envelope.mission_error return "OK" diff --git a/code/game/cas_manager/datums/cas_fire_mission.dm b/code/game/cas_manager/datums/cas_fire_mission.dm index cb43caec30bb..ece78042ac25 100644 --- a/code/game/cas_manager/datums/cas_fire_mission.dm +++ b/code/game/cas_manager/datums/cas_fire_mission.dm @@ -1,17 +1,83 @@ /obj/effect/firemission_guidance invisibility = 101 - var/list/users + var/list/mob/users + var/camera_width = 11 + var/camera_height = 11 + var/view_range = 7 /obj/effect/firemission_guidance/New() ..() users = list() +/obj/effect/firemission_guidance/Destroy(force) + . = ..() + users = null + +/obj/effect/firemission_guidance/proc/can_use() + return TRUE + +/obj/effect/firemission_guidance/proc/isXRay() + return FALSE + +/obj/effect/firemission_guidance/proc/updateCameras(atom/target) + SEND_SIGNAL(target, COMSIG_CAMERA_SET_TARGET, src, camera_width, camera_height) + +/obj/effect/firemission_guidance/proc/clearCameras(atom/target) + SEND_SIGNAL(target, COMSIG_CAMERA_CLEAR) + /datum/cas_fire_mission var/mission_length = 3 //can be 3,4,6 or 12 var/list/datum/cas_fire_mission_record/records = list() var/obj/structure/dropship_equipment/weapon/error_weapon var/name = "Unnamed Firemission" +/datum/cas_fire_mission/ui_data(mob/user) + . = list() + .["name"] = sanitize(copytext(name, 1, MAX_MESSAGE_LEN)) + .["records"] = list() + for(var/datum/cas_fire_mission_record/record as anything in records) + .["records"] += list(record.ui_data(user)) + +/datum/cas_fire_mission/proc/build_new_record(obj/structure/dropship_equipment/weapon/weap, fire_length) + var/datum/cas_fire_mission_record/record = new() + record.weapon = weap + record.offsets = new /list(fire_length) + for(var/idx = 1; idx<=fire_length; idx++) + record.offsets[idx] = "-" + records += record + +/datum/cas_fire_mission/proc/update_weapons(list/obj/structure/dropship_equipment/weapon/weapons, fire_length) + var/list/datum/cas_fire_mission_record/bad_records = list() + var/list/obj/structure/dropship_equipment/weapon/missing_weapons = list() + for(var/datum/cas_fire_mission_record/record in records) + // if weapon appears in weapons list but not in record + // > add empty record for new weapon + var/found = FALSE + for(var/obj/structure/dropship_equipment/weapon/weap in weapons) + if(record.weapon == weap) + found=TRUE + break + if(!found) + bad_records.Add(record) + for(var/obj/structure/dropship_equipment/weapon/weap in weapons) + var/found = FALSE + for(var/datum/cas_fire_mission_record/record in records) + if(record.weapon == weap) + found=TRUE + break + if(!found) + missing_weapons.Add(weap) + for(var/datum/cas_fire_mission_record/record in bad_records) + records -= record + for(var/obj/structure/dropship_equipment/weapon/weap in missing_weapons) + build_new_record(weap, fire_length) + +/datum/cas_fire_mission/proc/record_for_weapon(weapon_id) + for(var/datum/cas_fire_mission_record/record as anything in records) + if(record.weapon.ship_base.attach_id == weapon_id) + return record + return null + /datum/cas_fire_mission/proc/check(obj/structure/machinery/computer/dropship_weapons/linked_console) error_weapon = null if(records.len == 0) @@ -165,7 +231,7 @@ var/step = 1 for(step = 1; step<=steps; step++) if(step > next_step) - current_turf = get_step(current_turf,direction) + current_turf = get_step(current_turf, direction) next_step += tally_step if(envelope) envelope.change_current_loc(current_turf) diff --git a/code/game/machinery/computer/dropship_weapons.dm b/code/game/machinery/computer/dropship_weapons.dm index d86b9fc28a28..2f9047abc63c 100644 --- a/code/game/machinery/computer/dropship_weapons.dm +++ b/code/game/machinery/computer/dropship_weapons.dm @@ -11,7 +11,6 @@ exproof = TRUE var/shuttle_tag // Used to know which shuttle we're linked to. var/obj/structure/dropship_equipment/selected_equipment //the currently selected equipment installed on the shuttle this console controls. - var/list/shuttle_equipments = list() //list of the equipments on the shuttle this console controls var/cavebreaker = FALSE //ignore caves and other restrictions? var/datum/cas_fire_envelope/firemission_envelope var/datum/cas_fire_mission/selected_firemission @@ -25,15 +24,41 @@ var/datum/simulator/simulation var/datum/cas_fire_mission/configuration + // groundside maps + var/datum/tacmap/tacmap + var/minimap_type = MINIMAP_FLAG_USCM + + // Cameras + var/camera_target_id + var/camera_width = 11 + var/camera_height = 11 + var/camera_map_name + + var/registered = FALSE + /obj/structure/machinery/computer/dropship_weapons/Initialize() . = ..() simulation = new() + tacmap = new(src, minimap_type) + + RegisterSignal(src, COMSIG_CAMERA_MAPNAME_ASSIGNED, PROC_REF(camera_mapname_update)) + + // camera setup + AddComponent(/datum/component/camera_manager) + SEND_SIGNAL(src, COMSIG_CAMERA_CLEAR) /obj/structure/machinery/computer/dropship_weapons/New() ..() if(firemission_envelope) firemission_envelope.linked_console = src +/obj/structure/machinery/computer/dropship_weapons/proc/camera_mapname_update(source, value) + camera_map_name = value + +/obj/structure/machinery/computer/dropship_weapons/Destroy() + . = ..() + UnregisterSignal(src, COMSIG_CAMERA_MAPNAME_ASSIGNED) + /obj/structure/machinery/computer/dropship_weapons/attack_hand(mob/user) if(..()) return @@ -43,7 +68,7 @@ to_chat(user, SPAN_WARNING("Weapons modification access denied, attempting to launch simulation.")) if(!selected_firemission) - to_chat(usr, SPAN_WARNING("Firemission must be selected before attempting to run the simulation")) + to_chat(user, SPAN_WARNING("Firemission must be selected before attempting to run the simulation")) return tgui_interact(user) @@ -54,139 +79,41 @@ /obj/structure/machinery/computer/dropship_weapons/attackby(obj/item/W, mob/user as mob) if(istype(W, /obj/item/frame/matrix_frame)) - var/obj/item/frame/matrix_frame/MATRIX = W - if(MATRIX.state == ASSEMBLY_LOCKED) + var/obj/item/frame/matrix_frame/matrix = W + if(matrix.state == ASSEMBLY_LOCKED) user.drop_held_item(W, src) W.forceMove(src) to_chat(user, SPAN_NOTICE("You swap the matrix in the dropship guidance camera system, destroying the older part in the process")) - upgraded = MATRIX.upgrade - matrixcol = MATRIX.matrixcol - power = MATRIX.power + upgraded = matrix.upgrade + matrixcol = matrix.matrixcol + power = matrix.power else to_chat(user, SPAN_WARNING("Matrix is not complete!")) +/obj/structure/machinery/computer/dropship_weapons/proc/equipment_update(obj/docking_port/mobile/marine_dropship/dropship) + SIGNAL_HANDLER + var/list/obj/structure/dropship_equipment/weapons = list() + for(var/obj/structure/dropship_equipment/weapon/weap as anything in dropship.equipments) + weapons.Add(weap) + firemission_envelope.update_weapons(weapons) + /obj/structure/machinery/computer/dropship_weapons/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 0) - var/data[0] var/obj/docking_port/mobile/marine_dropship/dropship = SSshuttle.getShuttle(shuttle_tag) if (!istype(dropship)) return - var/shuttle_state - switch(dropship.mode) - if(SHUTTLE_IDLE) - shuttle_state = "idle" - if(SHUTTLE_IGNITING) - shuttle_state = "warmup" - if(SHUTTLE_CALL) - shuttle_state = "in_transit" - if(SHUTTLE_CRASHED) - shuttle_state = "crashed" - - - var/list/equipment_data = list() - var/list/targets_data = list() - var/list/firemission_data = list() - var/list/firemission_edit_data = list() - var/list/firemission_edit_timeslices = list() - - for(var/ts = 1; ts<=firemission_envelope.fire_length; ts++) - firemission_edit_timeslices += ts - - var/current_mission_error = null - if(!faction) - return //no faction, no weapons - - var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction] - - if(!cas_group) - return //broken group. No fighting - - for(var/X in cas_group.cas_signals) - var/datum/cas_signal/LT = X - if(!istype(LT) || !LT.valid_signal()) - continue - var/area/laser_area = get_area(LT.signal_loc) - targets_data += list(list("target_name" = "[LT.name] ([laser_area.name])", "target_tag" = LT.target_id)) - shuttle_equipments = dropship.equipments - var/element_nbr = 1 - for(var/X in dropship.equipments) - var/obj/structure/dropship_equipment/E = X - equipment_data += list(list("name"= sanitize(copytext(E.name,1,MAX_MESSAGE_LEN)), "eqp_tag" = element_nbr, "is_weapon" = E.is_weapon, "is_interactable" = E.is_interactable)) - element_nbr++ - E.linked_console = src - - - var/selected_eqp_name = "" - var/selected_eqp_ammo_name = "" - var/selected_eqp_ammo_amt = 0 - var/selected_eqp_max_ammo_amt = 0 var/screen_mode = 0 - var/fm_length = 0 - var/fm_offset = 0 - var/fm_direction = "" - var/fm_step_text = "" - var/firemission_signal - var/firemission_stat = 0 - if(selected_equipment) - selected_eqp_name = sanitize(copytext(selected_equipment.name,1,MAX_MESSAGE_LEN)) - if(selected_equipment.ammo_equipped) - selected_eqp_ammo_name = sanitize(copytext(selected_equipment.ammo_equipped.name,1,MAX_MESSAGE_LEN)) - selected_eqp_ammo_amt = selected_equipment.ammo_equipped.ammo_count - selected_eqp_max_ammo_amt = selected_equipment.ammo_equipped.max_ammo_count - screen_mode = selected_equipment.screen_mode - - var/firemission_id = 1 - var/found_selected = FALSE if(firemission_envelope) - firemission_stat = firemission_envelope.stat - fm_step_text = firemission_envelope.firemission_status_message() - for(var/datum/cas_fire_mission/X in firemission_envelope.missions) - if(!istype(X)) - continue //the fuck - var/error_code = X.check(src) - - var/selected = X == selected_firemission - if(error_code != FIRE_MISSION_ALL_GOOD && selected) - selected = FALSE - selected_firemission = null - var/can_edit = error_code != FIRE_MISSION_CODE_ERROR && !selected - - if(selected) - found_selected = TRUE - var/can_interact = firemission_envelope.stat == FIRE_MISSION_STATE_IDLE && error_code == FIRE_MISSION_ALL_GOOD - firemission_data += list(list("name"= sanitize(copytext(X.name,1,MAX_MESSAGE_LEN)), "mission_tag" = firemission_id, "can_edit" = can_edit, "can_interact" = can_interact, "selected" = selected)) - firemission_id++ - if(!istype(editing_firemission)) editing_firemission = null - //the fuck if(editing_firemission) var/error_code = editing_firemission.check(src) var/can_edit = error_code != FIRE_MISSION_CODE_ERROR - if(error_code != FIRE_MISSION_ALL_GOOD) - current_mission_error = editing_firemission.error_message(error_code) - else - current_mission_error = null if(!can_edit) editing_firemission = null //abort - else - screen_mode = 2 - for(var/datum/cas_fire_mission_record/firerec in editing_firemission.records) - var/gimbal = firerec.get_offsets() - var/ammo = firerec.get_ammo() - var/offsets = new /list(firerec.offsets.len) - for(var/idx = 1; idx < firerec.offsets.len; idx++) - offsets[idx] = firerec.offsets[idx] == null ? "-" : firerec.offsets[idx] - firemission_edit_data += list(list("name" = sanitize(copytext(firerec.weapon.name, 1, 50)), "ammo" = ammo, "gimbal" = gimbal, "offsets" = firerec.offsets)) - - if(!found_selected) - selected_firemission = null - - if(editing_firemission) - fm_length = editing_firemission.mission_length if((screen_mode != 0 && in_firemission_mode) || !selected_firemission) in_firemission_mode = FALSE @@ -196,497 +123,664 @@ selected_firemission = null if(selected_firemission && in_firemission_mode) screen_mode = 3 - fm_offset = firemission_envelope.recorded_offset - fm_direction = dir2text(firemission_envelope.recorded_dir) if(firemission_envelope.recorded_loc && (!firemission_envelope.recorded_loc.signal_loc || !firemission_envelope.recorded_loc.signal_loc:loc)) firemission_envelope.recorded_loc = null - firemission_signal = firemission_envelope.recorded_loc?firemission_envelope.recorded_loc.get_name() : "NOT SELECTED" - if(!fm_direction) - fm_direction = "NOT SELECTED" - - if(screen_mode != 3 || !selected_firemission || shuttle_state != "in_transit") - update_location(null) - // /if(firemission_envelope) - - data = list( - "shuttle_state" = shuttle_state, - "fire_mission_enabled" = dropship.in_flyby, - "equipment_data" = equipment_data, - "targets_data" = targets_data, - "selected_eqp" = selected_eqp_name, - "selected_eqp_ammo_name" = selected_eqp_ammo_name, - "selected_eqp_ammo_amt" = selected_eqp_ammo_amt, - "selected_eqp_max_ammo_amt" = selected_eqp_max_ammo_amt, - "screen_mode" = screen_mode, - "firemission_data" = firemission_data, - "editing_firemission" = editing_firemission, - "editing_firemission_length" = fm_length, - "firemission_edit_data" = firemission_edit_data, - "current_mission_error" = current_mission_error, - "firemission_edit_timeslices" = firemission_edit_timeslices, - "has_firemission" = !!firemission_envelope, - "can_firemission" = !!selected_firemission && shuttle_state == "in_transit", - "can_launch_firemission" = !!selected_firemission && shuttle_state == "in_transit" && firemission_stat != FIRE_MISSION_STATE_IDLE, - //firemission related stuff - "firemission_name" = (selected_firemission ? selected_firemission.name : ""), - "firemission_selected_laser" = firemission_signal, - "firemission_offset" = fm_offset, - "firemission_direction" = fm_direction, - "firemission_message" = fm_step_text, - "firemission_step" = firemission_stat, - ) + if(screen_mode != 3 || !selected_firemission || dropship.mode != SHUTTLE_CALL) + update_location(user, null) - ui = SSnano.nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) + ui_data(user) + if(!tacmap.map_holder) + var/level = SSmapping.levels_by_trait(tacmap.targeted_ztrait) + tacmap.map_holder = SSminimaps.fetch_tacmap_datum(level[1], tacmap.allowed_flags) + user.client.register_map_obj(tacmap.map_holder.map) + tgui_interact(user) + +/obj/structure/machinery/computer/dropship_weapons/tgui_interact(mob/user, datum/tgui/ui) + if(!registered) + var/obj/docking_port/mobile/marine_dropship/dropship = SSshuttle.getShuttle(shuttle_tag) + RegisterSignal(dropship, COMSIG_DROPSHIP_ADD_EQUIPMENT, PROC_REF(equipment_update)) + RegisterSignal(dropship, COMSIG_DROPSHIP_REMOVE_EQUIPMENT, PROC_REF(equipment_update)) + registered=TRUE + ui = SStgui.try_update_ui(user, src, ui) if (!ui) - ui = new(user, src, ui_key, "dropship_weapons_console.tmpl", "Weapons Control", 800, 600) - ui.set_initial_data(data) + SEND_SIGNAL(src, COMSIG_CAMERA_REGISTER_UI, user) + ui = new(user, src, "DropshipWeaponsConsole", "Weapons Console") ui.open() - ui.set_auto_update(1) -/obj/structure/machinery/computer/dropship_weapons/Topic(href, href_list) - if(..()) - return +/obj/structure/machinery/computer/dropship_weapons/ui_close(mob/user) + . = ..() + SEND_SIGNAL(src, COMSIG_CAMERA_UNREGISTER_UI, user) + if(simulation.looking_at_simulation) + simulation.stop_watching(user) + +/obj/structure/machinery/computer/dropship_weapons/ui_status(mob/user, datum/ui_state/state) + . = ..() + if(inoperable()) + return UI_CLOSE + if(!faction) + return UI_CLOSE + + var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction] + if(!cas_group) + return UI_CLOSE + +/obj/structure/machinery/computer/dropship_weapons/ui_state(mob/user) + return GLOB.not_incapacitated_and_adjacent_strict_state - add_fingerprint(usr) +/obj/structure/machinery/computer/dropship_weapons/ui_static_data(mob/user) + . = list() + .["tactical_map_ref"] = tacmap.map_holder.map_ref + .["camera_map_ref"] = camera_map_name +/obj/structure/machinery/computer/dropship_weapons/ui_data(mob/user) + . = list() var/obj/docking_port/mobile/marine_dropship/dropship = SSshuttle.getShuttle(shuttle_tag) if (!istype(dropship)) return - if(href_list["equip_interact"]) - var/base_tag = text2num(href_list["equip_interact"]) - var/obj/structure/dropship_equipment/E = shuttle_equipments[base_tag] - E.linked_console = src - E.equipment_interact(usr) - - if(href_list["open_fire"]) - var/targ_id = text2num(href_list["open_fire"]) - var/mob/M = usr - if(ishuman(M)) - var/mob/living/carbon/human/H = M - if(!H.allow_gun_usage) - to_chat(H, SPAN_WARNING("Your programming prevents you from operating dropship weaponry!")) - return - var/obj/structure/dropship_equipment/weapon/DEW = selected_equipment - if(!selected_equipment || !selected_equipment.is_weapon) - to_chat(usr, SPAN_WARNING("No weapon selected.")) - return - if(!skillcheck(M, SKILL_PILOT, DEW.skill_required)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("You don't have the training to fire this weapon!")) - return + var/datum/cas_signal/sig = get_cas_signal(camera_target_id) + if(camera_target_id && !sig) + set_camera_target(null) - if(!faction) - return //no faction, no weapons - - var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction] - - if(!cas_group) - return //broken group. No fighting - - for(var/X in cas_group.cas_signals) - var/datum/cas_signal/LT = X - if(LT.target_id == targ_id && LT.valid_signal()) - if(dropship.mode != SHUTTLE_CALL) - to_chat(usr, SPAN_WARNING("Dropship can only fire while in flight.")) - return - if(dropship.door_override) - return - if(!selected_equipment || !selected_equipment.is_weapon) - to_chat(usr, SPAN_WARNING("No weapon selected.")) - return - DEW = selected_equipment // for if the weapon somehow changes - if(!skillcheck(M, SKILL_PILOT, DEW.skill_required)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("You don't have the training to fire this weapon!")) - return - if(!dropship.in_flyby && DEW.fire_mission_only) - to_chat(usr, SPAN_WARNING("[DEW] requires a fire mission flight type to be fired.")) - return - - if(!DEW.ammo_equipped || DEW.ammo_equipped.ammo_count <= 0) - to_chat(usr, SPAN_WARNING("[DEW] has no ammo.")) - return - if(DEW.last_fired > world.time - DEW.firing_delay) - to_chat(usr, SPAN_WARNING("[DEW] just fired, wait for it to cool down.")) - return - if(!LT.signal_loc) - return - var/turf/TU = get_turf(LT.signal_loc) - var/area/targ_area = get_area(LT.signal_loc) - var/is_outside = FALSE - if(is_ground_level(TU.z)) - switch(targ_area.ceiling) - if(CEILING_NONE) - is_outside = TRUE - if(CEILING_GLASS) - is_outside = TRUE - if(!is_outside && !cavebreaker) //cavebreaker doesn't care - to_chat(usr, SPAN_WARNING("INVALID TARGET: target must be visible from high altitude.")) - return - if (protected_by_pylon(TURF_PROTECTION_CAS, TU)) - to_chat(usr, SPAN_WARNING("INVALID TARGET: biological-pattern interference with signal.")) - return - if(!DEW.ammo_equipped.can_fire_at(TU, usr)) - return - - DEW.open_fire(LT.signal_loc) - break - - if(href_list["deselect"]) - var/mob/M = usr - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return - selected_equipment = null + .["screen_mode"] = get_screen_mode() - if(href_list["create_mission"]) - var/mob/M = usr - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return - if(firemission_envelope.max_mission_len <= firemission_envelope.missions.len) - to_chat(usr, SPAN_WARNING("Cannot store more than [firemission_envelope.max_mission_len] Fire Missions.")) - return - var/fm_name = stripped_input(usr, "", "Enter Fire Mission Name", "Fire Mission [firemission_envelope.missions.len+1]", 50) - if(!fm_name || length(fm_name) < 5) - to_chat(usr, SPAN_WARNING("Name too short (at least 5 symbols).")) - return - var/fm_length = stripped_input(usr, "Enter length of the Fire Mission. Has to be less than [firemission_envelope.fire_length]. Use something that divides [firemission_envelope.fire_length] for optimal performance.", "Fire Mission Length (in tiles)", "[firemission_envelope.fire_length]", 5) - var/fm_length_n = text2num(fm_length) - if(!fm_length_n) - to_chat(usr, SPAN_WARNING("Incorrect input format.")) - return - if(fm_length_n > firemission_envelope.fire_length) - to_chat(usr, SPAN_WARNING("Fire Mission is longer than allowed by this vehicle.")) - return - if(firemission_envelope.stat != FIRE_MISSION_STATE_IDLE) - to_chat(usr, SPAN_WARNING("Vehicle has to be idle to allow Fire Mission editing and creation.")) - return - //everything seems to be fine now - firemission_envelope.generate_mission(fm_name, fm_length_n) - - if(href_list["mission_tag_delete"]) - var/ref = text2num(href_list["mission_tag_delete"]) - var/mob/M = usr - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return - if(ref>firemission_envelope.missions.len) - to_chat(usr, SPAN_WARNING("Fire Mission ID corrupted or already deleted.")) - return - if(selected_firemission == firemission_envelope.missions[ref]) - to_chat(usr, SPAN_WARNING("Can't delete selected Fire Mission.")) - return - var/result = firemission_envelope.delete_firemission(ref) - if(result != 1) - to_chat(usr, SPAN_WARNING("Unable to delete Fire Mission while in combat.")) - return + // dropship info + .["shuttle_state"] = dropship.mode + .["fire_mission_enabled"] = dropship.in_flyby - if(href_list["mission_tag"]) - var/ref = text2num(href_list["mission_tag"]) - var/mob/M = usr - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return - if(ref>firemission_envelope.missions.len) - to_chat(usr, SPAN_WARNING("Fire Mission ID corrupted or deleted.")) - return - if(firemission_envelope.stat > FIRE_MISSION_STATE_IN_TRANSIT && firemission_envelope.stat < FIRE_MISSION_STATE_COOLDOWN) - to_chat(usr, SPAN_WARNING("Fire Mission already underway.")) - return - if(selected_firemission == firemission_envelope.missions[ref]) - selected_firemission = null - else - selected_firemission = firemission_envelope.missions[ref] + // equipment info + .["equipment_data"] = get_sanitised_equipment(user, dropship) - if(href_list["mission_tag_edit"]) - var/ref = text2num(href_list["mission_tag_edit"]) - var/mob/M = usr - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return - if(ref>firemission_envelope.missions.len) - to_chat(usr, SPAN_WARNING("Fire Mission ID corrupted or deleted.")) - return - if(selected_firemission == firemission_envelope.missions[ref]) - to_chat(usr, SPAN_WARNING("Can't edit selected Fire Mission.")) - return - if(firemission_envelope.stat > FIRE_MISSION_STATE_IN_TRANSIT && firemission_envelope.stat < FIRE_MISSION_STATE_COOLDOWN) - to_chat(usr, SPAN_WARNING("Fire Mission already underway.")) - return - editing_firemission = firemission_envelope.missions[ref] + // medevac targets + .["medevac_targets"] = list() + for(var/obj/structure/dropship_equipment/equipment as anything in dropship.equipments) + if (istype(equipment, /obj/structure/dropship_equipment/medevac_system)) + var/obj/structure/dropship_equipment/medevac_system/medevac = equipment + .["medevac_targets"] += medevac.ui_data(user) + // fultons - if(href_list["leave_firemission_editing"]) - editing_firemission = null + .["fulton_targets"] = list() + for(var/obj/structure/dropship_equipment/equipment as anything in dropship.equipments) + if (istype(equipment, /obj/structure/dropship_equipment/fulton_system)) + var/obj/structure/dropship_equipment/fulton_system/fult = equipment + .["fulton_targets"] += fult.ui_data(user) - if(href_list["switch_to_firemission"]) - var/mob/M = usr - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return - in_firemission_mode = TRUE + .["targets_data"] = get_targets() + .["camera_target"] = camera_target_id - if(href_list["switch_to_simulation"]) - if(!selected_firemission) - to_chat(usr, SPAN_WARNING("Select a firemission before attempting to run the simulation")) - return + if(selected_equipment) + .["selected_eqp"] = selected_equipment.ship_base.attach_id + if(selected_equipment.ammo_equipped) + var/obj/structure/ship_ammo/ammo_equipped = selected_equipment.ammo_equipped + .["selected_eqp_ammo_name"] = sanitize(copytext(ammo_equipped.name, 1, MAX_MESSAGE_LEN)) + .["selected_eqp_ammo_amt"] = ammo_equipped.ammo_count + .["selected_eqp_max_ammo_amt"] = ammo_equipped.max_ammo_count + + // firemission info + .["has_firemission"] = !!firemission_envelope + .["can_firemission"] = !!selected_firemission && dropship.mode == SHUTTLE_CALL + if(editing_firemission) + .["editing_firemission"] = editing_firemission + .["editing_firemission_length"] = editing_firemission ? editing_firemission.mission_length : 0 + var/error_code = editing_firemission.check(src) + .["current_mission_error"] = error_code != FIRE_MISSION_ALL_GOOD ? editing_firemission.error_message(error_code) : null + .["firemission_edit_data"] = get_edit_firemission_data() - configuration = selected_firemission + if(firemission_envelope) + .["can_launch_firemission"] = !!selected_firemission && dropship.mode == SHUTTLE_CALL && firemission_envelope.stat != FIRE_MISSION_STATE_IDLE + .["firemission_data"] = get_firemission_data(user) + .["firemission_state"] = firemission_envelope.stat + .["firemission_offset"] = firemission_envelope.recorded_offset + .["firemission_message"] = firemission_envelope.firemission_status_message() + .["firemission_name"] = selected_firemission ? selected_firemission.name : "" + .["firemission_step"] = firemission_envelope.stat + .["firemission_selected_laser"] = firemission_envelope.recorded_loc ? firemission_envelope.recorded_loc.get_name() : "NOT SELECTED" + + .["configuration"] = configuration + .["looking"] = simulation.looking_at_simulation + .["dummy_mode"] = simulation.dummy_mode + .["worldtime"] = world.time + .["nextdetonationtime"] = simulation.detonation_cooldown + .["detonation_cooldown"] = simulation.detonation_cooldown_time - // simulation mode - tgui_interact(usr) +/obj/structure/machinery/computer/dropship_weapons/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) + return + var/obj/docking_port/mobile/marine_dropship/shuttle = SSshuttle.getShuttle(shuttle_tag) + if(shuttle.is_hijacked) + return - if(href_list["leave_firemission_execution"]) - var/mob/M = usr - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return - firemission_envelope.remove_user_from_tracking(usr) - in_firemission_mode = FALSE + var/mob/user = ui.user + switch(action) + if("button_push") + playsound(src, get_sfx("terminal_button"), 25, FALSE) + return TRUE - if(href_list["change_direction"]) - var/mob/M = usr - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return - var/list/directions = list(dir2text(NORTH), dir2text(SOUTH), dir2text(EAST), dir2text(WEST)) - var/chosen = tgui_input_list(usr, "Select new Direction for the strafing run", "Select Direction", directions) + if("select_equipment") + var/base_tag = params["equipment_id"] + ui_equip_interact(user, base_tag) + return TRUE - var/chosen_dir = text2dir(chosen) - if(!chosen_dir) - to_chat(usr, SPAN_WARNING("Error with direction detected.")) - return + if("start_watching") + simulation.start_watching(user) + . = TRUE - update_direction(chosen_dir) + if("stop_watching") + simulation.stop_watching(user) + . = TRUE - if(href_list["change_offset"]) - var/mob/M = usr - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return + if("execute_simulated_firemission") + if(!configuration) + to_chat(user, SPAN_WARNING("No configured firemission")) + return + simulate_firemission(user) + . = TRUE - var/chosen = stripped_input(usr, "Select Fire Mission length, from 0 to [firemission_envelope.max_offset]", "Select Offset", "[firemission_envelope.recorded_offset]", 2) - var/chosen_offset = text2num(chosen) + if("switch_firemission") + configuration = tgui_input_list(user, "Select firemission to simulate", "Select firemission", firemission_envelope.missions, 30 SECONDS) + if(!selected_firemission) + to_chat(user, SPAN_WARNING("No configured firemission")) + return + if(!configuration) + configuration = selected_firemission + . = TRUE - if(chosen_offset == null) - to_chat(usr, SPAN_WARNING("Error with offset detected.")) - return + if("switchmode") + simulation.dummy_mode = tgui_input_list(user, "Select target type to simulate", "Target type", simulation.target_types, 30 SECONDS) + if(!simulation.dummy_mode) + simulation.dummy_mode = CLF_MODE + . = TRUE - update_offset(chosen_offset) + if("set-camera") + var/target_camera = params["equipment_id"] + set_camera_target(target_camera) + return TRUE + + if("set-camera-sentry") + var/equipment_tag = params["equipment_id"] + for(var/obj/structure/dropship_equipment/equipment as anything in shuttle.equipments) + var/mount_point = equipment.ship_base.attach_id + if(mount_point != equipment_tag) + continue + if (istype(equipment, /obj/structure/dropship_equipment/sentry_holder)) + var/obj/structure/dropship_equipment/sentry_holder/sentry = equipment + var/obj/structure/machinery/defenses/sentry/defense = sentry.deployed_turret + if (defense.has_camera) + defense.set_range() + var/datum/shape/rectangle/current_bb = defense.range_bounds + SEND_SIGNAL(src, COMSIG_CAMERA_SET_AREA, current_bb.center_x, current_bb.center_y, defense.loc.z, current_bb.width, current_bb.height) + return TRUE + + if("clear-camera") + set_camera_target(null) + return TRUE + + if("medevac-target") + var/equipment_tag = params["equipment_id"] + for(var/obj/structure/dropship_equipment/equipment as anything in shuttle.equipments) + var/mount_point = equipment.ship_base.attach_id + if(mount_point != equipment_tag) + continue + if (istype(equipment, /obj/structure/dropship_equipment/medevac_system)) + var/obj/structure/dropship_equipment/medevac_system/medevac = equipment + var/target_ref = params["ref"] + medevac.automate_interact(user, target_ref) + if(medevac.linked_stretcher) + SEND_SIGNAL(src, COMSIG_CAMERA_SET_TARGET, medevac.linked_stretcher, 5, 5) + return TRUE + if("fulton-target") + var/equipment_tag = params["equipment_id"] + for(var/obj/structure/dropship_equipment/equipment as anything in shuttle.equipments) + var/mount_point = equipment.ship_base.attach_id + if(mount_point != equipment_tag) + continue + if (istype(equipment, /obj/structure/dropship_equipment/fulton_system)) + var/obj/structure/dropship_equipment/fulton_system/fulton = equipment + var/target_ref = params["ref"] + fulton.automate_interact(user, target_ref) + return TRUE + if("fire-weapon") + var/weapon_tag = params["eqp_tag"] + var/obj/structure/dropship_equipment/weapon/DEW = get_weapon(weapon_tag) + if(!DEW) + return FALSE + + var/datum/cas_signal/sig = get_cas_signal(camera_target_id) + + if(!sig) + return FALSE + + selected_equipment = DEW + ui_open_fire(user, shuttle, camera_target_id) + return TRUE + if("deploy-equipment") + var/equipment_tag = params["equipment_id"] + for(var/obj/structure/dropship_equipment/equipment as anything in shuttle.equipments) + var/mount_point = equipment.ship_base.attach_id + if(mount_point != equipment_tag) + continue + equipment.equipment_interact(user) + return TRUE + + if("firemission-create") + var/name = params["firemission_name"] + var/length = params["firemission_length"] + var/length_n = text2num(length) + if(!length_n) + to_chat(user, SPAN_WARNING("Incorrect input format.")) + return FALSE + ui_create_firemission(user, name, length_n) + return TRUE + + if("firemission-delete") + var/name = params["firemission_name"] + ui_delete_firemission(user, name) + return TRUE + + if("firemission-dual-offset-camera") + var/target_id = params["target_id"] + + var/x_offset_value = params["x_offset_value"] + var/y_offset_value = params["y_offset_value"] + + var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction] + var/datum/cas_signal/cas_sig + for(var/X in cas_group.cas_signals) + var/datum/cas_signal/LT = X + if(LT.target_id == target_id && LT.valid_signal()) + cas_sig = LT + break + // we don't want rapid offset changes to trigger admin warnings + // and block the user from accessing TGUI + // we change the minute_count + user.client.reduce_minute_count() + if(!cas_sig) + return TRUE + + // find position of cas_sig with offset dir and value applied + var/dx = text2num(x_offset_value) + var/dy = text2num(y_offset_value) + + var/obj/current = cas_sig.signal_loc + var/obj/new_target = locate( + current.x + dx, + current.y + dy, + current.z) + + firemission_envelope.change_current_loc(new_target) + + return TRUE + if("nvg-enable") + SEND_SIGNAL(src, COMSIG_CAMERA_SET_NVG, 5, "#7aff7a") + return TRUE + if("nvg-disable") + SEND_SIGNAL(src, COMSIG_CAMERA_CLEAR_NVG) + return TRUE + + if("firemission-edit") + var/fm_tag = text2num(params["tag"]) + var/weapon_id = text2num(params["weapon_id"]) + var/offset_id = text2num(params["offset_id"]) + var/offset_value = text2num(params["offset_value"]) + return ui_firemission_change_offset(user, fm_tag, weapon_id, offset_id + 1, offset_value) + + if("firemission-execute") + var/fm_tag = text2num(params["tag"]) + var/direction = params["direction"] + var/target_id = params["target_id"] + var/offset_x_value = params["offset_x_value"] + var/offset_y_value = params["offset_y_value"] + + if(!ui_select_firemission(user, fm_tag)) + playsound(src, 'sound/machines/terminal_error.ogg', 5, 1) + return FALSE + if(!update_direction(user, text2num(direction))) + playsound(src, 'sound/machines/terminal_error.ogg', 5, 1) + return FALSE + if(!ui_select_laser_firemission(user, shuttle, target_id)) + playsound(src, 'sound/machines/terminal_error.ogg', 5, 1) + return FALSE + + initiate_firemission(user, fm_tag, direction, text2num(offset_x_value), text2num(offset_y_value)) + return TRUE + +/obj/structure/machinery/computer/dropship_weapons/proc/get_weapon(eqp_tag) + var/obj/docking_port/mobile/marine_dropship/dropship = SSshuttle.getShuttle(shuttle_tag) + for(var/obj/structure/dropship_equipment/equipment in dropship.equipments) + if(istype(equipment, /obj/structure/dropship_equipment/weapon)) + //is weapon + if(selected_equipment == equipment) + return equipment + return + +/obj/structure/machinery/computer/dropship_weapons/proc/get_cas_signal(target_ref) + if(!target_ref) + return - if(href_list["select_laser_firemission"]) - var/mob/M = usr - var/targ_id = text2num(href_list["select_laser_firemission"]) - if(!targ_id) - to_chat(usr, SPAN_WARNING("Bad Target.")) - return - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return - if(firemission_envelope.stat > FIRE_MISSION_STATE_IN_TRANSIT && firemission_envelope.stat < FIRE_MISSION_STATE_COOLDOWN) - to_chat(usr, SPAN_WARNING("Fire Mission already underway.")) - return - if(dropship.mode != SHUTTLE_CALL) - to_chat(usr, SPAN_WARNING("Shuttle has to be in orbit.")) - return - var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction] - var/datum/cas_signal/cas_sig - for(var/X in cas_group.cas_signals) - var/datum/cas_signal/LT = X - if(LT.target_id == targ_id && LT.valid_signal()) - cas_sig = LT - if(!cas_sig) - to_chat(usr, SPAN_WARNING("Target lost or obstructed.")) - return + var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction] + for(var/datum/cas_signal/sig in cas_group.cas_signals) + if(sig.target_id == target_ref) + return sig - update_location(cas_sig) - if(href_list["execute_firemission"]) - var/mob/M = usr - if(ishuman(M)) - var/mob/living/carbon/human/H = M - if(!H.allow_gun_usage) - to_chat(H, SPAN_WARNING("Your programming prevents you from operating dropship weaponry!")) - return - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return - if(firemission_envelope.stat != FIRE_MISSION_STATE_IDLE) - to_chat(usr, SPAN_WARNING("Fire Mission already underway.")) - return - if(dropship.mode != SHUTTLE_CALL) - to_chat(usr, SPAN_WARNING("Shuttle has to be in orbit.")) - return - if(!firemission_envelope.recorded_loc) - to_chat(usr, SPAN_WARNING("Target is not selected or lost.")) - return +/obj/structure/machinery/computer/dropship_weapons/proc/set_camera_target(target_ref) + var/datum/cas_signal/target = get_cas_signal(target_ref) + camera_target_id = target_ref + if(!target) + SEND_SIGNAL(src, COMSIG_CAMERA_CLEAR) + return - initiate_firemission() + var/cam_width = camera_width + var/cam_height = camera_height + if(upgraded == MATRIX_WIDE) + cam_width = cam_width * 1.5 + cam_height = cam_height * 1.5 - if(href_list["fm_weapon_id"]) - var/weap_ref = text2num(href_list["fm_weapon_id"])+1 - var/offset_ref = text2num(href_list["fm_offset_id"])+1 - var/mob/M = usr - if(!skillcheck(M, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. - to_chat(usr, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) - return - if(!editing_firemission) - to_chat(usr, SPAN_WARNING("You are no longer editing Fire Mission.")) - return - if(!editing_firemission.records || editing_firemission.records.len FIRE_MISSION_STATE_IN_TRANSIT && firemission_envelope.stat < FIRE_MISSION_STATE_COOLDOWN) - to_chat(usr, SPAN_WARNING("Fire Mission already underway.")) - return - var/list/gimb = record.get_offsets() - var/min = gimb["min"] - var/max = gimb["max"] - var/offset_value = stripped_input(usr, "Enter offset for the [record.weapon.name]. It has to be between [min] and [max]. Enter '-' to remove fire order on this time stamp.", "Firing offset", "[record.offsets[offset_ref]]", 2) - if(offset_value == null) - return - if(offset_value == "-") - offset_value = "-" - else - offset_value = text2num(offset_value) - if(offset_value == null) - to_chat(usr, SPAN_WARNING("Incorrect offset value.")) - return - var/result = firemission_envelope.update_mission(firemission_envelope.missions.Find(editing_firemission), weap_ref, offset_ref, offset_value, TRUE) - if(result == 0) - to_chat(usr, SPAN_WARNING("Update caused an error: [firemission_envelope.mission_error]")) - if(result == -1) - to_chat(usr, SPAN_WARNING("System Error. Delete this Fire Mission.")) - - if(href_list["firemission_camera"]) - if(dropship.mode != SHUTTLE_CALL) - to_chat(usr, SPAN_WARNING("Shuttle has to be in orbit.")) - return + SEND_SIGNAL(src, COMSIG_CAMERA_SET_TARGET, target.linked_cam, cam_width, cam_height) - if(!firemission_envelope.guidance) - to_chat(usr, SPAN_WARNING("Guidance is not selected or lost.")) - return +/obj/structure/machinery/computer/dropship_weapons/proc/get_screen_mode() + . = 0 + if(selected_equipment) + . = selected_equipment.screen_mode + if(editing_firemission && editing_firemission.check(src) != FIRE_MISSION_CODE_ERROR) + . = 2 + if(selected_firemission && in_firemission_mode) + . = 3 +/obj/structure/machinery/computer/dropship_weapons/proc/get_firemission_data(mob/user) + . = list() + var/firemission_id = 1 + for(var/datum/cas_fire_mission/firemission in firemission_envelope.missions) + var/error_code = firemission.check(src) - firemission_envelope.add_user_to_tracking(usr) + var/selected = firemission == selected_firemission + var/can_edit = error_code != FIRE_MISSION_CODE_ERROR && !selected - to_chat(usr, "You peek through the guidance camera.") + var/can_interact = firemission_envelope.stat == FIRE_MISSION_STATE_IDLE && error_code == FIRE_MISSION_ALL_GOOD + var/list/fm_data = firemission.ui_data(user) + fm_data["mission_tag"] = firemission_id + fm_data["can_edit"] = can_edit + fm_data["can_interact"] = can_interact + fm_data["selected"] = selected + . += list(fm_data) - if(href_list["cas_camera"]) - if(!ishuman(usr)) - to_chat(usr, SPAN_WARNING("You have no idea how to do that!")) - return - if(dropship.mode != SHUTTLE_CALL) - to_chat(usr, SPAN_WARNING("Shuttle has to be in orbit.")) - return + firemission_id++ - if(!faction) - to_chat(usr, SPAN_DANGER("Bug encountered, this console doesn't have a faction set, report this to a coder!")) - return +/obj/structure/machinery/computer/dropship_weapons/proc/get_edit_firemission_data() + . = list() + if(!editing_firemission) + return + for(var/datum/cas_fire_mission_record/firerec as anything in editing_firemission.records) + var/gimbal = firerec.get_offsets() + var/ammo = firerec.get_ammo() + var/offsets = new /list(firerec.offsets.len) + for(var/idx = 1; idx < firerec.offsets.len; idx++) + offsets[idx] = firerec.offsets[idx] == null ? "-" : firerec.offsets[idx] + . += list( + "name" = sanitize(copytext(firerec.weapon.name, 1, 50)), + "ammo" = ammo, + "gimbal" = gimbal, + "offsets" = firerec.offsets + ) + +/obj/structure/machinery/computer/dropship_weapons/proc/get_sanitised_equipment(mob/user, obj/docking_port/mobile/marine_dropship/dropship) + . = list() + var/element_nbr = 1 + for(var/obj/structure/dropship_equipment/equipment in dropship.equipments) + var/list/data = list( + "name"= equipment.name, + "shorthand" = equipment.shorthand, + "eqp_tag" = element_nbr, + "is_weapon" = equipment.is_weapon, + "is_interactable" = equipment.is_interactable, + "mount_point" = equipment.ship_base.attach_id, + "is_missile" = istype(equipment, /obj/structure/dropship_equipment/weapon/rocket_pod), + "ammo_name" = equipment.ammo_equipped?.name, + "ammo" = equipment.ammo_equipped?.ammo_count, + "max_ammo" = equipment.ammo_equipped?.max_ammo_count, + "firemission_delay" = equipment.ammo_equipped?.fire_mission_delay, + "burst" = equipment.ammo_equipped?.ammo_used_per_firing, + "data" = equipment.ui_data(user) + ) + + . += list(data) - var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction] - if(!cas_group) - to_chat(usr, SPAN_DANGER("Bug encountered, no CAS group exists for this console, report this to a coder!")) - return + element_nbr++ + equipment.linked_console = src - var/targ_id = text2num(href_list["cas_camera"]) - var/datum/cas_signal/new_signal - for(var/datum/cas_signal/LT as anything in cas_group.cas_signals) - if(LT.target_id == targ_id && LT.valid_signal()) - new_signal = LT - break +/obj/structure/machinery/computer/dropship_weapons/proc/get_targets() + . = list() + var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction] + for(var/datum/cas_signal/LT as anything in cas_group.cas_signals) + if(!istype(LT) || !LT.valid_signal()) + continue + var/area/laser_area = get_area(LT.signal_loc) + . += list( + list( + "target_name" = "[LT.name] ([laser_area.name])", + "target_tag" = LT.target_id + ) + ) + +/obj/structure/machinery/computer/dropship_weapons/proc/ui_equip_interact(mob/user, base_tag) + var/obj/docking_port/mobile/marine_dropship/shuttle = SSshuttle.getShuttle(shuttle_tag) + var/obj/structure/dropship_equipment/E = shuttle.equipments[base_tag] + E.linked_console = src + E.equipment_interact(user) + +/obj/structure/machinery/computer/dropship_weapons/proc/ui_open_fire(mob/weapon_operator, obj/docking_port/mobile/marine_dropship/dropship, targ_id) + if(ishuman(weapon_operator)) + var/mob/living/carbon/human/human_operator = weapon_operator + if(!human_operator.allow_gun_usage) + to_chat(human_operator, SPAN_WARNING("Your programming prevents you from operating dropship weaponry!")) + return FALSE + var/obj/structure/dropship_equipment/weapon/DEW = selected_equipment + if(!selected_equipment || !selected_equipment.is_weapon) + to_chat(weapon_operator, SPAN_WARNING("No weapon selected.")) + return FALSE + if(!skillcheck(weapon_operator, SKILL_PILOT, DEW.skill_required)) //only pilots can fire dropship weapons. + to_chat(weapon_operator, SPAN_WARNING("You don't have the training to fire this weapon!")) + return FALSE + if(dropship.mode != SHUTTLE_CALL) + to_chat(weapon_operator, SPAN_WARNING("Dropship can only fire while in flight.")) + return FALSE + if(!faction) + return FALSE//no faction, no weapons + if(!selected_equipment || !selected_equipment.is_weapon) + to_chat(weapon_operator, SPAN_WARNING("No weapon selected.")) + return FALSE + if(dropship.door_override) + return FALSE + if(!skillcheck(weapon_operator, SKILL_PILOT, DEW.skill_required)) //only pilots can fire dropship weapons. + to_chat(weapon_operator, SPAN_WARNING("You don't have the training to fire this weapon!")) + return FALSE + if(!dropship.in_flyby && DEW.fire_mission_only) + to_chat(weapon_operator, SPAN_WARNING("[DEW] requires a fire mission flight type to be fired.")) + return FALSE + + if(!DEW.ammo_equipped || DEW.ammo_equipped.ammo_count <= 0) + to_chat(weapon_operator, SPAN_WARNING("[DEW] has no ammo.")) + return FALSE + if(DEW.last_fired > world.time - DEW.firing_delay) + to_chat(weapon_operator, SPAN_WARNING("[DEW] just fired, wait for it to cool down.")) + return FALSE - if(!new_signal) - to_chat(usr, SPAN_WARNING("Target lost or obstructed.")) - return + var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction] - if(usr in selected_cas_signal?.linked_cam?.viewing_users) // Reset previous cam - remove_from_view(usr) + if(!cas_group) + return FALSE//broken group. No fighting - selected_cas_signal = new_signal - if(selected_cas_signal && selected_cas_signal.linked_cam) - selected_cas_signal.linked_cam.view_directly(usr) - else - to_chat(usr, SPAN_WARNING("Error!")) - return - give_action(usr, /datum/action/human_action/cancel_view) - RegisterSignal(usr, COMSIG_MOB_RESET_VIEW, PROC_REF(remove_from_view)) - RegisterSignal(usr, COMSIG_MOB_RESISTED, PROC_REF(remove_from_view)) - firemission_envelope.apply_upgrade(usr) - to_chat(usr, SPAN_NOTICE("You peek through the guidance camera.")) - - ui_interact(usr) - -/obj/structure/machinery/computer/dropship_weapons/proc/remove_from_view(mob/living/carbon/human/user) - UnregisterSignal(user, COMSIG_MOB_RESET_VIEW) - UnregisterSignal(user, COMSIG_MOB_RESISTED) - if(selected_cas_signal && selected_cas_signal.linked_cam) - selected_cas_signal.linked_cam.remove_from_view(user) - firemission_envelope.remove_upgrades(user) - -/obj/structure/machinery/computer/dropship_weapons/proc/initiate_firemission() + for(var/datum/cas_signal/LT in cas_group.cas_signals) + if(LT.target_id != targ_id || !LT.valid_signal()) + continue + if(!LT.signal_loc) + return FALSE + var/turf/TU = get_turf(LT.signal_loc) + var/area/targ_area = get_area(LT.signal_loc) + var/is_outside = FALSE + if(is_ground_level(TU.z)) + switch(targ_area.ceiling) + if(CEILING_NONE) + is_outside = TRUE + if(CEILING_GLASS) + is_outside = TRUE + if(!is_outside && !cavebreaker) //cavebreaker doesn't care + to_chat(weapon_operator, SPAN_WARNING("INVALID TARGET: target must be visible from high altitude.")) + return FALSE + if (protected_by_pylon(TURF_PROTECTION_CAS, TU)) + to_chat(weapon_operator, SPAN_WARNING("INVALID TARGET: biological-pattern interference with signal.")) + return FALSE + if(!DEW.ammo_equipped.can_fire_at(TU, weapon_operator)) + return FALSE + + DEW.open_fire(LT.signal_loc) + return TRUE + return FALSE + +/obj/structure/machinery/computer/dropship_weapons/proc/ui_create_firemission(mob/weapon_operator, firemission_name, firemission_length) + if(!skillcheck(weapon_operator, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. + to_chat(weapon_operator, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) + return FALSE + // Check name + if(!firemission_name || length(firemission_name) < 1) + to_chat(weapon_operator, SPAN_WARNING("Name too short (at least 1 symbols).")) + return FALSE + // Check length + if(!firemission_length) + to_chat(weapon_operator, SPAN_WARNING("Incorrect input format.")) + return FALSE + if(firemission_length > firemission_envelope.fire_length) + to_chat(weapon_operator, SPAN_WARNING("Fire Mission is longer than allowed by this vehicle.")) + return FALSE + if(firemission_envelope.stat != FIRE_MISSION_STATE_IDLE) + to_chat(weapon_operator, SPAN_WARNING("Vehicle has to be idle to allow Fire Mission editing and creation.")) + return FALSE + + for(var/datum/cas_fire_mission/mission in firemission_envelope.missions) + if(firemission_name == mission.name) + to_chat(weapon_operator, SPAN_WARNING("Fire Mission name must be unique.")) + return FALSE + //everything seems to be fine now + firemission_envelope.generate_mission(firemission_name, firemission_length) + return TRUE + +/obj/structure/machinery/computer/dropship_weapons/proc/ui_delete_firemission(mob/weapon_operator, firemission_tag) + if(!skillcheck(weapon_operator, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. + to_chat(weapon_operator, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) + return FALSE + if(firemission_tag > firemission_envelope.missions.len) + to_chat(weapon_operator, SPAN_WARNING("Fire Mission ID corrupted or already deleted.")) + return FALSE + if(selected_firemission == firemission_envelope.missions[firemission_tag]) + to_chat(weapon_operator, SPAN_WARNING("Can't delete selected Fire Mission.")) + return FALSE + var/result = firemission_envelope.delete_firemission(firemission_tag) + if(result != 1) + to_chat(weapon_operator, SPAN_WARNING("Unable to delete Fire Mission while in combat.")) + return FALSE + return TRUE + +/obj/structure/machinery/computer/dropship_weapons/proc/ui_select_firemission(mob/weapon_operator, firemission_tag) + if(!skillcheck(weapon_operator, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. + to_chat(weapon_operator, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) + return FALSE + if(firemission_envelope.stat > FIRE_MISSION_STATE_IN_TRANSIT && firemission_envelope.stat < FIRE_MISSION_STATE_COOLDOWN) + to_chat(weapon_operator, SPAN_WARNING("Fire Mission already underway.")) + return FALSE + if(firemission_tag > firemission_envelope.missions.len) + to_chat(weapon_operator, SPAN_WARNING("Fire Mission ID corrupted or deleted.")) + return FALSE + if(selected_firemission == firemission_envelope.missions[firemission_tag]) + selected_firemission = null + else + selected_firemission = firemission_envelope.missions[firemission_tag] + return TRUE + +/obj/structure/machinery/computer/dropship_weapons/proc/ui_firemission_change_offset(mob/weapons_operator, fm_tag, weapon_id, offset_id, offset_value) + if(!skillcheck(weapons_operator, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. + to_chat(weapons_operator, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) + return FALSE + + var/result = firemission_envelope.update_mission(fm_tag, weapon_id, offset_id, offset_value) + if(result != FIRE_MISSION_ALL_GOOD) + playsound(src, 'sound/machines/terminal_error.ogg', 5, 1) + return TRUE + +/obj/structure/machinery/computer/dropship_weapons/proc/ui_select_laser_firemission(mob/weapons_operator, obj/docking_port/mobile/marine_dropship/dropship, laser) + if(!laser) + to_chat(weapons_operator, SPAN_WARNING("Bad Target.")) + return FALSE + if(!skillcheck(weapons_operator, SKILL_PILOT, SKILL_PILOT_TRAINED)) //only pilots can fire dropship weapons. + to_chat(weapons_operator, SPAN_WARNING("A screen with graphics and walls of physics and engineering values open, you immediately force it closed.")) + return FALSE + if(firemission_envelope.stat > FIRE_MISSION_STATE_IN_TRANSIT && firemission_envelope.stat < FIRE_MISSION_STATE_COOLDOWN) + to_chat(weapons_operator, SPAN_WARNING("Fire Mission already underway.")) + return FALSE + if(dropship.mode != SHUTTLE_CALL) + to_chat(weapons_operator, SPAN_WARNING("Shuttle has to be in orbit.")) + return FALSE + var/datum/cas_iff_group/cas_group = GLOB.cas_groups[faction] + var/datum/cas_signal/cas_sig + for(var/X in cas_group.cas_signals) + var/datum/cas_signal/LT = X + if(LT.target_id == laser && LT.valid_signal()) + cas_sig = LT + if(!cas_sig) + to_chat(weapons_operator, SPAN_WARNING("Target lost or obstructed.")) + return FALSE + + update_location(weapons_operator, cas_sig) + return TRUE + +/obj/structure/machinery/computer/dropship_weapons/proc/initiate_firemission(mob/user, fmId, dir, offset_x, offset_y) set waitfor = 0 var/obj/docking_port/mobile/marine_dropship/dropship = SSshuttle.getShuttle(shuttle_tag) if (!istype(dropship)) - return - if (dropship.timer && dropship.timeLeft(1) < firemission_envelope.get_total_duration()) - to_chat(usr, "Not enough time to complete the Fire Mission") - return + return FALSE if (!dropship.in_flyby || dropship.mode != SHUTTLE_CALL) - to_chat(usr, "Has to be in Fly By mode") - return - - var/fmid = firemission_envelope.missions.Find(selected_firemission) - if(!fmid) - to_chat(usr, "No Firemission selected") - return - - var/result = firemission_envelope.execute_firemission(firemission_envelope.recorded_loc, firemission_envelope.recorded_offset, firemission_envelope.recorded_dir, fmid) - if(result<1) - to_chat(usr, "Screen beeps with an error: "+ firemission_envelope.mission_error) - else - update_trace_loc() - -/obj/structure/machinery/computer/dropship_weapons/proc/update_offset(new_offset) - var/result = firemission_envelope.change_offset(new_offset) - if(result<1) - to_chat(usr, "Screen beeps with an error: "+ firemission_envelope.mission_error) - else - update_trace_loc() + to_chat(user, SPAN_WARNING("Has to be in Fly By mode")) + return FALSE + if (dropship.timer && dropship.timeLeft(1) < firemission_envelope.get_total_duration()) + to_chat(user, SPAN_WARNING("Not enough time to complete the Fire Mission")) + return FALSE + var/datum/cas_signal/recorded_loc = firemission_envelope.recorded_loc + var/obj/source = recorded_loc.signal_loc + var/turf/target = locate( + source.x + offset_x, + source.y + offset_y, + source.z + ) + var/result = firemission_envelope.execute_firemission(recorded_loc, target, dir, fmId) + if(result != FIRE_MISSION_ALL_GOOD) + to_chat(user, SPAN_WARNING("Screen beeps with an error: [firemission_envelope.mission_error]")) + return TRUE -/obj/structure/machinery/computer/dropship_weapons/proc/update_location(new_location) +/obj/structure/machinery/computer/dropship_weapons/proc/update_location(mob/user, new_location) var/result = firemission_envelope.change_target_loc(new_location) if(result<1) - to_chat(usr, "Screen beeps with an error: "+ firemission_envelope.mission_error) - else - update_trace_loc() + to_chat(user, SPAN_WARNING("Screen beeps with an error: [firemission_envelope.mission_error]")) + return FALSE + return TRUE -/obj/structure/machinery/computer/dropship_weapons/proc/update_direction(new_direction) +/obj/structure/machinery/computer/dropship_weapons/proc/update_direction(mob/user, new_direction) var/result = firemission_envelope.change_direction(new_direction) if(result<1) - to_chat(usr, "Screen beeps with an error: " + firemission_envelope.mission_error) - else - update_trace_loc() - -/obj/structure/machinery/computer/dropship_weapons/on_unset_interaction(mob/user) - ..() - if(firemission_envelope && firemission_envelope.guidance) - firemission_envelope.remove_user_from_tracking(user) + to_chat(user, SPAN_WARNING("Screen beeps with an error: [firemission_envelope.mission_error]")) + return FALSE + return TRUE -/obj/structure/machinery/computer/dropship_weapons/proc/update_trace_loc() +/obj/structure/machinery/computer/dropship_weapons/proc/update_trace_loc(mob/user) if(!firemission_envelope) return if(firemission_envelope.recorded_loc == null || firemission_envelope.recorded_dir == null || firemission_envelope.recorded_offset == null) return if(firemission_envelope.recorded_loc.obstructed_signal()) - if(firemission_envelope.user_is_guided(usr)) - to_chat(usr, SPAN_WARNING("Signal Obstructed. You have to go in blind.")) + if(firemission_envelope.user_is_guided(user)) + to_chat(user, SPAN_WARNING("Signal Obstructed. You have to go in blind.")) return var/sx = 0 var/sy = 0 @@ -711,108 +805,29 @@ return var/area/laser_area = get_area(shootloc) if(!istype(laser_area) || CEILING_IS_PROTECTED(laser_area.ceiling, CEILING_PROTECTION_TIER_1)) - if(firemission_envelope.user_is_guided(usr)) - to_chat(usr, SPAN_WARNING("Vision Obstructed. You have to go in blind.")) + if(firemission_envelope.user_is_guided(user)) + to_chat(user, SPAN_WARNING("Vision Obstructed. You have to go in blind.")) firemission_envelope.change_current_loc() else firemission_envelope.change_current_loc(shootloc) + return TRUE /obj/structure/machinery/computer/dropship_weapons/dropship1 name = "\improper 'Alamo' weapons controls" req_one_access = list(ACCESS_MARINE_LEADER, ACCESS_MARINE_DROPSHIP, ACCESS_WY_FLIGHT) firemission_envelope = new /datum/cas_fire_envelope/uscm_dropship() - -/obj/structure/machinery/computer/dropship_weapons/dropship1/New() - ..() shuttle_tag = DROPSHIP_ALAMO /obj/structure/machinery/computer/dropship_weapons/dropship2 name = "\improper 'Normandy' weapons controls" req_one_access = list(ACCESS_MARINE_LEADER, ACCESS_MARINE_DROPSHIP, ACCESS_WY_FLIGHT) firemission_envelope = new /datum/cas_fire_envelope/uscm_dropship() - -/obj/structure/machinery/computer/dropship_weapons/dropship2/New() - ..() shuttle_tag = DROPSHIP_NORMANDY /obj/structure/machinery/computer/dropship_weapons/Destroy() . = ..() - QDEL_NULL(firemission_envelope) - -// CAS TGUI SHIT \\ - -/obj/structure/machinery/computer/dropship_weapons/tgui_interact(mob/user, datum/tgui/ui) - ui = SStgui.try_update_ui(user, src, ui) - if(!ui) - ui = new(user, src, "CasSim", "[src.name]") - ui.open() - -/obj/structure/machinery/computer/dropship_weapons/ui_state(mob/user) // we gotta do custom shit here so that it always closes instead of suspending - return GLOB.not_incapacitated_and_adjacent_strict_state - -/obj/structure/machinery/computer/dropship_weapons/ui_status(mob/user, datum/ui_state/state) - . = ..() - if(inoperable()) - return UI_CLOSE - -/obj/structure/machinery/computer/dropship_weapons/ui_data(mob/user) - var/list/data = list() - - data["configuration"] = configuration - data["looking"] = simulation.looking_at_simulation - data["dummy_mode"] = simulation.dummy_mode - - data["worldtime"] = world.time - data["nextdetonationtime"] = simulation.detonation_cooldown - data["detonation_cooldown"] = simulation.detonation_cooldown_time - - return data - -/obj/structure/machinery/computer/dropship_weapons/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) - . = ..() - if(.) - return - - var/user = ui.user - - switch(action) - if("start_watching") - simulation.start_watching(user) - . = TRUE - - if("stop_watching") - simulation.stop_watching(user) - . = TRUE - - if("execute_simulated_firemission") - if(!configuration) - to_chat(user, SPAN_WARNING("No configured firemission")) - return - simulate_firemission(user) - . = TRUE - - if("switch_firemission") - configuration = tgui_input_list(user, "Select firemission to simulate", "Select firemission", firemission_envelope.missions, 30 SECONDS) - if(!selected_firemission) - to_chat(user, SPAN_WARNING("No configured firemission")) - return - if(!configuration) - configuration = selected_firemission - . = TRUE - - if("switchmode") - simulation.dummy_mode = tgui_input_list(user, "Select target type to simulate", "Target type", simulation.target_types, 30 SECONDS) - if(!simulation.dummy_mode) - simulation.dummy_mode = CLF_MODE - . = TRUE - -/obj/structure/machinery/computer/dropship_weapons/ui_close(mob/user) - . = ..() - if(simulation.looking_at_simulation) - simulation.stop_watching(user) - -// CAS TGUI SHIT END \\ + QDEL_NULL(tacmap) /obj/structure/machinery/computer/dropship_weapons/proc/simulate_firemission(mob/living/user) diff --git a/code/game/objects/structures/stool_bed_chair_nest/bed.dm b/code/game/objects/structures/stool_bed_chair_nest/bed.dm index 34b0fb01e9d6..ee2c2bcee882 100644 --- a/code/game/objects/structures/stool_bed_chair_nest/bed.dm +++ b/code/game/objects/structures/stool_bed_chair_nest/bed.dm @@ -322,6 +322,7 @@ GLOBAL_LIST_EMPTY(activated_medevac_stretchers) base_bed_icon = "stretcher" accepts_bodybag = TRUE var/stretcher_activated + var/view_range = 5 var/obj/structure/dropship_equipment/medevac_system/linked_medevac surgery_duration_multiplier = SURGERY_SURFACE_MULT_AWFUL //On the one hand, it's a big stretcher. On the other hand, you have a big sheet covering the patient and those damned Fulton hookups everywhere. @@ -352,6 +353,14 @@ GLOBAL_LIST_EMPTY(activated_medevac_stretchers) toggle_medevac_beacon(usr) +// Used to pretend to be a camera +/obj/structure/bed/medevac_stretcher/proc/can_use() + return TRUE + +// Used to pretend to be a camera +/obj/structure/bed/medevac_stretcher/proc/isXRay() + return FALSE + /obj/structure/bed/medevac_stretcher/proc/toggle_medevac_beacon(mob/user) if(!ishuman(user)) return diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 171cade3ed4e..6d5efba2645f 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -15,7 +15,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( "1548" = "bug breaking the \"alpha\" functionality in the game, allowing clients to be able to see things/mobs they should not be able to see.", )) -#define LIMITER_SIZE 5 +#define LIMITER_SIZE 12 #define CURRENT_SECOND 1 #define SECOND_COUNT 2 #define CURRENT_MINUTE 3 @@ -57,6 +57,12 @@ GLOBAL_LIST_INIT(whitelisted_client_procs, list( /client/proc/set_eye_blur_type, )) +/client/proc/reduce_minute_count() + if (!topiclimiter) + topiclimiter = new(LIMITER_SIZE) + if(topiclimiter[MINUTE_COUNT] > 0) + topiclimiter[MINUTE_COUNT] -= 1 + /client/Topic(href, href_list, hsrc) if(!usr || usr != mob) //stops us calling Topic for somebody else's client. Also helps prevent usr=null return diff --git a/code/modules/cm_marines/dropship_equipment.dm b/code/modules/cm_marines/dropship_equipment.dm index 510b9305a2a6..036b6ecf8330 100644 --- a/code/modules/cm_marines/dropship_equipment.dm +++ b/code/modules/cm_marines/dropship_equipment.dm @@ -6,6 +6,8 @@ icon = 'icons/obj/structures/props/almayer_props.dmi' climbable = TRUE layer = ABOVE_OBJ_LAYER //so they always appear above attach points when installed + var/shorthand + var/list/equip_categories //on what kind of base this can be installed. var/obj/effect/attach_point/ship_base //the ship base the equipment is currently installed on. var/uses_ammo = FALSE //whether it uses ammo @@ -22,7 +24,7 @@ /obj/structure/dropship_equipment/Destroy() QDEL_NULL(ammo_equipped) if(linked_shuttle) - linked_shuttle.equipments -= src + SEND_SIGNAL(linked_shuttle, COMSIG_DROPSHIP_REMOVE_EQUIPMENT, src) linked_shuttle = null if(ship_base) ship_base.installed_equipment = null @@ -122,7 +124,7 @@ ship_base.installed_equipment = null ship_base = null if(linked_shuttle) - linked_shuttle.equipments -= src + SEND_SIGNAL(linked_shuttle, COMSIG_DROPSHIP_REMOVE_EQUIPMENT, src) linked_shuttle = null if(linked_console && linked_console.selected_equipment == src) linked_console.selected_equipment = null @@ -160,6 +162,7 @@ icon_state = "sentry_system" is_interactable = TRUE point_cost = 500 + shorthand = "Sentry" var/deployment_cooldown var/obj/structure/machinery/defenses/sentry/premade/dropship/deployed_turret combat_equipment = FALSE @@ -176,6 +179,28 @@ if(!deployed_turret) . += "Its turret is missing." +/obj/structure/dropship_equipment/sentry_holder/ui_data(mob/user) + var/obj/structure/machinery/defenses/defense = deployed_turret + . = list() + var/is_deployed = deployed_turret.loc != src + .["name"] = defense.name + .["area"] = get_area(defense) + .["active"] = defense.turned_on + .["nickname"] = defense.nickname + .["camera_available"] = defense.has_camera && is_deployed + .["selection_state"] = list() + .["kills"] = defense.kills + .["iff_status"] = defense.faction_group + .["health"] = defense.health + .["health_max"] = defense.health_max + .["deployed"] = is_deployed + + if(istype(defense, /obj/structure/machinery/defenses/sentry)) + var/obj/structure/machinery/defenses/sentry/sentrygun = defense + .["rounds"] = sentrygun.ammo.current_rounds + .["max_rounds"] = sentrygun.ammo.max_rounds + .["engaged"] = length(sentrygun.targets) + /obj/structure/dropship_equipment/sentry_holder/on_launch() if(ship_base && ship_base.base_category == DROPSHIP_WEAPON) //only external sentires are automatically undeployed undeploy_sentry() @@ -290,6 +315,7 @@ equip_categories = list(DROPSHIP_WEAPON, DROPSHIP_CREW_WEAPON) icon_state = "mg_system" point_cost = 50 + shorthand = "MG" var/deployment_cooldown var/obj/structure/machinery/m56d_hmg/mg_turret/dropship/deployed_mg combat_equipment = FALSE @@ -304,6 +330,17 @@ QDEL_NULL(deployed_mg) . = ..() +/obj/structure/dropship_equipment/mg_holder/ui_data(mob/user) + . = list() + var/is_deployed = deployed_mg.loc == src + .["name"] = name + .["selection_state"] = list() + .["health"] = health + .["health_max"] = 100 + .["rounds"] = deployed_mg.rounds + .["max_rounds"] = deployed_mg.rounds_max + .["deployed"] = is_deployed + /obj/structure/dropship_equipment/mg_holder/get_examine_text(mob/user) . = ..() if(!deployed_mg) @@ -334,6 +371,9 @@ ..() +/obj/structure/dropship_equipment/mg_holder/equipment_interact(mob/user) + attack_hand(user) + /obj/structure/dropship_equipment/mg_holder/update_equipment() if(ship_base) setDir(ship_base.dir) @@ -450,6 +490,7 @@ /obj/structure/dropship_equipment/electronics/spotlights name = "\improper AN/LEN-15 Spotlight" + shorthand = "Spotlight" icon_state = "spotlights" desc = "A set of high-powered spotlights to illuminate large areas. Fits on electronics attach points of dropships. Moving this will require a powerloader." is_interactable = TRUE @@ -500,6 +541,7 @@ /obj/structure/dropship_equipment/electronics/targeting_system name = "\improper AN/AAQ-178 Weapon Targeting System" + shorthand = "Targeting" icon_state = "targeting_system" desc = "A targeting system for dropships. It improves firing accuracy on laser targets. Fits on electronics attach points. You need a powerloader to lift this." point_cost = 800 @@ -512,7 +554,8 @@ /obj/structure/dropship_equipment/electronics/landing_zone_detector name = "\improper AN/AVD-60 LZ detector" - desc = "An electronic device linked to the dropship's camera system that lets you observe your landing zone." + shorthand = "LZ Detector" + desc = "An electronic device linked to the dropship's camera system that lets you observe your landing zone mid-flight." icon_state = "lz_detector" point_cost = 50 var/obj/structure/machinery/computer/cameras/dropship/linked_cam_console @@ -694,6 +737,7 @@ point_cost = 400 skill_required = SKILL_PILOT_TRAINED fire_mission_only = FALSE + shorthand = "GAU" /obj/structure/dropship_equipment/weapon/heavygun/update_icon() if(ammo_equipped) @@ -710,6 +754,7 @@ firing_sound = 'sound/effects/rocketpod_fire.ogg' firing_delay = 5 point_cost = 600 + shorthand = "MSL" /obj/structure/dropship_equipment/weapon/rocket_pod/deplete_ammo() ammo_equipped = null //nothing left to empty after firing @@ -731,6 +776,7 @@ firing_sound = 'sound/effects/rocketpod_fire.ogg' firing_delay = 10 //1 seconds point_cost = 600 + shorthand = "RKT" /obj/structure/dropship_equipment/weapon/minirocket_pod/update_icon() if(ammo_equipped && ammo_equipped.ammo_count) @@ -754,6 +800,7 @@ point_cost = 500 skill_required = SKILL_PILOT_TRAINED fire_mission_only = FALSE + shorthand = "LZR" /obj/structure/dropship_equipment/weapon/laser_beam_gun/update_icon() if(ammo_equipped && ammo_equipped.ammo_count) @@ -772,6 +819,7 @@ bound_height = 32 equip_categories = list(DROPSHIP_CREW_WEAPON) //fits inside the central spot of the dropship point_cost = 400 + shorthand = "LCH" /obj/structure/dropship_equipment/weapon/launch_bay/update_equipment() if(ship_base) @@ -785,6 +833,7 @@ /obj/structure/dropship_equipment/medevac_system name = "\improper RMU-4M Medevac System" + shorthand = "Medevac" desc = "A winch system to lift injured marines on medical stretchers onto the dropship. Acquire lift target through the dropship equipment console." equip_categories = list(DROPSHIP_CREW_WEAPON) icon_state = "medevac_system" @@ -810,24 +859,8 @@ linked_stretcher = null icon_state = "medevac_system" - -/obj/structure/dropship_equipment/medevac_system/equipment_interact(mob/user) - if(!linked_shuttle) - return - - if(linked_shuttle.mode != SHUTTLE_CALL) - to_chat(user, SPAN_WARNING("[src] can only be used while in flight.")) - return - - if(busy_winch) - to_chat(user, SPAN_WARNING(" The winch is already in motion.")) - return - - if(world.time < medevac_cooldown) - to_chat(user, SPAN_WARNING("[src] was just used, you need to wait a bit before using it again.")) - return - - var/list/possible_stretchers = list() +/obj/structure/dropship_equipment/medevac_system/proc/get_targets() + . = list() for(var/obj/structure/bed/medevac_stretcher/MS in GLOB.activated_medevac_stretchers) var/area/AR = get_area(MS) var/evaccee_name @@ -854,20 +887,32 @@ if (evaccee_triagecard_color && evaccee_triagecard_color == "none") evaccee_triagecard_color = null - possible_stretchers["[evaccee_name] [evaccee_triagecard_color ? "\[" + uppertext(evaccee_triagecard_color) + "\]" : ""] ([AR.name])"] = MS + .["[evaccee_name] [evaccee_triagecard_color ? "\[" + uppertext(evaccee_triagecard_color) + "\]" : ""] ([AR.name])"] = MS - if(!possible_stretchers.len) - to_chat(user, SPAN_WARNING("No active medevac stretcher detected.")) - return +/obj/structure/dropship_equipment/medevac_system/proc/can_medevac(mob/user) + if(!linked_shuttle) + return FALSE - var/stretcher_choice = tgui_input_list(usr, "Which emitting stretcher would you like to link with?", "Available stretchers", possible_stretchers) - if(!stretcher_choice) - return + if(linked_shuttle.mode != SHUTTLE_CALL) + to_chat(user, SPAN_WARNING("[src] can only be used while in flight.")) + return FALSE - var/obj/structure/bed/medevac_stretcher/selected_stretcher = possible_stretchers[stretcher_choice] - if(!selected_stretcher) - return + if(busy_winch) + to_chat(user, SPAN_WARNING(" The winch is already in motion.")) + return FALSE + if(world.time < medevac_cooldown) + to_chat(user, SPAN_WARNING("[src] was just used, you need to wait a bit before using it again.")) + return FALSE + + var/list/possible_stretchers = get_targets() + + if(!possible_stretchers.len) + to_chat(user, SPAN_WARNING("No active medevac stretcher detected.")) + return FALSE + return TRUE + +/obj/structure/dropship_equipment/medevac_system/proc/position_dropship(mob/user, obj/structure/bed/medevac_stretcher/selected_stretcher) if(!ship_base) //system was uninstalled midway return @@ -917,6 +962,31 @@ linked_stretcher.linked_medevac = src linked_stretcher.visible_message(SPAN_NOTICE("[linked_stretcher] detects a dropship overhead.")) +/obj/structure/dropship_equipment/medevac_system/proc/automate_interact(mob/user, stretcher_choice) + if(!can_medevac(user)) + return + + var/list/possible_stretchers = get_targets() + + var/obj/structure/bed/medevac_stretcher/selected_stretcher = possible_stretchers[stretcher_choice] + if(!selected_stretcher) + return + position_dropship(user, selected_stretcher) + +/obj/structure/dropship_equipment/medevac_system/equipment_interact(mob/user) + if(!can_medevac(user)) + return + + var/list/possible_stretchers = get_targets() + + var/stretcher_choice = tgui_input_list(usr, "Which emitting stretcher would you like to link with?", "Available stretchers", possible_stretchers) + if(!stretcher_choice) + return + + var/obj/structure/bed/medevac_stretcher/selected_stretcher = possible_stretchers[stretcher_choice] + if(!selected_stretcher) + return + position_dropship(user, selected_stretcher) //on arrival we break any link @@ -962,6 +1032,35 @@ activate_winch(user) +/obj/structure/dropship_equipment/medevac_system/ui_data(mob/user) + var/list/stretchers = get_targets() + + . = list() + for(var/stretcher_ref in stretchers) + var/obj/structure/bed/medevac_stretcher/stretcher = stretchers[stretcher_ref] + + var/area/AR = get_area(stretcher) + var/list/target_data = list() + target_data["area"] = AR + target_data["ref"] = stretcher_ref + + var/mob/living/carbon/human/occupant = stretcher.buckled_mob + if(occupant) + target_data["occupant"] = occupant.name + target_data["time_of_death"] = occupant.tod + target_data["damage"] = list( + "hp" = occupant.health, + "brute" = occupant.bruteloss, + "oxy" = occupant.oxyloss, + "tox" = occupant.toxloss, + "fire" = occupant.fireloss + ) + if(ishuman(occupant)) + target_data["damage"]["undefib"] = occupant.undefibbable + target_data["triage_card"] = occupant.holo_card_color + + . += list(target_data) + /obj/structure/dropship_equipment/medevac_system/proc/activate_winch(mob/user) set waitfor = 0 var/old_stretcher = linked_stretcher @@ -1017,6 +1116,7 @@ /obj/structure/dropship_equipment/fulton_system name = "\improper RMU-19 Fulton Recovery System" + shorthand = "Fulton" desc = "A winch system to collect any fulton recovery balloons in high altitude. Make sure you turn it on!" equip_categories = list(DROPSHIP_CREW_WEAPON) icon_state = "fulton_system" @@ -1033,7 +1133,26 @@ icon_state = "fulton_system" -/obj/structure/dropship_equipment/fulton_system/equipment_interact(mob/user) +/obj/structure/dropship_equipment/fulton_system/proc/automate_interact(mob/user, fulton_choice) + if(!can_fulton(user)) + return + + var/list/possible_fultons = get_targets() + + var/obj/item/stack/fulton/fult = possible_fultons[fulton_choice] + if(!fulton_choice) + return + + if(!ship_base) //system was uninstalled midway + return + + if(is_ground_level(fult.z)) //in case the fulton popped during our input() + return + + if(!fult.attached_atom) + to_chat(user, SPAN_WARNING("This balloon stretcher is empty.")) + return + if(!linked_shuttle) return @@ -1049,14 +1168,50 @@ to_chat(user, SPAN_WARNING("[src] was just used, you need to wait a bit before using it again.")) return - var/list/possible_fultons = list() + to_chat(user, SPAN_NOTICE(" You move your dropship above the selected balloon's beacon.")) + + activate_winch(user, fult) + + +/obj/structure/dropship_equipment/fulton_system/proc/can_fulton(mob/user) + if(!linked_shuttle) + return FALSE + + if(linked_shuttle.mode != SHUTTLE_CALL) + to_chat(user, SPAN_WARNING("[src] can only be used while in flight.")) + return FALSE + + if(busy_winch) + to_chat(user, SPAN_WARNING(" The winch is already in motion.")) + return FALSE + + if(world.time < fulton_cooldown) + to_chat(user, SPAN_WARNING("[src] was just used, you need to wait a bit before using it again.")) + return FALSE + return TRUE + +/obj/structure/dropship_equipment/fulton_system/ui_data(mob/user) + var/list/targets = get_targets() + . = list() + for(var/i in targets) + . += list(i) + + +/obj/structure/dropship_equipment/fulton_system/proc/get_targets() + . = list() for(var/obj/item/stack/fulton/F in GLOB.deployed_fultons) var/recovery_object if(F.attached_atom) recovery_object = F.attached_atom.name else recovery_object = "Empty" - possible_fultons["[recovery_object]"] = F + .["[recovery_object]"] = F + +/obj/structure/dropship_equipment/fulton_system/equipment_interact(mob/user) + if(!can_fulton(user)) + return + + var/list/possible_fultons = get_targets() if(!possible_fultons.len) to_chat(user, SPAN_WARNING("No active balloons detected.")) @@ -1134,6 +1289,7 @@ // Rappel deployment system /obj/structure/dropship_equipment/rappel_system name = "\improper HPU-1 Rappel Deployment System" + shorthand = "Rappel" equip_categories = list(DROPSHIP_CREW_WEAPON) icon_state = "rappel_module_packaged" point_cost = 50 diff --git a/code/modules/dropships/attach_points/attach_point.dm b/code/modules/dropships/attach_points/attach_point.dm index 6724f5d18bd2..cee26f0b13f2 100644 --- a/code/modules/dropships/attach_points/attach_point.dm +++ b/code/modules/dropships/attach_points/attach_point.dm @@ -60,7 +60,7 @@ for(var/obj/docking_port/mobile/marine_dropship/shuttle in SSshuttle.mobile) if(shuttle.id == ship_tag) SE.linked_shuttle = shuttle - shuttle.equipments += SE + SEND_SIGNAL(shuttle, COMSIG_DROPSHIP_ADD_EQUIPMENT, SE) break SE.update_equipment() diff --git a/code/modules/dropships/cas/fire_mission_record.dm b/code/modules/dropships/cas/fire_mission_record.dm index 093a1509b2ad..2887ec92c24a 100644 --- a/code/modules/dropships/cas/fire_mission_record.dm +++ b/code/modules/dropships/cas/fire_mission_record.dm @@ -5,6 +5,11 @@ /// List of transverse offsets for each firing step - null meaning not shooting var/list/offsets +/datum/cas_fire_mission_record/ui_data(mob/user) + . = list() + .["weapon"] = weapon.ship_base.attach_id + .["offsets"] = offsets + /// Get offset range allowed when firing weapon in this configuration /datum/cas_fire_mission_record/proc/get_offsets() if(!weapon?.ship_base) diff --git a/code/modules/shuttle/computers/dropship_computer.dm b/code/modules/shuttle/computers/dropship_computer.dm index b7a74d1780df..86c0c86abfc2 100644 --- a/code/modules/shuttle/computers/dropship_computer.dm +++ b/code/modules/shuttle/computers/dropship_computer.dm @@ -419,7 +419,7 @@ update_equipment(is_optimised, FALSE) var/list/local_data = ui_data(user) var/found = FALSE - playsound(loc, get_sfx("terminal_button"), KEYBOARD_SOUND_VOLUME, 1) + playsound(loc, get_sfx("terminal_button"), 5, 1) for(var/destination in local_data["destinations"]) if(destination["id"] == dock_id) found = TRUE diff --git a/code/modules/shuttle/shuttles/dropship.dm b/code/modules/shuttle/shuttles/dropship.dm index 105c0e122234..f741df301bbb 100644 --- a/code/modules/shuttle/shuttles/dropship.dm +++ b/code/modules/shuttle/shuttles/dropship.dm @@ -30,6 +30,7 @@ var/automated_delay var/automated_timer + /obj/docking_port/mobile/marine_dropship/Initialize(mapload) . = ..() door_control = new() @@ -43,15 +44,28 @@ if("aft_door") door_control.add_door(air, "aft") + RegisterSignal(src, COMSIG_DROPSHIP_ADD_EQUIPMENT, PROC_REF(add_equipment)) + RegisterSignal(src, COMSIG_DROPSHIP_REMOVE_EQUIPMENT, PROC_REF(remove_equipment)) + /obj/docking_port/mobile/marine_dropship/Destroy(force) . = ..() qdel(door_control) + UnregisterSignal(src, COMSIG_DROPSHIP_ADD_EQUIPMENT) + UnregisterSignal(src, COMSIG_DROPSHIP_REMOVE_EQUIPMENT) /obj/docking_port/mobile/marine_dropship/proc/send_for_flyby() in_flyby = TRUE var/obj/docking_port/stationary/dockedAt = get_docked() SSshuttle.moveShuttle(src.id, dockedAt.id, TRUE) +/obj/docking_port/mobile/marine_dropship/proc/add_equipment(obj/docking_port/mobile/marine_dropship/dropship, obj/structure/dropship_equipment/equipment) + SIGNAL_HANDLER + equipments += equipment + +/obj/docking_port/mobile/marine_dropship/proc/remove_equipment(obj/docking_port/mobile/marine_dropship/dropship, obj/structure/dropship_equipment/equipment) + SIGNAL_HANDLER + equipments -= equipment + /obj/docking_port/mobile/marine_dropship/proc/get_door_data() return door_control.get_data() @@ -107,10 +121,12 @@ /obj/docking_port/mobile/marine_dropship/alamo name = "Alamo" id = DROPSHIP_ALAMO + preferred_direction = SOUTH /obj/docking_port/mobile/marine_dropship/normandy name = "Normandy" id = DROPSHIP_NORMANDY + preferred_direction = SOUTH /obj/docking_port/mobile/marine_dropship/check() . = ..() diff --git a/colonialmarines.dme b/colonialmarines.dme index 64f1338244b4..ca8e80ef5067 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -723,6 +723,7 @@ #include "code\game\area\techtree.dm" #include "code\game\area\varadero.dm" #include "code\game\area\WhiskeyOutpost.dm" +#include "code\game\camera_manager\camera_manager.dm" #include "code\game\cas_manager\datums\cas_fire_envelope.dm" #include "code\game\cas_manager\datums\cas_fire_mission.dm" #include "code\game\cas_manager\datums\cas_iff_group.dm" diff --git a/maps/shuttles/dropship_alamo.dmm b/maps/shuttles/dropship_alamo.dmm index 6cd6922c22b0..1e78347c1721 100644 --- a/maps/shuttles/dropship_alamo.dmm +++ b/maps/shuttles/dropship_alamo.dmm @@ -18,6 +18,14 @@ /obj/structure/shuttle/part/dropship1/transparent/nose_center, /turf/template_noop, /area/shuttle/drop1/sulaco) +"bc" = ( +/obj/effect/attach_point/electronics/dropship1{ + dir = 1; + attach_id = 5 + }, +/obj/structure/shuttle/part/dropship1/transparent/inner_left_weapons, +/turf/template_noop, +/area/shuttle/drop1/sulaco) "be" = ( /obj/structure/shuttle/part/dropship1/transparent/upper_right_wing, /turf/template_noop, @@ -73,6 +81,15 @@ icon_state = "floor8" }, /area/shuttle/drop1/sulaco) +"ed" = ( +/obj/structure/machinery/door/airlock/multi_tile/almayer/dropshiprear/dropshipside/ds1{ + dir = 1; + id = "starboard_door" + }, +/turf/open/shuttle/dropship{ + icon_state = "rasputin15" + }, +/area/shuttle/drop1/sulaco) "eD" = ( /obj/structure/shuttle/part/dropship1/transparent/engine_right_cap, /turf/template_noop, @@ -159,14 +176,6 @@ icon_state = "76" }, /area/shuttle/drop1/sulaco) -"os" = ( -/obj/effect/attach_point/fuel/dropship1{ - pixel_x = -32 - }, -/turf/closed/shuttle/dropship1/transparent{ - icon_state = "33" - }, -/area/shuttle/drop1/sulaco) "oW" = ( /obj/structure/shuttle/part/dropship1/transparent/middle_left_wing, /turf/template_noop, @@ -216,19 +225,18 @@ icon_state = "23" }, /area/shuttle/drop1/sulaco) -"rS" = ( -/obj/structure/machinery/door/airlock/multi_tile/almayer/dropshiprear/dropshipside/ds1{ - id = "port_door"; - dir = 2 - }, -/turf/open/shuttle/dropship{ - icon_state = "rasputin15" - }, -/area/shuttle/drop1/sulaco) "rV" = ( /obj/structure/shuttle/part/dropship1/transparent/left_outer_bottom_wing, /turf/template_noop, /area/shuttle/drop1/sulaco) +"sm" = ( +/obj/effect/attach_point/fuel/dropship1{ + attach_id = 10 + }, +/turf/closed/shuttle/dropship1/transparent{ + icon_state = "28" + }, +/area/shuttle/drop1/sulaco) "sA" = ( /obj/structure/shuttle/part/dropship1/lower_left_wall, /turf/open/space/basic, @@ -248,12 +256,6 @@ /obj/structure/shuttle/part/dropship1/transparent/lower_right_wing, /turf/template_noop, /area/shuttle/drop1/sulaco) -"wr" = ( -/obj/effect/attach_point/crew_weapon/dropship1, -/turf/open/shuttle/dropship{ - icon_state = "rasputin15" - }, -/area/shuttle/drop1/sulaco) "ws" = ( /obj/structure/bed/chair/vehicle{ dir = 1; @@ -344,20 +346,6 @@ icon_state = "rasputin15" }, /area/shuttle/drop1/sulaco) -"Da" = ( -/obj/effect/attach_point/electronics/dropship1{ - dir = 1 - }, -/obj/structure/shuttle/part/dropship1/transparent/inner_left_weapons, -/turf/template_noop, -/area/shuttle/drop1/sulaco) -"De" = ( -/obj/effect/attach_point/electronics/dropship1{ - dir = 1 - }, -/obj/structure/shuttle/part/dropship1/transparent/inner_right_weapons, -/turf/template_noop, -/area/shuttle/drop1/sulaco) "Et" = ( /turf/closed/shuttle/dropship1{ icon_state = "72" @@ -427,6 +415,14 @@ icon_state = "62" }, /area/shuttle/drop1/sulaco) +"Kk" = ( +/obj/effect/attach_point/crew_weapon/dropship1{ + attach_id = 7 + }, +/turf/open/shuttle/dropship{ + icon_state = "rasputin15" + }, +/area/shuttle/drop1/sulaco) "KC" = ( /obj/structure/machinery/door/airlock/hatch/cockpit, /obj/structure/blocker/forcefield/multitile_vehicles, @@ -453,6 +449,23 @@ icon_state = "64" }, /area/shuttle/drop1/sulaco) +"Nv" = ( +/obj/effect/attach_point/crew_weapon/dropship1{ + attach_id = 8 + }, +/turf/open/shuttle/dropship{ + icon_state = "rasputin15" + }, +/area/shuttle/drop1/sulaco) +"ND" = ( +/obj/effect/attach_point/fuel/dropship1{ + pixel_x = -32; + attach_id = 11 + }, +/turf/closed/shuttle/dropship1/transparent{ + icon_state = "33" + }, +/area/shuttle/drop1/sulaco) "NQ" = ( /obj/structure/shuttle/part/dropship1/transparent/left_inner_bottom_wing, /turf/template_noop, @@ -481,15 +494,6 @@ icon_state = "rasputin5" }, /area/shuttle/drop1/sulaco) -"Pf" = ( -/obj/structure/machinery/door/airlock/multi_tile/almayer/dropshiprear/dropshipside/ds1{ - dir = 1; - id = "starboard_door" - }, -/turf/open/shuttle/dropship{ - icon_state = "rasputin15" - }, -/area/shuttle/drop1/sulaco) "Ph" = ( /turf/closed/shuttle/dropship1{ icon_state = "68" @@ -502,6 +506,14 @@ icon_state = "rasputin15" }, /area/shuttle/drop1/sulaco) +"PV" = ( +/obj/effect/attach_point/crew_weapon/dropship1{ + attach_id = 9 + }, +/turf/open/shuttle/dropship{ + icon_state = "rasputin15" + }, +/area/shuttle/drop1/sulaco) "Qh" = ( /turf/closed/shuttle/dropship1/transparent{ icon_state = "32" @@ -575,12 +587,6 @@ /obj/structure/shuttle/part/dropship1/transparent/outer_left_weapons, /turf/template_noop, /area/shuttle/drop1/sulaco) -"Ua" = ( -/obj/effect/attach_point/fuel/dropship1, -/turf/closed/shuttle/dropship1/transparent{ - icon_state = "28" - }, -/area/shuttle/drop1/sulaco) "UG" = ( /obj/structure/prop/ice_colony/hula_girl{ pixel_x = -10; @@ -628,6 +634,23 @@ icon_state = "rasputin7" }, /area/shuttle/drop1/sulaco) +"XP" = ( +/obj/structure/machinery/door/airlock/multi_tile/almayer/dropshiprear/dropshipside/ds1{ + id = "port_door"; + dir = 2 + }, +/turf/open/shuttle/dropship{ + icon_state = "rasputin15" + }, +/area/shuttle/drop1/sulaco) +"Ye" = ( +/obj/effect/attach_point/electronics/dropship1{ + dir = 1; + attach_id = 6 + }, +/obj/structure/shuttle/part/dropship1/transparent/inner_right_weapons, +/turf/template_noop, +/area/shuttle/drop1/sulaco) "Za" = ( /turf/closed/shuttle/dropship1{ icon_state = "77" @@ -660,7 +683,7 @@ mb mb FA Oq -Ua +sm iz EN mb @@ -677,7 +700,7 @@ Et iI JP il -rS +XP mW qn sA @@ -694,7 +717,7 @@ NQ mb mb mb -Da +bc oo TK ws @@ -773,11 +796,11 @@ BB OK OU il -wr +Kk il -wr +Nv il -wr +PV il mb mb @@ -832,7 +855,7 @@ Wg mb mb mb -De +Ye oo TK cr @@ -861,7 +884,7 @@ iv zV MP il -Pf +ed nC nE rl @@ -890,7 +913,7 @@ mb mb eD Gw -os +ND qy Jm mb diff --git a/maps/shuttles/dropship_normandy.dmm b/maps/shuttles/dropship_normandy.dmm index a2847ae62611..5a733f6a9e9b 100644 --- a/maps/shuttles/dropship_normandy.dmm +++ b/maps/shuttles/dropship_normandy.dmm @@ -36,20 +36,6 @@ /obj/structure/shuttle/part/dropship2/transparent/right_outer_bottom_wing, /turf/template_noop, /area/shuttle/drop2/sulaco) -"do" = ( -/obj/effect/attach_point/crew_weapon/dropship2, -/turf/open/shuttle/dropship{ - icon_state = "rasputin3" - }, -/area/shuttle/drop2/sulaco) -"es" = ( -/obj/effect/attach_point/fuel/dropship2{ - pixel_x = -32 - }, -/turf/closed/shuttle/dropship2/transparent{ - icon_state = "33" - }, -/area/shuttle/drop2/sulaco) "eu" = ( /turf/closed/shuttle/dropship2{ icon_state = "75" @@ -93,6 +79,14 @@ icon_state = "54" }, /area/shuttle/drop2/sulaco) +"gH" = ( +/obj/effect/attach_point/electronics/dropship2{ + dir = 1; + attach_id = 6 + }, +/obj/structure/shuttle/part/dropship2/transparent/inner_right_weapons, +/turf/template_noop, +/area/shuttle/drop2/sulaco) "gP" = ( /obj/structure/bed/chair/dropship/pilot{ dir = 1 @@ -101,6 +95,14 @@ icon_state = "rasputin15" }, /area/shuttle/drop2/sulaco) +"hn" = ( +/obj/effect/attach_point/crew_weapon/dropship2{ + attach_id = 8 + }, +/turf/open/shuttle/dropship{ + icon_state = "rasputin3" + }, +/area/shuttle/drop2/sulaco) "it" = ( /obj/structure/bed/chair/vehicle{ dir = 1; @@ -173,6 +175,14 @@ icon_state = "62" }, /area/shuttle/drop2/sulaco) +"mn" = ( +/obj/effect/attach_point/fuel/dropship2{ + attach_id = 10 + }, +/turf/closed/shuttle/dropship2/transparent{ + icon_state = "28" + }, +/area/shuttle/drop2/sulaco) "mz" = ( /obj/structure/machinery/camera/autoname/almayer/dropship_two{ dir = 4; @@ -190,6 +200,15 @@ icon_state = "rasputin15" }, /area/shuttle/drop2/sulaco) +"mA" = ( +/obj/structure/machinery/door/airlock/multi_tile/almayer/dropshiprear/dropshipside/ds2{ + id = "port_door"; + dir = 2 + }, +/turf/open/shuttle/dropship{ + icon_state = "rasputin15" + }, +/area/shuttle/drop2/sulaco) "nq" = ( /obj/effect/attach_point/weapon/dropship2/left_fore, /obj/structure/shuttle/part/dropship2/transparent/outer_left_weapons, @@ -253,10 +272,13 @@ icon_state = "rasputin3" }, /area/shuttle/drop2/sulaco) -"vw" = ( -/obj/effect/attach_point/fuel/dropship2, -/turf/closed/shuttle/dropship2/transparent{ - icon_state = "28" +"vh" = ( +/obj/structure/machinery/door/airlock/multi_tile/almayer/dropshiprear/dropshipside/ds2{ + dir = 1; + id = "starboard_door" + }, +/turf/open/shuttle/dropship{ + icon_state = "rasputin15" }, /area/shuttle/drop2/sulaco) "wX" = ( @@ -264,13 +286,6 @@ icon_state = "83" }, /area/shuttle/drop2/sulaco) -"xd" = ( -/obj/effect/attach_point/electronics/dropship2{ - dir = 1 - }, -/obj/structure/shuttle/part/dropship2/transparent/inner_right_weapons, -/turf/template_noop, -/area/shuttle/drop2/sulaco) "xe" = ( /turf/closed/shuttle/dropship2{ icon_state = "18" @@ -310,6 +325,14 @@ icon_state = "56" }, /area/shuttle/drop2/sulaco) +"Bg" = ( +/obj/effect/attach_point/crew_weapon/dropship2{ + attach_id = 7 + }, +/turf/open/shuttle/dropship{ + icon_state = "rasputin3" + }, +/area/shuttle/drop2/sulaco) "Bi" = ( /turf/closed/shuttle/dropship2/transparent{ icon_state = "97" @@ -349,15 +372,6 @@ /obj/structure/shuttle/part/dropship2/transparent/lower_right_wing, /turf/template_noop, /area/shuttle/drop2/sulaco) -"En" = ( -/obj/structure/machinery/door/airlock/multi_tile/almayer/dropshiprear/dropshipside/ds2{ - dir = 1; - id = "starboard_door" - }, -/turf/open/shuttle/dropship{ - icon_state = "rasputin15" - }, -/area/shuttle/drop2/sulaco) "Eo" = ( /turf/closed/shuttle/dropship2{ icon_state = "47" @@ -463,6 +477,14 @@ /obj/structure/shuttle/part/dropship2/transparent/nose_top_left, /turf/template_noop, /area/shuttle/drop2/sulaco) +"MA" = ( +/obj/effect/attach_point/crew_weapon/dropship2{ + attach_id = 9 + }, +/turf/open/shuttle/dropship{ + icon_state = "rasputin3" + }, +/area/shuttle/drop2/sulaco) "ME" = ( /turf/closed/shuttle/dropship2/transparent{ icon_state = "96" @@ -494,6 +516,15 @@ /obj/structure/shuttle/part/dropship2/left_outer_wing_connector, /turf/open/space/basic, /area/shuttle/drop2/sulaco) +"Od" = ( +/obj/effect/attach_point/fuel/dropship2{ + pixel_x = -32; + attach_id = 11 + }, +/turf/closed/shuttle/dropship2/transparent{ + icon_state = "33" + }, +/area/shuttle/drop2/sulaco) "Ov" = ( /obj/structure/shuttle/part/dropship2/transparent/right_inner_bottom_wing, /turf/template_noop, @@ -582,15 +613,6 @@ /obj/structure/shuttle/part/dropship2/nose_front_left, /turf/template_noop, /area/shuttle/drop2/sulaco) -"SC" = ( -/obj/structure/machinery/door/airlock/multi_tile/almayer/dropshiprear/dropshipside/ds2{ - id = "port_door"; - dir = 2 - }, -/turf/open/shuttle/dropship{ - icon_state = "rasputin15" - }, -/area/shuttle/drop2/sulaco) "SO" = ( /turf/closed/shuttle/dropship2{ icon_state = "36" @@ -693,7 +715,7 @@ Rr Rr BG SQ -vw +mn sk Xr Rr @@ -710,7 +732,7 @@ OI GE lJ PJ -SC +mA jc pU nS @@ -806,11 +828,11 @@ Bb Iv rc vd -do +Bg vd -do +hn vd -do +MA PJ Rr Rr @@ -865,7 +887,7 @@ RJ Rr Rr Rr -xd +gH yl SY it @@ -894,7 +916,7 @@ fI fx Tp PJ -En +vh gG RG QK @@ -923,7 +945,7 @@ Rr Rr yh UP -es +Od zt Uu Rr diff --git a/nano/templates/dropship_weapons_console.tmpl b/nano/templates/dropship_weapons_console.tmpl deleted file mode 100644 index fabfdee2467b..000000000000 --- a/nano/templates/dropship_weapons_console.tmpl +++ /dev/null @@ -1,245 +0,0 @@ - -{{if data.screen_mode == 0}} -
-

Equipment installed:

-
- {{for data.equipment_data}} - {{if value.is_interactable}} -
- {{:helper.link(value.name, null, {'equip_interact' : value.eqp_tag}, null , null)}} -
- {{else}} -
- {{:value.name}} -
- {{/if}} - {{empty}} - No equipment installed. - {{/for}} -
-
- {{if data.has_firemission}} -
-

Fire Missions:

-
- {{for data.firemission_data}} -
- - {{:value.name}} - - -   - - {{if !value.can_interact}} - - *!SELECT* - - {{/if}} - {{if !value.can_edit}} - - *!EDIT* - - {{/if}} - - {{if value.can_interact}} - - {{if value.selected}} - {{:helper.link("[UNSELECT]", null, {'mission_tag' : value.mission_tag}, null , null)}} - {{else}} - {{:helper.link("[SELECT]", null, {'mission_tag' : value.mission_tag}, null , null)}} - {{/if}} - - {{/if}} - - {{if value.can_edit}} - - {{:helper.link("[EDIT]", null, {'mission_tag_edit' : value.mission_tag}, null , null)}} - - {{/if}} - - - {{:helper.link("[DELETE]", null, {'mission_tag_delete' : value.mission_tag}, null , null)}} - -
- - {{empty}} - No Fire Missions Detected - {{/for}} -
- {{:helper.link("Create New Fire Mission", null, {'create_mission' : 1}, null , null)}} -
- -
-
-
-

Fire Mission Control:

- {{if data.can_firemission}} -
- {{:helper.link("Switch to Fire Mission", null, {'switch_to_firemission' : 1}, null , null)}} -
-
- {{else}} -
- Have to be in Transit, have to select a Fire Mission and Fire Mission has to be without errors. -
- {{/if}} -
-
-

Fire Mission Simulator:

- {{if data.shuttle_state != "in_transit"}} -
- {{:helper.link("Switch To Simulation", null, {'switch_to_simulation' : 1}, null , null)}} -
-
- {{else}} -
- Have to be Stationary, have to select a Fire Mission and Fire Mission has to be without errors. -
- {{/if}} -
- {{/if}} -{{else data.screen_mode == 1}} -

Weapon Selected: {{:data.selected_eqp}}

- {{if data.selected_eqp_ammo_name}} -
- Ammo loaded: {{:data.selected_eqp_ammo_name}} -
-
- {{if data.selected_eqp_ammo_amt > data.selected_eqp_max_ammo_amt*0.5}} - Ammo count: {{:data.selected_eqp_ammo_amt}} / {{:data.selected_eqp_max_ammo_amt}} - {{else data.selected_eqp_ammo_amt > 0}} - Ammo count: {{:data.selected_eqp_ammo_amt}} / {{:data.selected_eqp_max_ammo_amt}} - {{else}} - Ammo count: {{:data.selected_eqp_ammo_amt}} / {{:data.selected_eqp_max_ammo_amt}} - {{/if}} -
- {{else}} -
- No ammo loaded -
- {{/if}} - -
- Available Targets -
- {{:helper.link('Deselect Weapon', null, {'deselect' : '1'}, null , null)}} -
-
- -
- {{for data.targets_data}} - {{:helper.link(value.target_name, null, {'open_fire' : value.target_tag}, (data.shuttle_state == "in_transit") ? null : 'disabled' , 'fixedLeftLongText')}} {{:helper.link('View', 'search', {'cas_camera' : value.target_tag}, (data.shuttle_state == "in_transit") ? null : 'disabled' , 'fixedLeft')}} - {{empty}} - No laser target detected. - {{/for}} -
- - - -{{else data.screen_mode == 2}} -

Fire Mission Editing: {{:data.editing_firemission}}

- {{if data.current_mission_error}} -
- ERROR DETECTED: {{:data.current_mission_error}} -
- {{else}} -
- No errors detected -
- {{/if}} - -
- Mission Tile Coverage: {{:data.editing_firemission_length}} -
- - - - - - - {{for data.firemission_edit_timeslices}} - - {{/for}} - - {{for data.firemission_edit_data :fm_value:fm_id}} - - - - - {{for fm_value.offsets :offset_value:offset_id}} - - {{/for}} - - {{/for}} -
NameAmmoGimbal - {{:value}} -
{{:fm_value.name}} - {{if fm_value.ammo==null}} - 0/0 - {{else}} - {{if fm_value.ammo.used > fm_value.ammo.count}} - {{:fm_value.ammo.count?fm_value.ammo.count:0}}/{{:fm_value.ammo.max?fm_value.ammo.max:0}} - {{else fm_value.ammo.used * 2 > fm_value.ammo.count}} - {{:fm_value.ammo.count?fm_value.ammo.count:0}}/{{:fm_value.ammo.max?fm_value.ammo.max:0}} - {{else}} - {{:fm_value.ammo.count?fm_value.ammo.count:0}}/{{:fm_value.ammo.max?fm_value.ammo.max:0}} - {{/if}} - {{/if}} - - {{if(fm_value.gimbal)}} - {{:fm_value.gimbal.min}} to {{:fm_value.gimbal.max}} - {{else}} - Not installed - {{/if}} - - {{:helper.link(offset_value == null ? '-' : offset_value, null, {'fm_weapon_id' : fm_id, 'fm_offset_id' : offset_id, 'fm_offset_previous': offset_value}, null , null)}} -
- -
- {{:helper.link("BACK", null, {'leave_firemission_editing' : 1}, null , null)}} -
- -{{else data.screen_mode == 3 && data.has_firemission}} -

Fire Mission Selected: {{:data.firemission_name}}

- -

- Fire Mission Status: {{:data.firemission_message}} -

- -
-

Fire Mission Options:

- - - - - - - - - - - - - -
Target:{{:data.firemission_selected_laser}}
Direction:{{:helper.link(data.firemission_direction, null, {'change_direction' : 1}, (data.shuttle_state == "in_transit" && data.firemission_step < 2) ? null : 'disabled' , null)}}
Offset:{{:helper.link(data.firemission_offset, null, {'change_offset' : 1}, (data.shuttle_state == "in_transit" && data.firemission_step < 2) ? null : 'disabled' , null)}}
-
- -
-

Fire Mission Actions:

-
- {{:helper.link('BACK', null, {'leave_firemission_execution' : '1'}, null , 'fixedLeft')}} - {{:helper.link('Activate Camera', null, {'firemission_camera' : 1}, (data.shuttle_state == "in_transit" && data.firemission_selected_laser) ? null : 'disabled' , 'fixedLeft')}} - {{:helper.link('Execute Fire Mission', null, {'execute_firemission' : 1}, (data.shuttle_state == "in_transit" && data.firemission_step == 0) ? null : 'disabled' , "linkDanger fixedLeftWide")}} -
-
-
-
Available Targets:
-
- {{for data.targets_data}} - {{:helper.link(value.target_name, null, {'select_laser_firemission' : value.target_tag}, (data.shuttle_state == "in_transit") ? null : 'disabled' , 'fixedLeftLongText')}} - {{empty}} - No CAS signal detected. - {{/for}} -
- -{{/if}} diff --git a/tgui/packages/tgui/interfaces/CasSim.js b/tgui/packages/tgui/interfaces/CasSim.js deleted file mode 100644 index 2346435e336a..000000000000 --- a/tgui/packages/tgui/interfaces/CasSim.js +++ /dev/null @@ -1,109 +0,0 @@ -import { useBackend } from '../backend'; -import { Button, Section, ProgressBar, NoticeBox, Box, Stack } from '../components'; -import { Window } from '../layouts'; - -export const CasSim = (_props, context) => { - const { act, data } = useBackend(context); - - const timeLeft = data.nextdetonationtime - data.worldtime; - const timeLeftPct = timeLeft / data.detonation_cooldown; - - const canDetonate = timeLeft < 0 && data.configuration && data.looking; - - return ( - - -
- {(!!data.configuration && ( - - Configuration : Executing {data.configuration}! - - )) || ( - - No firemission configuration loaded! - - )} - - Target dummy type : {data.dummy_mode} - - {timeLeft > 0 && ( - - - {Math.ceil(timeLeft / 10)} seconds until the console's - processors finish cooling! - - - )} -
-
- - - {(!data.looking && ( -
-
-
- ); -}; diff --git a/tgui/packages/tgui/interfaces/CasSim.tsx b/tgui/packages/tgui/interfaces/CasSim.tsx new file mode 100644 index 000000000000..b81e1baafe9c --- /dev/null +++ b/tgui/packages/tgui/interfaces/CasSim.tsx @@ -0,0 +1,106 @@ +import { useBackend } from '../backend'; +import { Box, Button, Section, ProgressBar, NoticeBox, Stack } from '../components'; + +interface CasSimData { + configuration: any; + looking: 0 | 1; + dummy_mode: string; + worldtime: number; + nextdetonationtime: number; + detonation_cooldown: number; +} + +export const CasSim = (_props, context) => { + const { act, data } = useBackend(context); + + const timeLeft = data.nextdetonationtime - data.worldtime; + const timeLeftPct = timeLeft / data.detonation_cooldown; + + const canDetonate = timeLeft < 0 && data.configuration && data.looking; + + return ( + +
+ {(!!data.configuration && ( + + Configuration : Executing {data.configuration}! + + )) || ( + No firemission configuration loaded! + )} + Target dummy type : {data.dummy_mode} + {timeLeft > 0 && ( + + + {Math.ceil(timeLeft / 10)} seconds until the console's + processors finish cooling! + + + )} +
+
+ + + {(!data.looking && ( +
+
+ ); +}; diff --git a/tgui/packages/tgui/interfaces/CrtPanel.tsx b/tgui/packages/tgui/interfaces/CrtPanel.tsx new file mode 100644 index 000000000000..5745bd29c5a9 --- /dev/null +++ b/tgui/packages/tgui/interfaces/CrtPanel.tsx @@ -0,0 +1,20 @@ +import { classes } from 'common/react'; +import { Box } from '../components'; +import { BoxProps } from '../components/Box'; +interface CrtPanelProps extends BoxProps { + color: 'green' | 'yellow' | 'blue'; +} +export const CrtPanel = (props: CrtPanelProps) => { + return ( +
+ + {props.children} + +
+ ); +}; diff --git a/tgui/packages/tgui/interfaces/DropshipWeaponsConsole.tsx b/tgui/packages/tgui/interfaces/DropshipWeaponsConsole.tsx new file mode 100644 index 000000000000..629191b3ba70 --- /dev/null +++ b/tgui/packages/tgui/interfaces/DropshipWeaponsConsole.tsx @@ -0,0 +1,366 @@ +import { useBackend } from '../backend'; +import { Window } from '../layouts'; +import { Box, Divider, Flex, Stack } from '../components'; +import { CasSim } from './CasSim'; +import { MfdPanel, MfdProps } from './MfdPanels/MultifunctionDisplay'; +import { CameraMfdPanel } from './MfdPanels/CameraPanel'; +import { EquipmentMfdPanel } from './MfdPanels/EquipmentPanel'; +import { MapMfdPanel } from './MfdPanels/MapPanel'; +import { WeaponMfdPanel } from './MfdPanels/WeaponPanel'; +import { SupportMfdPanel } from './MfdPanels/SupportPanel'; +import { FiremissionMfdPanel } from './MfdPanels/FiremissionPanel'; +import { TargetAquisitionMfdPanel } from './MfdPanels/TargetAquisition'; +import { mfdState } from './MfdPanels/stateManagers'; +import { Dpad } from './common/Dpad'; + +export interface DropshipProps { + equipment_data: Array; + medevac_targets: Array; + fulton_targets: Array; + selected_eqp: number; + tactical_map_ref?: string; + camera_map_ref?: string; + camera_target_id?: string; + targets_data: Array; +} + +type MedevacTargets = { + area: string; + occupant: string; + ref: string; + triage_card?: string; + damage?: { + hp: number; + brute: number; + oxy: number; + tox: number; + fire: number; + undefib: number; + }; +}; + +type LazeTarget = { + target_name: string; + target_tag: number; +}; + +export type DropshipEquipment = { + name: string; + shorthand: string; + eqp_tag: number; + is_missile: 0 | 1; + is_weapon: 0 | 1; + is_interactable: 0 | 1; + mount_point: number; + ammo_name: string; + ammo?: number; + burst?: number; + max_ammo?: number; + firemission_delay?: number; + data?: any; +}; + +const xOffset = 40; +const yOffset = 0; +const xLookup = (index: number) => [0, 40, 80, 120][index] + xOffset; +const yLookup = (index: number) => [150, 20, 20, 150][index] + yOffset; +const OutlineColor = '#00e94e'; +const OutlineWidth = '2'; + +const DrawShipOutline = () => { + const drawLine = (pos0, pos1) => ( + + ); + return ( + <> + {drawLine(0, 1)} + {drawLine(1, 2)} + {drawLine(2, 3)} + + ); +}; + +const DrawWeapon = (props: { weapon: DropshipEquipment }, context) => { + const { data, act } = useBackend(context); + const position = props.weapon.mount_point; + const index = position - 1; + const x = xLookup(index); + const y = yLookup(index); + return ( + <> + + act('select_equipment', { 'equipment_id': props.weapon.eqp_tag }) + } + /> + + {props.weapon.shorthand} + + + ); +}; + +const WeaponStatsPanel = (props: { + slot: number; + weapon?: DropshipEquipment; +}) => { + if (props.weapon === undefined) { + return ; + } + return ( + + {props.weapon.name ?? 'Empty'} + {props.weapon.is_missile === 0 && props.weapon.ammo !== null && ( + + Ammo: {props.weapon?.ammo ?? 'Empty'} /{' '} + {props.weapon.max_ammo ?? 'Empty'} + + )} + {props.weapon?.is_missile === 1 && ( + + Loaded:
+ {props.weapon.ammo_name} +
+ )} + {props.weapon?.ammo === null && Empty} +
+ ); +}; + +const EmptyWeaponStatsPanel = (props: { slot: number }) => { + return ( + + Bay {props.slot} is empty + + ); +}; + +const DropshipWeaponsPanel = (props: { + equipment: Array; +}) => { + const weapons = props.equipment.filter((x) => x.is_weapon === 1); + const support = props.equipment.filter((x) => x.is_weapon === 0); + return ( + + + + + + x.mount_point === 2)} + /> + + + + + + x.mount_point === 1)} + /> + + + + + + + + + {weapons.map((x) => ( + + ))} + + + + + {support.map((x) => ( + {x.name} + ))} + + + + + + + + x.mount_point === 3)} + /> + + + + + + x.mount_point === 4)} + /> + + + + + + ); +}; + +const LcdPanel = (props, context) => { + const { data } = useBackend(context); + return ( + + + + ); +}; + +const FiremissionSimulationPanel = (props, context) => { + return ( + + + + ); +}; + +const FiremissionsSimMfdPanel = (props: MfdProps, context) => { + const { setPanelState } = mfdState(context, props.panelStateId); + return ( + setPanelState(''), + }, + ]}> + + + ); +}; + +const WeaponsMfdPanel = (props, context) => { + return ( + + + + ); +}; + +const BaseMfdPanel = (props: MfdProps, context) => { + const { setPanelState } = mfdState(context, props.panelStateId); + + return ( + setPanelState('equipment') }, + { + children: 'F-MISS', + onClick: () => setPanelState('firemission'), + }, + {}, + { + children: 'TARGETS', + onClick: () => setPanelState('target-aquisition'), + }, + ]} + bottomButtons={[ + {}, + { children: 'MAPS', onClick: () => setPanelState('map') }, + { children: 'CAMS', onClick: () => setPanelState('camera') }, + ]}> + +
+

U.S.C.M.

+

Dropship Weapons Control System

+

UA Northbridge

+

V 0.1

+
+
+
+ ); +}; + +const PrimaryPanel = (props: MfdProps, context) => { + const { panelState } = mfdState(context, props.panelStateId); + switch (panelState) { + case 'camera': + return ; + case 'equipment': + return ; + case 'map': + return ; + case 'weapons': + return ; + case 'firemission': + return ; + case 'firemission-sim': + return ; + case 'target-aquisition': + return ; + case 'weapon': + return ; + case 'support': + return ; + default: + return ; + } +}; + +export const DropshipWeaponsConsole = () => { + return ( + + + + + + + + + + + + + + + + Offset +
+ Calibration +
+ +
+
+ + + + +
+
+
+
+ ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/CameraPanel.tsx b/tgui/packages/tgui/interfaces/MfdPanels/CameraPanel.tsx new file mode 100644 index 000000000000..f3a1197e9802 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/CameraPanel.tsx @@ -0,0 +1,37 @@ +import { MfdProps, MfdPanel } from './MultifunctionDisplay'; +import { ByondUi } from '../../components'; +import { useBackend } from '../../backend'; +import { Box } from '../../components'; +import { mfdState } from './stateManagers'; +import { CameraProps } from './types'; + +export const CameraMfdPanel = (props: MfdProps, context) => { + const { act } = useBackend(context); + const { setPanelState } = mfdState(context, props.panelStateId); + return ( + act('nvg-enable') }, + { children: 'nvgoff', onClick: () => act('nvg-disable') }, + ]} + bottomButtons={[{ children: 'EXIT', onClick: () => setPanelState('') }]}> + + + ); +}; + +const CameraPanel = (_, context) => { + const { data } = useBackend(context); + return ( + + + + ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/EquipmentPanel.tsx b/tgui/packages/tgui/interfaces/MfdPanels/EquipmentPanel.tsx new file mode 100644 index 000000000000..05a500563b52 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/EquipmentPanel.tsx @@ -0,0 +1,350 @@ +import { useBackend } from '../../backend'; +import { Box } from '../../components'; +import { DropshipEquipment } from '../DropshipWeaponsConsole'; +import { MfdProps, MfdPanel } from './MultifunctionDisplay'; +import { mfdState, useEquipmentState, useWeaponState } from './stateManagers'; +import { EquipmentContext } from './types'; + +const equipment_xs = [140, 160, 320, 340, 180, 300, 240, 240, 240, 140, 340]; +const equipment_ys = [120, 100, 100, 120, 100, 100, 260, 300, 340, 320, 320]; + +const DrawWeapon = (props: { x: number; y: number }, context) => { + return ( + + ); +}; + +const DrawEquipmentBox = (props: { x: number; y: number }, context) => { + return ( + + ); +}; + +const equipment_text_xs = [ + 100, 120, 360, 380, 180, 320, 250, 250, 250, 100, 400, +]; +const equipment_text_ys = [120, 60, 60, 120, 20, 20, 240, 280, 320, 320, 320]; + +const DrawWeaponText = (props: { + x: number; + y: number; + desc: string; + sub_desc?: string; +}) => { + return ( + + {props.desc.split(' ').map((x) => ( + + {x} + + ))} + + {props.sub_desc && ( + + {props.sub_desc} + + )} + + ); +}; + +const DrawWeaponEquipment = (props: DropshipEquipment) => { + return ( + <> + + + + ); +}; + +const DrawMiscEquipment = (props: DropshipEquipment, context) => { + return ( + <> + + + + ); +}; + +const DrawEquipment = (props, context) => { + const { data } = useBackend(context); + return ( + <> + {data.equipment_data.map((x) => { + if (x.is_weapon) { + return ; + } + return ; + })} + + ); +}; + +const DrawDropshipOutline = () => { + return ( + <> + {/* cockpit */} + + + {/* left body */} + + + {/* left weapon */} + + {/* left engine */} + + + {/* left tail */} + + + {/* right body */} + + {/* right weapon */} + + + {/* right engine */} + + + {/* right tail */} + + + ); +}; +const DrawAirlocks = () => { + return ( + <> + {/* cockpit door */} + + {/* left airlock */} + + {/* right airlock */} + + {/* rear ramp */} + + + ); +}; + +const EquipmentPanel = () => { + return ( + + + + + + + + + + + + + + + + + + + + + + ); +}; + +const ShipOutline = () => { + return ; +}; + +export const EquipmentMfdPanel = (props: MfdProps, context) => { + const { data } = useBackend(context); + const { setPanelState } = mfdState(context, props.panelStateId); + + const { setWeaponState } = useWeaponState(context, props.panelStateId); + + const { setEquipmentState } = useEquipmentState(context, props.panelStateId); + + const weap1 = data.equipment_data.find((x) => x.mount_point === 1); + const weap2 = data.equipment_data.find((x) => x.mount_point === 2); + const weap3 = data.equipment_data.find((x) => x.mount_point === 3); + const weap4 = data.equipment_data.find((x) => x.mount_point === 4); + const support1 = data.equipment_data.find((x) => x.mount_point === 7); + const support2 = data.equipment_data.find((x) => x.mount_point === 8); + const support3 = data.equipment_data.find((x) => x.mount_point === 9); + + const elec1 = data.equipment_data.find((x) => x.mount_point === 5); + const elec2 = data.equipment_data.find((x) => x.mount_point === 6); + + const generateWeaponButton = (equip: DropshipEquipment) => { + return { + children: equip.shorthand, + onClick: () => { + setWeaponState(equip.mount_point); + setPanelState('weapon'); + }, + }; + }; + + const generateEquipmentButton = (equip: DropshipEquipment) => { + return { + children: equip.shorthand, + onClick: () => { + setEquipmentState(equip.mount_point); + setPanelState('support'); + }, + }; + }; + + const generateButton = (equip: DropshipEquipment) => { + return equip.is_weapon + ? generateWeaponButton(equip) + : generateEquipmentButton(equip); + }; + + return ( + setPanelState('firemission'), + }, + {}, + {}, + ]} + leftButtons={[ + weap2 ? generateButton(weap2) : {}, + weap1 ? generateButton(weap1) : {}, + support1 ? generateButton(support1) : {}, + support2 ? generateButton(support2) : {}, + support3 ? generateButton(support3) : {}, + ]} + rightButtons={[ + weap3 ? generateButton(weap3) : {}, + weap4 ? generateButton(weap4) : {}, + elec1 ? generateButton(elec1) : {}, + elec2 ? generateButton(elec2) : {}, + {}, + ]} + bottomButtons={[ + { + children: 'EXIT', + onClick: () => setPanelState(''), + }, + ]}> + + + ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/FiremissionPanel.tsx b/tgui/packages/tgui/interfaces/MfdPanels/FiremissionPanel.tsx new file mode 100644 index 000000000000..fd71dab8f045 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/FiremissionPanel.tsx @@ -0,0 +1,580 @@ +import { MfdPanel, MfdProps } from './MultifunctionDisplay'; +import { Box, Button, Divider, Icon, Input, Stack } from '../../components'; +import { useBackend, useLocalState } from '../../backend'; +import { CasFiremission, FiremissionContext } from './types'; +import { range } from 'common/collections'; +import { DropshipEquipment, DropshipProps } from '../DropshipWeaponsConsole'; +import { fmEditState, fmState, fmWeaponEditState, mfdState } from './stateManagers'; + +const sortWeapons = (a: DropshipEquipment, b: DropshipEquipment) => { + return (a?.mount_point ?? 0) < (b?.mount_point ?? 0) ? -1 : 1; +}; + +const CreateFiremissionPanel = (props, context) => { + const { act } = useBackend(context); + const [fmName, setFmName] = useLocalState(context, 'fmname', ''); + return ( + + +

Create Fire Mission

+
+ + Firemission Name{' '} + setFmName(value)} + onEnter={() => { + if (fmName === '') { + return; + } + act('firemission-create', { + firemission_name: fmName, + firemission_length: 12, + }); + setFmName(''); + }} + /> + +
+ ); +}; + +const FiremissionList = (props, context) => { + const { data } = useBackend(context); + return ( + + +

Existing Fire Missions

+
+ + {data.firemission_data.map((x, i) => ( + + FM {i + 1}. {x.name} + + ))} + +
+ ); +}; + +const FiremissionMfdHomePage = (props: MfdProps, context) => { + const { setSelectedFm } = fmState(context, props.panelStateId); + const [fmName, setFmName] = useLocalState(context, 'fmname', ''); + const { data, act } = useBackend(context); + const { setPanelState } = mfdState(context, props.panelStateId); + + const firemission_mapper = (x: number) => { + const firemission = + data.firemission_data.length > x ? data.firemission_data[x] : undefined; + return { + children: firemission ? ( +
+ FM {x + 1}
{firemission?.name} +
+ ) : undefined, + onClick: () => setSelectedFm(firemission?.name), + }; + }; + + const [fmOffset, setFmOffset] = useLocalState( + context, + `${props.panelStateId}_fm_select_offset`, + 0 + ); + + const left_firemissions = range(fmOffset, fmOffset + 5).map( + firemission_mapper + ); + const right_firemissions = range(fmOffset + 5, fmOffset + 10).map( + firemission_mapper + ); + + return ( + { + act('firemission-create', { + firemission_name: fmName, + firemission_length: 12, + }); + setFmName(''); + }, + } + : {}, + { + children: , + onClick: () => { + if (fmOffset >= 1) { + setFmOffset(fmOffset - 1); + } + }, + }, + ]} + bottomButtons={[ + { + children: 'EXIT', + onClick: () => setPanelState(''), + }, + {}, + {}, + {}, + { + children: , + onClick: () => { + if (fmOffset + 8 < data.firemission_data.length) { + setFmOffset(fmOffset + 1); + } + }, + }, + ]}> + + + + + + + + + + + + + + + + + + ); +}; + +interface GimbalInfo { + min: number; + max: number; + values: string[]; +} + +const ViewFiremissionMfdPanel = ( + props: MfdProps & { firemission: CasFiremission }, + context +) => { + const { data, act } = useBackend(context); + const { setPanelState } = mfdState(context, props.panelStateId); + const { setSelectedFm } = fmState(context, props.panelStateId); + const { editFm, setEditFm } = fmEditState(context, props.panelStateId); + const { editFmWeapon, setEditFmWeapon } = fmWeaponEditState( + context, + props.panelStateId + ); + + const rightButtons = [ + editFmWeapon === undefined + ? {} + : { children: 'BACK', onClick: () => setEditFmWeapon(undefined) }, + ...data.equipment_data + .filter((x) => x.is_weapon === 1) + .sort((a, b) => (a.mount_point < b.mount_point ? -1 : 1)) + .map((x) => { + return { + children: `${x.shorthand} ${x.mount_point}`, + onClick: () => setEditFmWeapon(x.mount_point), + }; + }), + ]; + + const firemission = props.firemission; + return ( + { + act('firemission-delete', { + firemission_name: firemission.mission_tag, + }); + setSelectedFm(undefined); + }, + }, + { children: 'F-MISS', onClick: () => setSelectedFm(undefined) }, + editFm + ? { children: 'VIEW', onClick: () => setEditFm(false) } + : { children: 'EDIT', onClick: () => setEditFm(true) }, + ]} + bottomButtons={[ + { + children: 'EXIT', + onClick: () => setPanelState(''), + }, + ]} + rightButtons={editFm === true ? rightButtons : []}> + + + + + + + + +

Firemission:

+
+ +

{firemission.name}

+
+
+
+ + + +
+
+ +
+
+
+ ); +}; + +const FiremissionView = (props: MfdProps & { fm: CasFiremission }, context) => { + const { data } = useBackend(context); + + const { editFm } = fmEditState(context, props.panelStateId); + + const { editFmWeapon } = fmWeaponEditState(context, props.panelStateId); + + const weaponData = props.fm.records + .map((x) => data.equipment_data.find((y) => y.mount_point === x.weapon)) + .filter((x) => x !== undefined) + .sort(sortWeapons) as Array; + + const selectedWeapon = weaponData.find((x) => x.mount_point === editFmWeapon); + const displayDetail = editFm; + return ( + + + + Weapon + Ammunition + {!displayDetail && ( + <> + Consumption + + + )} + {displayDetail && ( + <> + Gimbals + Fire Delay + Offset + + )} + + + + + {range(1, 13).map((x) => ( + + {x} + + ))} + + + + + + + {!editFm && + weaponData.map((x) => ( + + + + ))} + {editFm && selectedWeapon === undefined && ( + Select weapon on right panel + )} + {editFm && selectedWeapon && ( + + + + )} + + ); +}; + +const gimbals: GimbalInfo[] = [ + { min: -1, max: -1, values: [] }, + { min: -6, max: 0, values: ['-6', '-5', '-4', '-3', '-2', '-1', '0', '-'] }, + { min: -6, max: 0, values: ['-6', '-5', '-4', '-3', '-2', '-1', '0', '-'] }, + { min: 0, max: 6, values: ['-', '0', '1', '2', '3', '4', '5', '6'] }, + { min: 0, max: 6, values: ['-', '0', '1', '2', '3', '4', '5', '6'] }, +]; + +const OffsetOverview = ( + props: MfdProps & { fm: CasFiremission; equipment: DropshipEquipment } +) => { + const weaponFm = props.fm.records.find( + (x) => x.weapon === props.equipment.mount_point + ); + if (weaponFm === undefined) { + return <>error; + } + const ammoConsumption = weaponFm.offsets + .map((x) => (x !== '-' ? props.equipment.burst ?? 0 : 0)) + .reduce((accumulator, currentValue) => accumulator + currentValue, 0); + return ( + <> + + {props.equipment.shorthand} {props.equipment.mount_point} + + + {props.equipment.ammo} / {props.equipment.max_ammo} + + + {ammoConsumption} + + + ); +}; + +const OffsetDetailed = ( + props: MfdProps & { + fm: CasFiremission; + equipment: DropshipEquipment; + } +) => { + const availableGimbals = gimbals[props.equipment.mount_point]; + const weaponFm = props.fm.records.find( + (x) => x.weapon === props.equipment.mount_point + ); + if (weaponFm === undefined) { + return <>error; + } + const ammoConsumption = weaponFm.offsets + .map((x) => (x === '-' ? props.equipment.burst : 0)) + .reduce( + (accumulator, currentValue) => (accumulator ?? 0) + (currentValue ?? 0), + 0 + ); + return ( + <> + + {props.equipment.shorthand} {props.equipment.mount_point} + + + {props.equipment.ammo} / {props.equipment.max_ammo} using{' '} + {ammoConsumption} per run. + + + {availableGimbals.min} to {availableGimbals.max} + + + {(props.equipment.firemission_delay ?? 0) - 1} + + + ); +}; + +const FMOffsetError = ( + props: MfdProps & { + fm: CasFiremission; + equipment: DropshipEquipment; + displayDetail?: boolean; + } +) => { + return ( + + {props.displayDetail ? ( + + ) : ( + + )} + + + + Unable to set firemission offsets. +
+ Offsets depend on ammunition. +
+ Load ammunition to adjust. +
+
+ ); +}; + +const FMOffsetStack = ( + props: MfdProps & { + fm: CasFiremission; + equipment: DropshipEquipment; + displayDetail?: boolean; + }, + context +) => { + const { fm } = props; + const { act } = useBackend(context); + const offsets = props.fm.records.find( + (x) => x.weapon === props.equipment.mount_point + )?.offsets; + + const { editFm } = fmEditState(context, props.panelStateId); + const availableGimbals = gimbals[props.equipment.mount_point]; + + const firemissionOffsets = props.equipment.firemission_delay ?? 0; + + if (firemissionOffsets === 0) { + return ; + } + + const availableMap = range(0, 13).map((_) => true); + offsets?.forEach((x, index) => { + if (x === undefined || x === '-') { + return; + } + // if offset is 0 then not allowed on strike. + if (firemissionOffsets === 0) { + range(0, availableMap.length - 1).forEach( + (value) => (availableMap[value] = false) + ); + return; + } + const indexMin = Math.max(index - firemissionOffsets + 1, 0); + const indexMax = Math.max( + Math.min(index + firemissionOffsets, availableMap.length - 1), + indexMin + ); + range(indexMin, indexMax).forEach((value) => (availableMap[value] = false)); + }); + + return ( + + {props.displayDetail ? ( + + ) : ( + + )} + + + {editFm && + availableGimbals.values.map((x) => ( + + {x === '-' ? 'UNSET' : x} + + ))} + + + + + + {editFm === false && + offsets && + offsets.map((x, i) => ( + + {x} + + ))} + + {editFm === true && + offsets && + offsets.map((x, i) => { + if (availableMap[i] === false && x === '-') { + return ( + + WEAPON BUSY + + ); + } + if (props.equipment.firemission_delay === 0) { + return ( + + + Ammo unusable for firemissions + + + ); + } + return ( + + + {availableGimbals.values.map((y) => { + const is_selected = x.toString() === y; + return ( + + + + ); + })} + + + ); + })} + + ); +}; + +export const FiremissionMfdPanel = (props: MfdProps, context) => { + const { data, act } = useBackend(context); + const { selectedFm } = fmState(context, props.panelStateId); + const firemission = data.firemission_data.find((x) => x.name === selectedFm); + if (firemission === undefined) { + return ; + } + return ( + + ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/FultonPanel.tsx b/tgui/packages/tgui/interfaces/MfdPanels/FultonPanel.tsx new file mode 100644 index 000000000000..05d33e51a8d1 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/FultonPanel.tsx @@ -0,0 +1,161 @@ +import { MfdPanel, MfdProps } from './MultifunctionDisplay'; +import { Box, Stack } from '../../components'; +import { useBackend, useLocalState } from '../../backend'; +import { mfdState, useEquipmentState } from './stateManagers'; +import { range } from 'common/collections'; +import { Icon } from '../../components'; +import { FultonProps } from './types'; + +export const FultonMfdPanel = (props: MfdProps, context) => { + const { data, act } = useBackend(context); + const [fulltonOffset, setFultonOffset] = useLocalState( + context, + `${props.panelStateId}_fultonoffset`, + 0 + ); + const { setPanelState } = mfdState(context, props.panelStateId); + const { equipmentState } = useEquipmentState(context, props.panelStateId); + + const fultons = [...data.fulton_targets]; + const regex = /(\d+)/; + + const result = data.equipment_data.find( + (x) => x.mount_point === equipmentState + ); + + const fulton_mapper = (x: number) => { + const target = fultons.length > x ? fultons[x] : undefined; + return { + children: target ? (regex.exec(target) ?? [target])[0] : undefined, + onClick: () => + act('fulton-target', { + equipment_id: result?.mount_point, + ref: target, + }), + }; + }; + + const left_targets = range(fulltonOffset, fulltonOffset + 5).map( + fulton_mapper + ); + + const right_targets = range(fulltonOffset + 5, fulltonOffset + 8).map( + fulton_mapper + ); + + const all_targets = range(fulltonOffset, fulltonOffset + 8) + .map((x) => fultons[x]) + .filter((x) => x !== undefined); + + return ( + , + onClick: () => { + if (fulltonOffset >= 1) { + setFultonOffset(fulltonOffset - 1); + } + }, + }, + ...right_targets, + { + children: , + onClick: () => { + if (fulltonOffset + 8 < data.fulton_targets.length) { + setFultonOffset(fulltonOffset + 1); + } + }, + }, + ]} + bottomButtons={[ + { + children: 'EXIT', + onClick: () => setPanelState(''), + }, + ]}> + + + + + {all_targets.length > 0 && ( + + )} + {all_targets.length > 1 && ( + + )} + {all_targets.length > 2 && ( + + )} + {all_targets.length > 3 && ( + + )} + {all_targets.length > 4 && ( + + )} + + + + + +

Active Fultons

+
+ {all_targets.map((x) => ( + +

{x}

+
+ ))} +
+
+ + + {all_targets.length > 5 && ( + + )} + {all_targets.length > 6 && ( + + )} + {all_targets.length > 7 && ( + + )} + + +
+
+
+ ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/MGPanel.tsx b/tgui/packages/tgui/interfaces/MfdPanels/MGPanel.tsx new file mode 100644 index 000000000000..dc6df25e17c1 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/MGPanel.tsx @@ -0,0 +1,69 @@ +import { MfdPanel, MfdProps } from './MultifunctionDisplay'; +import { Box, Stack } from '../../components'; +import { DropshipEquipment } from '../DropshipWeaponsConsole'; +import { useBackend } from '../../backend'; +import { mfdState, useEquipmentState } from './stateManagers'; +import { EquipmentContext, MGSpec } from './types'; + +const MgPanel = (props: DropshipEquipment) => { + const mgData = props.data as MGSpec; + return ( + + + + + + + +

{props.name}

+
+ +

+ Health: {mgData.health} / {mgData.health_max} +

+
+ +

+ Ammo {mgData.rounds} / {mgData.max_rounds} +

+
+ +

{mgData.deployed === 1 ? 'DEPLOYED' : 'UNDEPLOYED'}

+
+
+
+ + + +
+ ); +}; + +export const MgMfdPanel = (props: MfdProps, context) => { + const { act, data } = useBackend(context); + const { setPanelState } = mfdState(context, props.panelStateId); + const { equipmentState } = useEquipmentState(context, props.panelStateId); + const mg = data.equipment_data.find((x) => x.mount_point === equipmentState); + return ( + setPanelState('equipment') }, + ]} + leftButtons={[ + { + children: 'DEPLOY', + onClick: () => + act('deploy-equipment', { equipment_id: mg?.mount_point }), + }, + ]} + bottomButtons={[ + { + children: 'EXIT', + onClick: () => setPanelState(''), + }, + ]}> + {mg && } + + ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/MapPanel.tsx b/tgui/packages/tgui/interfaces/MfdPanels/MapPanel.tsx new file mode 100644 index 000000000000..83ecaac24a5c --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/MapPanel.tsx @@ -0,0 +1,37 @@ +import { useBackend } from '../../backend'; +import { Box } from '../../components'; +import { MfdPanel, MfdProps } from './MultifunctionDisplay'; +import { ByondUi } from '../../components'; +import { MapProps } from './types'; +import { mfdState } from './stateManagers'; + +export const MapMfdPanel = (props: MfdProps, context) => { + const { setPanelState } = mfdState(context, props.panelStateId); + return ( + setPanelState(''), + }, + ]}> + + + ); +}; + +const MapPanel = (_, context) => { + const { data } = useBackend(context); + return ( + + + + ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/MedevacPanel.tsx b/tgui/packages/tgui/interfaces/MfdPanels/MedevacPanel.tsx new file mode 100644 index 000000000000..634b4ef2a52e --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/MedevacPanel.tsx @@ -0,0 +1,208 @@ +import { MfdProps, MfdPanel } from './MultifunctionDisplay'; +import { Box, Divider, Flex, Stack } from '../../components'; +import { useBackend, useLocalState } from '../../backend'; +import { range } from 'common/collections'; +import { Icon } from '../../components'; +import { mfdState, useEquipmentState } from './stateManagers'; +import { MedevacContext, MedevacTargets } from './types'; + +const MedevacOccupant = (props: { data: MedevacTargets }) => ( + + + + + {props.data.occupant ?? 'Empty'} + {props.data.area ?? 'Unknown'} + + + + + + HP +
+ {props.data.damage?.hp} +
+ + Brute +
+ {props.data.damage?.brute} +
+ + Fire +
+ {props.data.damage?.fire} +
+ + Tox +
+ {props.data.damage?.tox} +
+ + Oxy +
{props.data.damage?.oxy} +
+
+
+
+
+); + +export const MedevacMfdPanel = (props: MfdProps, context) => { + const [medevacOffset, setMedevacOffset] = useLocalState( + context, + `${props.panelStateId}_medevacoffset`, + 0 + ); + const { setPanelState } = mfdState(context, props.panelStateId); + const { equipmentState } = useEquipmentState(context, props.panelStateId); + + const { data, act } = useBackend(context); + + const result = data.equipment_data.find( + (x) => x.mount_point === equipmentState + ); + const medevacs = data.medevac_targets === null ? [] : data.medevac_targets; + const medevac_mapper = (x: number) => { + const target = medevacs.length > x ? medevacs[x] : undefined; + return { + children: target ? target.occupant?.split(' ')[0] ?? 'Empty' : undefined, + onClick: () => + act('medevac-target', { + equipment_id: result?.mount_point, + ref: target?.ref, + }), + }; + }; + + const left_targets = range(medevacOffset, medevacOffset + 5).map( + medevac_mapper + ); + + const right_targets = range(medevacOffset + 5, medevacOffset + 8).map( + medevac_mapper + ); + + const all_targets = range(medevacOffset, medevacOffset + 8) + .map((x) => data.medevac_targets[x]) + .filter((x) => x !== undefined); + return ( + , + onClick: () => { + if (medevacOffset >= 1) { + setMedevacOffset(medevacOffset - 1); + } + }, + }, + ...right_targets, + { + children: , + onClick: () => { + if (medevacOffset + 8 < data.medevac_targets.length) { + setMedevacOffset(medevacOffset + 1); + } + }, + }, + ]} + topButtons={[ + { + children: 'EQUIP', + onClick: () => setPanelState('equipment'), + }, + ]} + bottomButtons={[ + { + children: 'EXIT', + onClick: () => setPanelState(''), + }, + ]}> + + + + + {all_targets.length > 0 && ( + + )} + {all_targets.length > 1 && ( + + )} + {all_targets.length > 2 && ( + + )} + {all_targets.length > 3 && ( + + )} + {all_targets.length > 4 && ( + + )} + + + + + +

Medevac Requests

+
+ {all_targets.map((x) => ( + <> + + + + + + ))} +
+
+ + + {all_targets.length > 5 && ( + + )} + {all_targets.length > 6 && ( + + )} + {all_targets.length > 7 && ( + + )} + + +
+
+
+ ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/MultifunctionDisplay.tsx b/tgui/packages/tgui/interfaces/MfdPanels/MultifunctionDisplay.tsx new file mode 100644 index 000000000000..9df7eaffcde4 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/MultifunctionDisplay.tsx @@ -0,0 +1,152 @@ +import { useBackend } from '../../backend'; +import { Button, Flex } from '../../components'; +import { CrtPanel } from '../CrtPanel'; +import { Table, TableCell, TableRow } from '../../components/Table'; +import { InfernoNode } from 'inferno'; +import { ButtonProps } from './types'; +import { classes } from 'common/react'; + +export interface MfdProps { + panelStateId: string; + topButtons?: Array; + leftButtons?: Array; + rightButtons?: Array; + bottomButtons?: Array; + children?: InfernoNode; +} + +export const MfdButton = (props: ButtonProps, context) => { + const { act } = useBackend(context); + return ( + + ); +}; + +export const EmptyMfdButton = () => { + return ; +}; + +export const HorizontalPanel = ( + props: { buttons: Array }, + context +) => { + return ( + + {props.buttons.map((x, i) => ( + + {x ? : } + + ))} + + ); +}; + +export const VerticalPanel = ( + props: { buttons?: Array }, + context +) => { + return ( + + {props.buttons?.map((x, i) => ( + + {x ? : } + + ))} + + ); +}; + +const HexScrew = () => { + return ( + + + + + ); +}; + +export const MfdPanel = (props: MfdProps) => { + const topProps = props.topButtons ?? []; + const botProps = props.bottomButtons ?? []; + const leftProps = props.leftButtons ?? []; + const rightProps = props.rightButtons ?? []; + + const topButtons = Array.from({ length: 5 }).map((_, i) => topProps[i] ?? {}); + const bottomButtons = Array.from({ length: 5 }).map( + (_, i) => botProps[i] ?? {} + ); + const leftButtons = Array.from({ length: 5 }).map( + (_, i) => leftProps[i] ?? {} + ); + const rightButtons = Array.from({ length: 5 }).map( + (_, i) => rightProps[i] ?? {} + ); + return ( + + + + + + + + + + + + + + + + + + + {props.children} + + + + + + + + + + + + + + + + + +
+ ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/SentryPanel.tsx b/tgui/packages/tgui/interfaces/MfdPanels/SentryPanel.tsx new file mode 100644 index 000000000000..d8ea220ec986 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/SentryPanel.tsx @@ -0,0 +1,89 @@ +import { MfdPanel, MfdProps } from './MultifunctionDisplay'; +import { Box, Stack } from '../../components'; +import { DropshipEquipment } from '../DropshipWeaponsConsole'; +import { useBackend } from '../../backend'; +import { mfdState, useEquipmentState } from './stateManagers'; +import { EquipmentContext, SentrySpec } from './types'; + +const SentryPanel = (props: DropshipEquipment, context) => { + const sentryData = props.data as SentrySpec; + return ( + + + + + + + +

{props.name}

+
+ +

+ Health: {sentryData.health} / {sentryData.health_max} +

+
+ +

+ Ammo {sentryData.rounds} / {sentryData.max_rounds} +

+
+ +

{sentryData.deployed === 1 ? 'DEPLOYED' : 'UNDEPLOYED'}

+
+ +

+ {sentryData.engaged === 1 + ? 'ENGAGED' + : sentryData.deployed === 1 + ? 'STANDBY' + : 'OFFLINE'} +

+
+
+
+ + + +
+ ); +}; + +export const SentryMfdPanel = (props: MfdProps, context) => { + const { act, data } = useBackend(context); + const { setPanelState } = mfdState(context, props.panelStateId); + const { equipmentState } = useEquipmentState(context, props.panelStateId); + const sentry = data.equipment_data.find( + (x) => x.mount_point === equipmentState + ); + const deployLabel = + (sentry?.data?.deployed ?? 0) === 1 ? 'RETRACT' : 'DEPLOY'; + return ( + setPanelState('equipment') }, + ]} + leftButtons={[ + { + children: deployLabel, + onClick: () => + act('deploy-equipment', { equipment_id: sentry?.mount_point }), + }, + { + children: 'CAMERA', + onClick: () => + act('set-camera-sentry', { equipment_id: sentry?.mount_point }), + }, + ]} + bottomButtons={[ + { + children: 'EXIT', + onClick: () => setPanelState(''), + }, + ]}> + + {sentry && } + + + ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/SpotlightPanel.tsx b/tgui/packages/tgui/interfaces/MfdPanels/SpotlightPanel.tsx new file mode 100644 index 000000000000..ce241420497e --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/SpotlightPanel.tsx @@ -0,0 +1,60 @@ +import { MfdPanel, MfdProps } from './MultifunctionDisplay'; +import { Box, Stack } from '../../components'; +import { useBackend } from '../../backend'; +import { mfdState, useEquipmentState } from './stateManagers'; +import { EquipmentContext, SpotlightSpec } from './types'; +import { DropshipEquipment } from '../DropshipWeaponsConsole'; + +const SpotPanel = (props: DropshipEquipment) => { + const spotData = props.data as SpotlightSpec; + return ( + + + + + + + +

{props.name}

+
+
+
+ + + +
+ ); +}; + +export const SpotlightMfdPanel = (props: MfdProps, context) => { + const { act, data } = useBackend(context); + const { setPanelState } = mfdState(context, props.panelStateId); + const { equipmentState } = useEquipmentState(context, props.panelStateId); + const spotlight = data.equipment_data.find( + (x) => x.mount_point === equipmentState + ); + return ( + setPanelState('equipment') }, + ]} + leftButtons={[ + { + children: 'DEPLOY', + onClick: () => + act('deploy-equipment', { equipment_id: spotlight?.mount_point }), + }, + ]} + bottomButtons={[ + { + children: 'EXIT', + onClick: () => setPanelState(''), + }, + ]}> + + {spotlight && } + + + ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/SupportPanel.tsx b/tgui/packages/tgui/interfaces/MfdPanels/SupportPanel.tsx new file mode 100644 index 000000000000..1eca123173b0 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/SupportPanel.tsx @@ -0,0 +1,62 @@ +import { useBackend } from '../../backend'; +import { MfdPanel, MfdProps } from './MultifunctionDisplay'; +import { MedevacMfdPanel } from './MedevacPanel'; +import { FultonMfdPanel } from './FultonPanel'; +import { Box, Stack } from '../../components'; +import { SentryMfdPanel } from './SentryPanel'; +import { MgMfdPanel } from './MGPanel'; +import { SpotlightMfdPanel } from './SpotlightPanel'; +import { EquipmentContext } from './types'; +import { mfdState, useEquipmentState } from './stateManagers'; + +export const SupportMfdPanel = (props: MfdProps, context) => { + const { equipmentState } = useEquipmentState(context, props.panelStateId); + + const { setPanelState } = mfdState(context, props.panelStateId); + + const { data } = useBackend(context); + const result = data.equipment_data.find( + (x) => x.mount_point === equipmentState + ); + if (result?.shorthand === 'Medevac') { + return ; + } + if (result?.shorthand === 'Fulton') { + return ; + } + if (result?.shorthand === 'Sentry') { + return ; + } + if (result?.shorthand === 'MG') { + return ; + } + if (result?.shorthand === 'Spotlight') { + return ; + } + return ( + setPanelState(''), + }, + ]}> + + + +

Component {result?.shorthand} not found

+
+ +

Is this authorised equipment?

+
+ +

+ Contact your local WY representative for further upgrade options +

+
+
+
+
+ ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/TargetAquisition.tsx b/tgui/packages/tgui/interfaces/MfdPanels/TargetAquisition.tsx new file mode 100644 index 000000000000..49f22db18104 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/TargetAquisition.tsx @@ -0,0 +1,519 @@ +import { range } from 'common/collections'; +import { useBackend, useLocalState, useSharedState } from '../../backend'; +import { Box, Icon, Stack } from '../../components'; +import { MfdProps, MfdPanel } from './MultifunctionDisplay'; +import { mfdState, useFiremissionXOffsetValue, useFiremissionYOffsetValue, useLazeTarget } from './stateManagers'; +import { CasFiremission, EquipmentContext, FiremissionContext, TargetContext } from './types'; + +const directionLookup = new Map(); +directionLookup['SOUTH'] = 2; +directionLookup['NORTH'] = 1; +directionLookup['WEST'] = 8; +directionLookup['EAST'] = 4; + +const useStrikeMode = (context) => { + const [data, set] = useSharedState( + context, + 'strike-mode', + undefined + ); + return { + strikeMode: data, + setStrikeMode: set, + }; +}; + +const useStrikeDirection = (context) => { + const [data, set] = useSharedState( + context, + 'strike-direction', + undefined + ); + return { + strikeDirection: data, + setStrikeDirection: set, + }; +}; + +const useWeaponSelectedState = (context) => { + const [data, set] = useSharedState( + context, + 'target-weapon-select', + undefined + ); + return { + weaponSelected: data, + setWeaponSelected: set, + }; +}; + +const useTargetFiremissionSelect = (context) => { + const [data, set] = useSharedState( + context, + 'target-firemission-select', + undefined + ); + return { + firemissionSelected: data, + setFiremissionSelected: set, + }; +}; + +const useTargetOffset = (context, panelId: string) => { + const [data, set] = useLocalState(context, `${panelId}_targetOffset`, 0); + return { + targetOffset: data, + setTargetOffset: set, + }; +}; + +const useTargetSubmenu = (context, panelId: string) => { + const [data, set] = useSharedState( + context, + `${panelId}_target_left`, + undefined + ); + return { + leftButtonMode: data, + setLeftButtonMode: set, + }; +}; + +const TargetLines = (props: { panelId: string }, context) => { + const { data } = useBackend< + EquipmentContext & FiremissionContext & TargetContext + >(context); + const { targetOffset } = useTargetOffset(context, props.panelId); + return ( + <> + {data.targets_data.length > targetOffset && ( + + )} + {data.targets_data.length > targetOffset + 1 && ( + + )} + {data.targets_data.length > targetOffset + 2 && ( + + )} + + {data.targets_data.length > targetOffset + 3 && ( + + )} + {data.targets_data.length > targetOffset + 4 && ( + + )} + + ); +}; + +const leftButtonGenerator = (context, panelId: string) => { + const { data } = useBackend< + EquipmentContext & FiremissionContext & TargetContext + >(context); + const { leftButtonMode, setLeftButtonMode } = useTargetSubmenu( + context, + panelId + ); + const { strikeMode, setStrikeMode } = useStrikeMode(context); + const { setStrikeDirection } = useStrikeDirection(context); + const { firemissionSelected, setFiremissionSelected } = + useTargetFiremissionSelect(context); + const { weaponSelected, setWeaponSelected } = useWeaponSelectedState(context); + const weapons = data.equipment_data.filter((x) => x.is_weapon); + if (leftButtonMode === undefined) { + return [ + { + children: 'STRIKE', + onClick: () => setLeftButtonMode('STRIKE'), + }, + { + children: 'VECTOR', + onClick: () => setLeftButtonMode('VECTOR'), + }, + ]; + } + if (leftButtonMode === 'STRIKE') { + if (strikeMode === 'weapon' && weaponSelected === undefined) { + return weapons.map((x) => { + return { + children: x.shorthand, + onClick: () => { + setWeaponSelected(x.mount_point); + setLeftButtonMode(undefined); + }, + }; + }); + } + if (strikeMode === 'firemission' && firemissionSelected === undefined) { + return data.firemission_data.map((x) => { + return { + children: x.name, + onClick: () => { + setFiremissionSelected(x); + setLeftButtonMode(undefined); + }, + }; + }); + } + return [ + { children: 'CANCEL', onClick: () => setLeftButtonMode(undefined) }, + { + children: 'WEAPON', + onClick: () => { + setWeaponSelected(undefined); + setStrikeMode('weapon'); + }, + }, + { + children: 'F-MISS', + onClick: () => { + setFiremissionSelected(undefined); + setStrikeMode('firemission'); + }, + }, + ]; + } + if (leftButtonMode === 'VECTOR') { + return [ + { children: 'CANCEL', onClick: () => setLeftButtonMode(undefined) }, + { + children: 'SOUTH', + onClick: () => { + setStrikeDirection('SOUTH'); + setLeftButtonMode(undefined); + }, + }, + { + children: 'NORTH', + onClick: () => { + setStrikeDirection('NORTH'); + setLeftButtonMode(undefined); + }, + }, + { + children: 'EAST', + onClick: () => { + setStrikeDirection('EAST'); + setLeftButtonMode(undefined); + }, + }, + { + children: 'WEST', + onClick: () => { + setStrikeDirection('WEST'); + setLeftButtonMode(undefined); + }, + }, + ]; + } + + return []; +}; + +const lazeMapper = (context, offset) => { + const { act, data } = useBackend(context); + const { setSelectedTarget } = useLazeTarget(context); + + const { fmXOffsetValue } = useFiremissionXOffsetValue(context); + const { fmYOffsetValue } = useFiremissionYOffsetValue(context); + + const target = + data.targets_data.length > offset ? data.targets_data[offset] : undefined; + const isDebug = target?.target_name.includes('debug'); + + const buttomLabel = () => { + if (isDebug) { + return 'd-' + target?.target_name.split(' ')[3]; + } + const label = target?.target_name.split(' ')[0] ?? ''; + const squad = label[0] ?? undefined; + const number = label.split('-')[1] ?? undefined; + return squad !== undefined && number !== undefined + ? `${squad}-${number}` + : target?.target_name; + }; + + return { + children: buttomLabel(), + onClick: target + ? () => { + setSelectedTarget(target.target_tag); + act('firemission-dual-offset-camera', { + 'target_id': target.target_tag, + 'x_offset_value': fmXOffsetValue, + 'y_offset_value': fmYOffsetValue, + }); + } + : () => { + act('set-camera', { 'equipment_id': null }); + setSelectedTarget(undefined); + }, + }; +}; + +export const TargetAquisitionMfdPanel = (props: MfdProps, context) => { + const { panelStateId } = props; + + const { act, data } = useBackend< + EquipmentContext & FiremissionContext & TargetContext + >(context); + + const { setPanelState } = mfdState(context, panelStateId); + const { selectedTarget, setSelectedTarget } = useLazeTarget(context); + const { strikeMode } = useStrikeMode(context); + const { strikeDirection } = useStrikeDirection(context); + const { weaponSelected } = useWeaponSelectedState(context); + const { firemissionSelected } = useTargetFiremissionSelect(context); + const { targetOffset, setTargetOffset } = useTargetOffset( + context, + panelStateId + ); + + const { fmXOffsetValue } = useFiremissionXOffsetValue(context); + const { fmYOffsetValue } = useFiremissionYOffsetValue(context); + + const lazes = range(0, 5).map((x) => + x > data.targets_data.length ? undefined : data.targets_data[x] + ); + + const strikeConfigLabel = + strikeMode === 'weapon' + ? data.equipment_data.find((x) => x.mount_point === weaponSelected)?.name + : firemissionSelected !== undefined + ? data.firemission_data.find( + (x) => x.mission_tag === firemissionSelected.mission_tag + )?.name + : 'NONE'; + + const lazeIndex = lazes.findIndex((x) => x?.target_tag === selectedTarget); + const strikeReady = strikeMode !== undefined && lazeIndex !== -1; + + const targets = range(targetOffset, targetOffset + 5).map((x) => + lazeMapper(context, x) + ); + + const getLastName = () => { + const target = data.targets_data[data.targets_data.length - 1] ?? undefined; + const isDebug = target?.target_name.includes('debug'); + if (isDebug) { + return 'debug ' + target.target_name.split(' ')[3]; + } + const label = target?.target_name.split(' ')[0] ?? ''; + const squad = label[0] ?? undefined; + const number = label.split('-')[1] ?? undefined; + + return squad !== undefined && number !== undefined + ? `${squad}-${number}` + : target?.target_name; + }; + + if ( + selectedTarget && + data.targets_data.find((x) => `${x.target_tag}` === `${selectedTarget}`) === + undefined + ) { + setSelectedTarget(undefined); + } + + return ( + { + if (strikeMode === undefined) { + return; + } + if (strikeMode === 'firemission') { + act('firemission-execute', { + tag: firemissionSelected?.mission_tag, + direction: strikeDirection + ? directionLookup[strikeDirection] + : 1, + target_id: selectedTarget, + offset_x_value: fmXOffsetValue, + offset_y_value: fmYOffsetValue, + }); + } + if (strikeMode === 'weapon') { + act('fire-weapon', { eqp_tag: weaponSelected }); + } + }, + }, + {}, + {}, + {}, + { + children: targetOffset > 0 ? : undefined, + onClick: () => { + if (targetOffset > 0) { + setTargetOffset(targetOffset - 1); + } + }, + }, + ]} + bottomButtons={[ + { + children: 'EXIT', + onClick: () => setPanelState(''), + }, + {}, + {}, + {}, + { + children: + targetOffset < lazes.length ? ( + + ) : undefined, + onClick: () => { + if (targetOffset < lazes.length) { + setTargetOffset(targetOffset + 1); + } + }, + }, + ]} + leftButtons={leftButtonGenerator(context, panelStateId)} + rightButtons={targets}> + + + + + + + + + + + + + + + + + + + + +

Target Aquisition

+
+ +

Strike mode: {strikeMode?.toUpperCase() ?? 'NONE'}

+
+ +

Strike configuration {strikeConfigLabel}

+
+ +

+ Target selected:{' '} + {lazes.find((x) => x?.target_tag === selectedTarget) + ?.target_name ?? 'NONE'} +

+
+ +

Attack Vector {strikeDirection ?? 'NONE'}

+
+ +

+ Offset {fmXOffsetValue},{fmYOffsetValue} +

+
+ +

+ Guidance computer {strikeReady ? 'READY' : 'INCOMPLETE'} +

+
+
+
+ + + + + {data.targets_data.length === 0 && ( + + + NO TARGETS + + + )} + {data.targets_data.length > 0 && ( + + + SELECT + + + TARGETS + + + {Math.min(5, data.targets_data.length)} of{' '} + {data.targets_data.length} + + {data.targets_data.length > 0 && ( + <> + + LATEST + + + {getLastName()} + + + )} + + )} + + + + +
+
+
+ ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/WeaponPanel.tsx b/tgui/packages/tgui/interfaces/MfdPanels/WeaponPanel.tsx new file mode 100644 index 000000000000..090001aa3ac9 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/WeaponPanel.tsx @@ -0,0 +1,179 @@ +import { range } from 'common/collections'; +import { useBackend } from '../../backend'; +import { Box, Stack } from '../../components'; +import { DropshipEquipment } from '../DropshipWeaponsConsole'; +import { MfdProps, MfdPanel } from './MultifunctionDisplay'; +import { mfdState, useWeaponState } from './stateManagers'; +import { LazeTarget } from './types'; + +const EmptyWeaponPanel = (props, context) => { + return
Nothing Listed
; +}; +interface EquipmentContext { + equipment_data: Array; + targets_data: Array; +} + +const getLazeButtonProps = (context) => { + const { act, data } = useBackend(context); + const lazes = range(0, 5).map((x) => + x > data.targets_data.length ? undefined : data.targets_data[x] + ); + const get_laze = (index: number) => { + const laze = lazes.find((_, i) => i === index); + if (laze === undefined) { + return { + children: '', + onClick: () => act('set-camera', { equipment_id: null }), + }; + } + return { + children: laze?.target_name.split(' ')[0] ?? 'NONE', + onClick: laze + ? () => act('set-camera', { 'equipment_id': laze.target_tag }) + : undefined, + }; + }; + return [get_laze(0), get_laze(1), get_laze(2), get_laze(3), get_laze(4)]; +}; + +const WeaponPanel = (props: { equipment: DropshipEquipment }, context) => { + return ( + + + + + ACTIONS + + {false && ( + + )} + {false && ( + + )} + {false && ( + + )} + + {false && ( + + )} + {false && ( + + )} + + + + + + +

{props.equipment.name}

+
+ +

{props.equipment.ammo_name}

+
+ +

+ Ammo {props.equipment.ammo} / {props.equipment.max_ammo} +

+
+
+
+
+ + + + + SELECT + + + TARGETS + + + + + + + + + + +
+ ); +}; + +export const WeaponMfdPanel = (props: MfdProps, context) => { + const { setPanelState } = mfdState(context, props.panelStateId); + const { weaponState } = useWeaponState(context, props.panelStateId); + const { data, act } = useBackend(context); + const weap = data.equipment_data.find((x) => x.mount_point === weaponState); + + return ( + act('fire-weapon', { eqp_tag: weap?.eqp_tag }), + }, + ]} + bottomButtons={[ + { + children: 'EXIT', + onClick: () => setPanelState(''), + }, + {}, + ]} + topButtons={[ + { + children: 'EQUIP', + onClick: () => setPanelState('equipment'), + }, + ]} + rightButtons={getLazeButtonProps(context)}> + + {weap ? : } + + + ); +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/stateManagers.ts b/tgui/packages/tgui/interfaces/MfdPanels/stateManagers.ts new file mode 100644 index 000000000000..e639938eabf8 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/stateManagers.ts @@ -0,0 +1,109 @@ +import { useLocalState, useSharedState } from '../../backend'; + +export const useEquipmentState = (context, panelId: string) => { + const [data, set] = useSharedState( + context, + `${panelId}_equipmentstate`, + undefined + ); + return { + equipmentState: data, + setEquipmentState: set, + }; +}; + +export const fmState = (context, panelId: string) => { + const [data, set] = useLocalState( + context, + `${panelId}_selected_fm`, + undefined + ); + return { + selectedFm: data, + setSelectedFm: set, + }; +}; + +export const fmEditState = (context, panelId: string) => { + const [data, set] = useLocalState( + context, + `${panelId}_edit_fm`, + false + ); + return { + editFm: data, + setEditFm: set, + }; +}; + +export const fmWeaponEditState = (context, panelId: string) => { + const [data, set] = useLocalState( + context, + `${panelId}_edit_fm_weapon`, + undefined + ); + return { + editFmWeapon: data, + setEditFmWeapon: set, + }; +}; + +export const mfdState = (context, panelId: string) => { + const [data, set] = useSharedState( + context, + `${panelId}_panelstate`, + '' + ); + return { + panelState: data, + setPanelState: set, + }; +}; + +export const useWeaponState = (context, panelId: string) => { + const [data, set] = useSharedState( + context, + `${panelId}_weaponstate`, + undefined + ); + return { + weaponState: data, + setWeaponState: set, + }; +}; + +export const useFiremissionXOffsetValue = (context) => { + const [data, set] = useSharedState( + context, + 'firemission-x-offset-value', + 0 + ); + return { + fmXOffsetValue: data, + setFmXOffsetValue: set, + }; +}; + +export const useFiremissionYOffsetValue = (context) => { + const [data, set] = useSharedState( + context, + 'firemission-y-offset-value', + 0 + ); + return { + fmYOffsetValue: data, + setFmYOffsetValue: set, + }; +}; + +export const useLazeTarget = (context) => { + const [data, set] = useSharedState( + context, + 'laze-target', + undefined + ); + return { + selectedTarget: data, + setSelectedTarget: set, + }; +}; diff --git a/tgui/packages/tgui/interfaces/MfdPanels/types.ts b/tgui/packages/tgui/interfaces/MfdPanels/types.ts new file mode 100644 index 000000000000..78e7c3314b30 --- /dev/null +++ b/tgui/packages/tgui/interfaces/MfdPanels/types.ts @@ -0,0 +1,112 @@ +import { InfernoNode } from 'inferno'; +import { DropshipEquipment } from '../DropshipWeaponsConsole'; + +export interface ButtonProps { + children?: InfernoNode; + onClick?: () => void; +} + +export type LazeTarget = { + target_name: string; + target_tag: number; +}; + +export type TargetContext = { + targets_data: Array; +}; + +export type FultonProps = { + fulton_targets: Array; + equipment_data: Array; +}; + +export type MedevacTargets = { + area: string; + occupant: string; + ref: string; + triage_card?: string; + damage?: { + hp: number; + brute: number; + oxy: number; + tox: number; + fire: number; + undefib: number; + }; +}; + +export type CameraProps = { + camera_map_ref?: string; +}; + +export type EquipmentContext = { + equipment_data: Array; +}; + +export type MedevacContext = { + medevac_targets: Array; + equipment_data: Array; +}; + +export type FiremissionContext = { + firemission_data: Array; +}; + +export type SentrySpec = { + rounds?: number; + max_rounds?: number; + name: string; + area: string; + active: 0 | 1; + index: number; + engaged?: number; + nickname: string; + health: number; + health_max: number; + kills: number; + iff_status: string[]; + camera_available: number; + deployed: number; +}; + +export type SpotlightSpec = { + name: string; +}; + +export type MGSpec = { + name: string; + health: number; + health_max: number; + rounds: number; + max_rounds: number; + deployed: 0 | 1; +}; + +export type CasFiremissionStage = { + weapon: number; + offsets: Array; +}; + +export type CasFiremission = { + name: string; + mission_length: number; + records: Array; + mission_tag: number; +}; + +export type MapProps = { + tactical_map_ref: string; +}; + +export const dirMap = (dir) => { + switch (dir) { + case 'NORTH': + return 1; + case 'SOUTH': + return 2; + case 'EAST': + return 4; + case 'WEST': + return 8; + } +}; diff --git a/tgui/packages/tgui/interfaces/common/Dpad.tsx b/tgui/packages/tgui/interfaces/common/Dpad.tsx new file mode 100644 index 000000000000..faa2264eb452 --- /dev/null +++ b/tgui/packages/tgui/interfaces/common/Dpad.tsx @@ -0,0 +1,113 @@ +import { useBackend } from '../../backend'; +import { Box, Button, Stack } from '../../components'; +import { useFiremissionXOffsetValue, useFiremissionYOffsetValue, useLazeTarget } from '../MfdPanels/stateManagers'; + +const SvgButton = ( + props: { transform?: string; onClick?: (e: any) => void }, + context +) => { + return ( + + + + + + + ); +}; + +export const Dpad = (props, context) => { + const { act } = useBackend(context); + const { selectedTarget } = useLazeTarget(context); + + const { fmXOffsetValue, setFmXOffsetValue } = + useFiremissionXOffsetValue(context); + const { fmYOffsetValue, setFmYOffsetValue } = + useFiremissionYOffsetValue(context); + + const min_value = -12; + const max_value = 12; + const updateOffset = (e, xValue, yValue) => { + if (xValue < min_value || yValue < min_value) { + return; + } + if (xValue > max_value || yValue > max_value) { + return; + } + setFmXOffsetValue(xValue); + setFmYOffsetValue(yValue); + act('firemission-dual-offset-camera', { + 'target_id': selectedTarget, + 'x_offset_value': xValue, + 'y_offset_value': yValue, + }); + }; + + return ( + + + + + + + + updateOffset(e, fmXOffsetValue - 1, fmYOffsetValue) + } + /> + + + + + + + + + updateOffset(e, fmXOffsetValue, fmYOffsetValue + 1) + } + /> + + +