Skip to content

Commit 99eae43

Browse files
committed
Show the attack range of opposing units with the opposite direction applied so that movement and attack can overlap and still be visible to the player.
GitOrigin-RevId: c76593cb777fc418b0bab02d1975d68ed381cdfb
1 parent 8ac8126 commit 99eae43

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

hera/GameMap.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,7 @@ export default class GameMap extends Component<Props, State> {
18731873
currentViewer={currentViewer}
18741874
getLayer={getLayer}
18751875
map={map}
1876+
opposite
18761877
radius={additionalRadius}
18771878
selectedPosition={selectedPosition}
18781879
selectedUnit={selectedUnit}

hera/Radius.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const Item = memo(function Item({
4545
dim,
4646
fields,
4747
getLayer,
48+
opposite,
4849
position,
4950
size,
5051
type,
@@ -53,6 +54,7 @@ const Item = memo(function Item({
5354
dim?: boolean | null;
5455
fields: ReadonlyMap<Vector, RadiusItem>;
5556
getLayer: GetLayerFunction;
57+
opposite: boolean | undefined;
5658
position: Vector;
5759
size: number;
5860
type: RadiusType;
@@ -106,6 +108,7 @@ const Item = memo(function Item({
106108
}}
107109
className={cx(
108110
itemStyle,
111+
opposite && oppositeMaskStyle,
109112
...borderStyles,
110113
dim && dimStyle,
111114
type === RadiusType.Attack &&
@@ -210,6 +213,7 @@ export default memo(function Radius({
210213
currentViewer,
211214
getLayer,
212215
map,
216+
opposite,
213217
radius: { dim, fields, path, type },
214218
selectedPosition,
215219
selectedUnit,
@@ -219,6 +223,7 @@ export default memo(function Radius({
219223
currentViewer: PlayerID | null;
220224
getLayer: GetLayerFunction;
221225
map: MapData;
226+
opposite?: boolean;
222227
radius: RadiusInfo;
223228
selectedPosition?: Vector | null;
224229
selectedUnit?: Unit | null;
@@ -274,6 +279,7 @@ export default memo(function Radius({
274279
)
275280
}
276281
key={'r' + String(vector)}
282+
opposite={opposite}
277283
position={vector}
278284
size={size}
279285
type={type}
@@ -359,6 +365,16 @@ const itemStyle = css`
359365
transform: translate3d(${vars.apply('x')}, ${vars.apply('y')}, 0);
360366
`;
361367

368+
const oppositeMaskStyle = css`
369+
mask: repeating-linear-gradient(
370+
to top right,
371+
black,
372+
black 1px,
373+
${vars.apply('background-light')} 0%,
374+
${vars.apply('background-light')} 2.13px
375+
);
376+
`;
377+
362378
const radialMaskStyle = css`
363379
mask: repeating-radial-gradient(
364380
circle at 50%,

hera/behavior/Base.tsx

+8-11
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,15 @@ export default class Base extends AbstractSelectBehavior {
124124

125125
const isLongRange =
126126
entity.info.isLongRange() && !entity.info.canAct(player);
127-
const attackFilter = isLongRange
128-
? Boolean
129-
: ([vector]: [Vector, unknown]) => !fields?.has(vector);
130-
const moveFilter = isLongRange
131-
? ([vector]: [Vector, unknown]) => !additionalFields?.has(vector)
132-
: Boolean;
133-
134127
const additionalRadius = additionalFields?.size
135128
? {
136-
fields: new Map([...additionalFields].filter(attackFilter)),
129+
fields: new Map(
130+
[...additionalFields].filter(
131+
isLongRange
132+
? Boolean
133+
: ([vector]: [Vector, unknown]) => !fields?.has(vector),
134+
),
135+
),
137136
path: null,
138137
type: RadiusType.Attack,
139138
}
@@ -144,9 +143,7 @@ export default class Base extends AbstractSelectBehavior {
144143
behavior: new Move(),
145144
position: vector,
146145
radius: {
147-
fields: new Map(
148-
fields ? [...fields].filter(moveFilter) : undefined,
149-
),
146+
fields: new Map(fields),
150147
path: null,
151148
type: RadiusType.Move,
152149
},

0 commit comments

Comments
 (0)