display warning icons for missiles
This commit is contained in:
parent
722579161e
commit
7b84761fca
@ -128,16 +128,22 @@ const assimilator = ({
|
||||
let startingX = section.x;
|
||||
let startingY = section.y;
|
||||
const { data } = message;
|
||||
if (Object.prototype.hasOwnProperty.call(data, 'target')) {
|
||||
|
||||
// @ts-ignore
|
||||
const { missileLocation, target } = data;
|
||||
// account for missiles and targets
|
||||
if (missileLocation || target) {
|
||||
const { x: locationX, y: locationY } =
|
||||
missileLocation || target.location;
|
||||
|
||||
if (
|
||||
// @ts-ignore
|
||||
message.data.target.location.x + widget.w <=
|
||||
section.x + section.w && // @ts-ignore
|
||||
message.data.target.location.y + widget.h <= section.y + section.h
|
||||
locationX + widget.w <= section.x + section.w && // @ts-ignore
|
||||
locationY + widget.h <= section.y + section.h
|
||||
) {
|
||||
// @ts-ignore //use the coords given in message if they are within the section and could possibly house the widget
|
||||
startingX = message.data.target.location.x; // @ts-ignore
|
||||
startingY = message.data.target.location.y;
|
||||
startingX = locationX; // @ts-ignore
|
||||
startingY = locationY;
|
||||
}
|
||||
}
|
||||
for (let x = startingX; x < section.x + section.w - widget.w; x++) {
|
||||
|
@ -144,8 +144,7 @@ const acaFuelLowMessageHigh = (message: Message) => {
|
||||
const missileToOwnshipDetectedMessageHigh = (
|
||||
message: MissileToOwnshipDetected,
|
||||
) => {
|
||||
const elements: Element[] = [];
|
||||
elements.push(
|
||||
const pearceScreenElements: Element[] = [
|
||||
lpdHelper.generateMissileIncomingElement(
|
||||
lpdHelper.generateBaseElement(
|
||||
uuid(),
|
||||
@ -161,7 +160,41 @@ const missileToOwnshipDetectedMessageHigh = (
|
||||
DANGER_ICON,
|
||||
),
|
||||
),
|
||||
);
|
||||
];
|
||||
|
||||
const minimapWidgetId1 = uuid();
|
||||
const minimapElements: Element[] = [
|
||||
{
|
||||
id: uuid(),
|
||||
modality: 'visual',
|
||||
type: 'icon',
|
||||
h: 50,
|
||||
w: 50,
|
||||
widgetId: minimapWidgetId1,
|
||||
src: mapTargetTypeToWarningIcon('missile'),
|
||||
} satisfies IconElement,
|
||||
];
|
||||
|
||||
console.log('message', message);
|
||||
|
||||
const minimapWidgets: Widget[] = [
|
||||
{
|
||||
id: minimapWidgetId1, // this should be something static?
|
||||
sectionType: 'minimap',
|
||||
type: 'map-warning',
|
||||
x: message.data.missileLocation.x,
|
||||
y: message.data.missileLocation.y,
|
||||
w: 50,
|
||||
h: 50,
|
||||
screen: '/minimap',
|
||||
canOverlap: true,
|
||||
useElementLocation: false,
|
||||
maxAmount: 10,
|
||||
|
||||
elements: minimapElements,
|
||||
} satisfies MapWarningWidget,
|
||||
];
|
||||
|
||||
return {
|
||||
sections: [],
|
||||
possibleClusters: [
|
||||
@ -178,9 +211,10 @@ const missileToOwnshipDetectedMessageHigh = (
|
||||
false,
|
||||
true,
|
||||
1,
|
||||
[...elements],
|
||||
[...pearceScreenElements],
|
||||
),
|
||||
),
|
||||
...minimapWidgets,
|
||||
]),
|
||||
],
|
||||
};
|
||||
@ -299,8 +333,12 @@ const highLPD = (message: Message) => {
|
||||
y: 0,
|
||||
},
|
||||
},
|
||||
missileLocation: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
},
|
||||
} as RequestApprovalToAttack;
|
||||
};
|
||||
|
||||
const messageKinds = [
|
||||
//all message kinds, so we can get all widgets
|
||||
|
@ -138,6 +138,37 @@ const missileToOwnshipDetectedMessageLow = (
|
||||
) => {
|
||||
const elementId = uuid();
|
||||
|
||||
const minimapWidgetId1 = uuid();
|
||||
const minimapElements: Element[] = [
|
||||
{
|
||||
id: uuid(),
|
||||
modality: 'visual',
|
||||
type: 'icon',
|
||||
h: 50,
|
||||
w: 50,
|
||||
widgetId: minimapWidgetId1,
|
||||
src: mapTargetTypeToWarningIcon('missile'),
|
||||
} satisfies IconElement,
|
||||
];
|
||||
|
||||
const minimapWidgets: Widget[] = [
|
||||
{
|
||||
id: minimapWidgetId1, // this should be something static?
|
||||
sectionType: 'minimap',
|
||||
type: 'map-warning',
|
||||
x: message.data.missileLocation.x,
|
||||
y: message.data.missileLocation.y,
|
||||
w: 50,
|
||||
h: 50,
|
||||
screen: '/minimap',
|
||||
canOverlap: true,
|
||||
useElementLocation: false,
|
||||
maxAmount: 10,
|
||||
|
||||
elements: minimapElements,
|
||||
} satisfies MapWarningWidget,
|
||||
];
|
||||
|
||||
const pearceScreenElements: Element[] = [
|
||||
lpdHelper.generateMissileIncomingElement(
|
||||
lpdHelper.generateBaseElement(
|
||||
@ -174,6 +205,7 @@ const missileToOwnshipDetectedMessageLow = (
|
||||
[...pearceScreenElements],
|
||||
),
|
||||
),
|
||||
...minimapWidgets,
|
||||
]),
|
||||
],
|
||||
};
|
||||
@ -289,8 +321,12 @@ const lowLPD = (message: Message) => {
|
||||
y: 0,
|
||||
},
|
||||
},
|
||||
missileLocation: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
},
|
||||
} as RequestApprovalToAttack;
|
||||
};
|
||||
|
||||
const messageKinds = [
|
||||
//all message kinds, so we can get all widgets
|
||||
|
@ -136,8 +136,7 @@ const acaFuelLowMessageMedium = (message: Message) => {
|
||||
const missileToOwnshipDetectedMessageMedium = (
|
||||
message: MissileToOwnshipDetected,
|
||||
) => {
|
||||
const elements: Element[] = [];
|
||||
elements.push(
|
||||
const pearceScreenElements: Element[] = [
|
||||
lpdHelper.generateMissileIncomingElement(
|
||||
lpdHelper.generateBaseElement(
|
||||
uuid(),
|
||||
@ -152,7 +151,39 @@ const missileToOwnshipDetectedMessageMedium = (
|
||||
DANGER_ICON,
|
||||
),
|
||||
),
|
||||
);
|
||||
];
|
||||
|
||||
const minimapWidgetId1 = uuid();
|
||||
const minimapElements: Element[] = [
|
||||
{
|
||||
id: uuid(),
|
||||
modality: 'visual',
|
||||
type: 'icon',
|
||||
h: 50,
|
||||
w: 50,
|
||||
widgetId: minimapWidgetId1,
|
||||
src: mapTargetTypeToWarningIcon('missile'),
|
||||
} satisfies IconElement,
|
||||
];
|
||||
|
||||
const minimapWidgets: Widget[] = [
|
||||
{
|
||||
id: minimapWidgetId1, // this should be something static?
|
||||
sectionType: 'minimap',
|
||||
type: 'map-warning',
|
||||
x: message.data.missileLocation.x,
|
||||
y: message.data.missileLocation.y,
|
||||
w: 50,
|
||||
h: 50,
|
||||
screen: '/minimap',
|
||||
canOverlap: true,
|
||||
useElementLocation: false,
|
||||
maxAmount: 10,
|
||||
|
||||
elements: minimapElements,
|
||||
} satisfies MapWarningWidget,
|
||||
];
|
||||
|
||||
return {
|
||||
sections: [],
|
||||
possibleClusters: [
|
||||
@ -169,9 +200,10 @@ const missileToOwnshipDetectedMessageMedium = (
|
||||
false,
|
||||
true,
|
||||
1,
|
||||
[...elements],
|
||||
[...pearceScreenElements],
|
||||
),
|
||||
),
|
||||
...minimapWidgets,
|
||||
]),
|
||||
],
|
||||
};
|
||||
@ -287,8 +319,12 @@ const mediumLPD = (message: Message) => {
|
||||
y: 0,
|
||||
},
|
||||
},
|
||||
missileLocation: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
},
|
||||
} as RequestApprovalToAttack;
|
||||
};
|
||||
|
||||
const messageKinds = [
|
||||
//all message kinds, so we can get all widgets
|
||||
|
@ -2,11 +2,14 @@ import { type Target } from 'src/types/schema-types';
|
||||
import AirDefenseSmReg from 'src/assets/icons/threats/airdefense-sm-reg.svg';
|
||||
import ArtillerySmReg from 'src/assets/icons/threats/artillery-sm-reg.svg';
|
||||
import RadarSmReg from 'src/assets/icons/threats/radar-sm-reg.svg';
|
||||
import MissileLgEmph from 'src/assets/icons/threats/missile-lg-emph.svg';
|
||||
|
||||
// also pass in stress level to determine size of icon?
|
||||
// or just pass in a size (sm, lg)
|
||||
// also a boolean for whether we want emphasized version of the icon?
|
||||
export const mapTargetTypeToWarningIcon = (targetType: Target['type']) => {
|
||||
export const mapTargetTypeToWarningIcon = (
|
||||
targetType: Target['type'] | 'missile',
|
||||
) => {
|
||||
switch (targetType) {
|
||||
case 'airDefense':
|
||||
return AirDefenseSmReg;
|
||||
@ -14,6 +17,8 @@ export const mapTargetTypeToWarningIcon = (targetType: Target['type']) => {
|
||||
return ArtillerySmReg;
|
||||
case 'radar':
|
||||
return RadarSmReg;
|
||||
case 'missile':
|
||||
return MissileLgEmph;
|
||||
default:
|
||||
return AirDefenseSmReg;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user