Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | import { SpriteAnimationType } from "shared/lib/entities/entitiesTypes"; import l10n from "shared/lib/lang/l10n"; import { filterAnimationsBySpriteType, AnimationType, } from "shared/lib/sprites/helpers"; export const getAnimationNameForType = (type: AnimationType) => { const animationNameLookup: Record<AnimationType, string> = { idle: l10n("FIELD_IDLE"), moving: l10n("FIELD_MOVING"), idleLeft: l10n("FIELD_IDLE_DIR", { direction: l10n("FIELD_DIRECTION_LEFT"), }), idleRight: l10n("FIELD_IDLE_DIR", { direction: l10n("FIELD_DIRECTION_RIGHT"), }), idleUp: l10n("FIELD_IDLE_DIR", { direction: l10n("FIELD_DIRECTION_UP") }), idleDown: l10n("FIELD_IDLE_DIR", { direction: l10n("FIELD_DIRECTION_DOWN"), }), movingLeft: l10n("FIELD_MOVING_DIR", { direction: l10n("FIELD_DIRECTION_LEFT"), }), movingRight: l10n("FIELD_MOVING_DIR", { direction: l10n("FIELD_DIRECTION_RIGHT"), }), movingUp: l10n("FIELD_MOVING_DIR", { direction: l10n("FIELD_DIRECTION_UP"), }), movingDown: l10n("FIELD_MOVING_DIR", { direction: l10n("FIELD_DIRECTION_DOWN"), }), jumpingLeft: l10n("FIELD_JUMPING_DIR", { direction: l10n("FIELD_DIRECTION_LEFT"), }), jumpingRight: l10n("FIELD_JUMPING_DIR", { direction: l10n("FIELD_DIRECTION_RIGHT"), }), climbing: l10n("FIELD_CLIMBING"), hover: l10n("FIELD_HOVER"), }; return animationNameLookup[type]; }; export const getAnimationNameByIndex = ( type: SpriteAnimationType, flipLeft: boolean, animationIndex: number ) => { Iif (type === "fixed" || type === "fixed_movement") { const fixedAnimationNames = [l10n("FIELD_IDLE"), l10n("FIELD_MOVING")]; return fixedAnimationNames[animationIndex]; } Iif (type === "platform_player") { const platformAnimationNames = [ l10n("FIELD_IDLE_DIR", { direction: l10n("FIELD_DIRECTION_RIGHT") }), l10n("FIELD_IDLE_DIR", { direction: l10n("FIELD_DIRECTION_LEFT") }), l10n("FIELD_JUMPING_DIR", { direction: l10n("FIELD_DIRECTION_RIGHT") }), l10n("FIELD_JUMPING_DIR", { direction: l10n("FIELD_DIRECTION_LEFT") }), l10n("FIELD_MOVING_DIR", { direction: l10n("FIELD_DIRECTION_RIGHT") }), l10n("FIELD_MOVING_DIR", { direction: l10n("FIELD_DIRECTION_LEFT") }), l10n("FIELD_CLIMBING"), ]; return filterAnimationsBySpriteType(platformAnimationNames, type, flipLeft)[ animationIndex ]; } Iif (type === "multi") { const multiAnimationNames = [ l10n("FIELD_DIRECTION_RIGHT"), l10n("FIELD_DIRECTION_LEFT"), l10n("FIELD_DIRECTION_UP"), l10n("FIELD_DIRECTION_DOWN"), ]; return filterAnimationsBySpriteType(multiAnimationNames, type, flipLeft)[ animationIndex ]; } const animationNames = [ l10n("FIELD_IDLE_DIR", { direction: l10n("FIELD_DIRECTION_RIGHT") }), l10n("FIELD_IDLE_DIR", { direction: l10n("FIELD_DIRECTION_LEFT") }), l10n("FIELD_IDLE_DIR", { direction: l10n("FIELD_DIRECTION_UP") }), l10n("FIELD_IDLE_DIR", { direction: l10n("FIELD_DIRECTION_DOWN") }), l10n("FIELD_MOVING_DIR", { direction: l10n("FIELD_DIRECTION_RIGHT") }), l10n("FIELD_MOVING_DIR", { direction: l10n("FIELD_DIRECTION_LEFT") }), l10n("FIELD_MOVING_DIR", { direction: l10n("FIELD_DIRECTION_UP") }), l10n("FIELD_MOVING_DIR", { direction: l10n("FIELD_DIRECTION_DOWN") }), ]; return filterAnimationsBySpriteType(animationNames, type, flipLeft)[ animationIndex ]; }; export const getAnimationNameById = ( type: SpriteAnimationType, flipLeft: boolean, selectedId: string, animationIds: string[] ) => { const filteredIds = filterAnimationsBySpriteType(animationIds, type, flipLeft) || []; const animationIndex = filteredIds.indexOf(selectedId); return getAnimationNameByIndex(type, flipLeft, animationIndex); }; |