Skip to content

Commit

Permalink
Allow for secondary action styles to be shown on top of units.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 380aea763c54a8d4a470b1c01c3ba698a15713f8
  • Loading branch information
cpojer committed Dec 3, 2024
1 parent bb33cfa commit dcd0f7a
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions hera/Unit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ const getAmmoStyle = (unit: Unit) => {
const Action = ({
actionStyle,
hide,
position,
rescuer,
unit,
}: {
actionStyle: ActionStyle | null;
hide: boolean;
position?: 'secondary';
rescuer: PlayerID | null;
unit: Unit;
}) => {
Expand All @@ -134,6 +136,7 @@ const Action = ({
absoluteStyle,
baseIconStyle,
statusStyle,
position === 'secondary' ? secondaryStyle : null,
className,
hide && hideStyle,
)}
Expand All @@ -160,16 +163,20 @@ const Status = ({
fuelStyle,
hide,
rescuer,
secondaryActionStyle,
unit,
}: {
actionStyle: ActionStyle | null;
ammoStyle: AmmoStyle | null;
fuelStyle: FuelStyle | null;
hide: boolean;
rescuer: PlayerID | null;
secondaryActionStyle: ActionStyle | null;
unit: Unit;
}) => {
const hasOne = !!(fuelStyle || ammoStyle);
const hasSecondaryAction =
secondaryActionStyle && secondaryActionStyle !== actionStyle;
return (
<>
<Action
Expand All @@ -178,6 +185,15 @@ const Status = ({
rescuer={rescuer}
unit={unit}
/>
{hasSecondaryAction && (
<Action
actionStyle={secondaryActionStyle}
hide={hide}
position="secondary"
rescuer={rescuer}
unit={unit}
/>
)}
{unit.health ? (
<div
className={cx(
Expand Down Expand Up @@ -873,15 +889,15 @@ export default function UnitTile({
};

const hide = !!animation;
const secondaryActionStyle =
!isCompleted && unit.hasMoved() ? ActionStyle.Moved : null;
const actionStyle = unit.isTransportingUnits()
? ActionStyle.Transport
: unit.isCapturing()
? ActionStyle.Capture
: unit.isBeingRescued()
? ActionStyle.Rescue
: !isCompleted && unit.hasMoved()
? ActionStyle.Moved
: null;
: secondaryActionStyle;
const fuelStyle = getFuelStyle(unit);
const ammoStyle = getAmmoStyle(unit);
const completedStyles = cx(
Expand Down Expand Up @@ -958,6 +974,7 @@ export default function UnitTile({
fuelStyle={fuelStyle}
hide={hide}
rescuer={actionStyle === ActionStyle.Rescue ? unit.getRescuer() : null}
secondaryActionStyle={secondaryActionStyle}
unit={unit}
/>
<Health
Expand Down Expand Up @@ -1254,6 +1271,10 @@ const statusStyle = css`
bottom: -1px;
`;

const secondaryStyle = css`
transform: translate3d(0, -100%, 0);
`;

const captureStyle = css`
bottom: 0px;
`;
Expand Down

0 comments on commit dcd0f7a

Please sign in to comment.