Adds a pointer to the extraction location for Contractor uplinks (#16497)

* Contractor extraction point locator V1

* `update_static_data()` revert
This commit is contained in:
SabreML
2021-08-12 13:26:58 +01:00
committed by GitHub
parent 682c6a1f28
commit 269afcae07
8 changed files with 74 additions and 35 deletions
+2
View File
@@ -130,6 +130,8 @@
#define SOUTH_OF_TURF(T) locate(T.x, T.y - 1, T.z)
#define WEST_OF_TURF(T) locate(T.x - 1, T.y, T.z)
#define ATOM_COORDS(A) list(A.x, A.y, A.z)
#define MIN_SUPPLIED_LAW_NUMBER 15
#define MAX_SUPPLIED_LAW_NUMBER 50
+1 -1
View File
@@ -119,7 +119,7 @@ SUBSYSTEM_DEF(tgui)
* Close all UIs attached to src_object.
* Returns the number of UIs closed.
*
* * datum/src_objectThe object/datum which owns the UIs.
* * datum/src_object - The object/datum which owns the UIs.
*/
/datum/controller/subsystem/tgui/proc/close_uis(datum/src_object)
if(!src_object.unique_datum_id) // First check if the datum has an UID set
@@ -1,5 +1,4 @@
/datum/contractor_hub/ui_act(action, list/params)
/datum/contractor_hub/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
if(..())
return
@@ -44,7 +43,6 @@
if(!ui)
ui = new(user, src, ui_key, "Contractor", "Syndicate Contractor Uplink", 500, 600, master_ui, state)
ui.open()
ui.set_autoupdate(FALSE)
/datum/contractor_hub/ui_data(mob/user)
var/list/data = list()
@@ -67,6 +65,7 @@
switch(page)
if(HUB_PAGE_CONTRACTS)
var/contract_target
var/list/contracts_out = list()
data["contracts"] = contracts_out
for(var/c in contracts)
@@ -99,15 +98,26 @@
contract_data["dead_extraction"] = C.dead_extraction
if(CONTRACT_STATUS_FAILED)
contract_data["fail_reason"] = C.fail_reason
if(C.contract.extraction_zone)
contract_target = C.contract.target?.current
var/area/A = get_area(user)
contract_data["objective"] = list(
extraction_zone = C.contract.extraction_zone.map_name,
reward_tc = C.reward_tc[C.chosen_difficulty],
reward_credits = C.reward_credits,
extraction_name = C.contract.extraction_zone.map_name,
locs = list(
user_area_id = A.uid,
user_coords = ATOM_COORDS(user),
target_area_id = C.contract.extraction_zone.uid,
target_coords = ATOM_COORDS(C.contract.extraction_zone),
),
rewards = list(tc = C.reward_tc[C.chosen_difficulty], credits = C.reward_credits)
)
contracts_out += list(contract_data)
data["can_extract"] = current_contract?.contract.can_start_extraction_process(ui_host(), usr) || FALSE
data["can_extract"] = FALSE
if(contract_target)
data["can_extract"] = current_contract?.contract.can_start_extraction_process(user, contract_target)
if(HUB_PAGE_SHOP)
var/list/buyables = list()
for(var/p in purchases)
+3 -5
View File
@@ -1,7 +1,6 @@
GLOBAL_LIST_EMPTY(GPS_list)
#define EMP_DISABLE_TIME 30 SECONDS
#define POS_VECTOR(A) list(A.x, A.y, A.z)
/**
* # GPS
@@ -83,11 +82,11 @@ GLOBAL_LIST_EMPTY(GPS_list)
return data
var/turf/T = get_turf(src)
data["area"] = get_area_name(src, TRUE)
data["position"] = POS_VECTOR(T)
data["position"] = ATOM_COORDS(T)
// Saved location
if(locked_location)
data["saved"] = POS_VECTOR(locked_location)
data["saved"] = ATOM_COORDS(locked_location)
else
data["saved"] = null
@@ -104,7 +103,7 @@ GLOBAL_LIST_EMPTY(GPS_list)
var/list/signal = list("tag" = G.gpstag, "area" = null, "position" = null)
if(!G.emped)
signal["area"] = get_area_name(G, TRUE)
signal["position"] = POS_VECTOR(GT)
signal["position"] = ATOM_COORDS(GT)
signals += list(signal)
data["signals"] = signals
@@ -219,4 +218,3 @@ GLOBAL_LIST_EMPTY(GPS_list)
. = ..()
#undef EMP_DISABLE_TIME
#undef POS_VECTOR
+7
View File
@@ -82,3 +82,10 @@ export const keyOfMatchingRange = (value, ranges) => {
}
}
};
/**
* Converts a value in radians to degrees.
*/
export const rad2deg = rad => {
return rad * (180 / Math.PI);
};
+41 -19
View File
@@ -1,3 +1,4 @@
import { rad2deg } from 'common/math';
import { Component, Fragment } from 'inferno';
import { useBackend, useLocalState } from '../backend';
import { Box, Button, Flex, Icon, LabeledList, Modal, Section, Tabs } from '../components';
@@ -260,7 +261,7 @@ const Contracts = (properties, context) => {
)}
</Box>
)}>
<Flex width="100%">
<Flex>
<Flex.Item grow="2" mr="0.5rem">
{contract.fluff_message}
{!!contract.completed_time && (
@@ -284,28 +285,26 @@ const Contracts = (properties, context) => {
</Box>
)}
</Flex.Item>
<Flex.Item grow="1" flexBasis="100%">
<Box mb="0.5rem" color="label">
Extraction Zone:
</Box>
<Flex.Item flexBasis="100%">
<Flex mb="0.5rem" color="label">
Extraction Zone:&nbsp;
{areaArrow(contract)}
</Flex>
{contract.difficulties?.map((difficulty, key) => (
<Fragment>
<Button.Confirm
disabled={!!contract_active}
content={difficulty.name + " (" + difficulty.reward + " TC)"}
onClick={() => act("activate", {
uid: contract.uid,
difficulty: key + 1,
})}
/>
<br />
</Fragment>
<Button.Confirm
disabled={!!contract_active}
content={difficulty.name + " (" + difficulty.reward + " TC)"}
onClick={() => act("activate", {
uid: contract.uid,
difficulty: key + 1,
})}
/>
))}
{!!contract.objective && (
<Box color="white" bold>
{contract.objective.extraction_zone}<br />
({(contract.objective.reward_tc || 0) + " TC"},&nbsp;
{(contract.objective.reward_credits || 0) + " Credits"})
{contract.objective.extraction_name}<br />
({(contract.objective.rewards.tc || 0) + " TC"},&nbsp;
{(contract.objective.rewards.credits || 0) + " Credits"})
</Box>
)}
</Flex.Item>
@@ -316,6 +315,29 @@ const Contracts = (properties, context) => {
);
};
const areaArrow = contract => {
if (!contract.objective || (contract.status > 1)) {
return;
} else {
const current_area_id = contract.objective.locs.user_area_id;
const c_coords = contract.objective.locs.user_coords;
const target_area_id = contract.objective.locs.target_area_id;
const t_coords = contract.objective.locs.target_coords;
const same_area = (current_area_id === target_area_id);
return (
<Flex.Item>
<Icon
name={same_area ? "dot-circle-o" : "arrow-alt-circle-right-o"}
color={same_area ? "green" : "yellow"}
rotation={same_area ? null : -rad2deg(Math.atan2(t_coords[1] - c_coords[1], t_coords[0] - c_coords[0]))}
lineHeight={same_area ? null : "0.85"} // Needed because it jumps upwards otherwise
size="1.5"
/>
</Flex.Item>
);
}
};
const Hub = (properties, context) => {
const { act, data } = useBackend(context);
const {
+1 -1
View File
@@ -1,3 +1,4 @@
import { rad2deg } from 'common/math';
import { Fragment } from 'inferno';
import { useBackend, useLocalState } from '../backend';
import { Box, Button, Flex, Icon, Input, LabeledList, Section, Table } from '../components';
@@ -5,7 +6,6 @@ import { Window } from '../layouts';
const vectorText = vector => vector ? "(" + vector.join(", ") + ")" : "ERROR";
const rad2deg = rad => rad * (180 / Math.PI);
const distanceToPoint = (from, to) => {
if (!from || !to) {
return;
File diff suppressed because one or more lines are too long