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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | import type { BGAOpacityTimelines } from '@be-music/chart-model';
/**
* What the shared playfield's passes (`view/shared/playfield/*`) read and write: the layers and pools they draw into,
* the skin's answers ({@link PlayfieldSkin}), the view's own drawing around them ({@link PlayChrome}) and its caches,
* and the running play as `play` ({@link PlayfieldRuntime}: the lanes, the notes and their scroll, the lane effects and
* bombs). A play view passes itself.
*/
import type { BGAFeed } from '../../../media/bga-camera.ts';
import type { ResolvedChart, TimingResolver, ChartPlayVariant } from '@be-music/chart-model';
import type { BeMusicJSON } from '@be-music/chart-source';
import type { ScrollDistanceMapperLike, TimedLandmineNote, TimedPlayableNote } from '@be-music/player-engine/display';
import type { PlayerGaugeSummary, PlayerUIFramePayload } from '@be-music/player-engine/signals';
import type { JudgmentKind, ScoreSummary } from '@be-music/player-engine/ruleset';
import type { HiSpeedTransition, LibraryChart, PlayState } from '@be-music/player-scene-model';
import type { BeMusicJudgeWindows, BeMusicLaneKind, BeMusicLongNote } from '@be-music/player-skin-sdk';
import type { Graphics, Text, Texture } from 'pixi.js';
import type { AudioAnalyzer, AudioFeatures } from '../../../runtime/audio-analysis.ts';
import type { BGACue, NonstopStageBGATimeline } from '../../../chart/bga-timeline.ts';
import type { PlayTempoRange } from '../../../session/play/tempo-range.ts';
import type { PlaySessionOptions } from '../../../session/play/play-options.ts';
import type { LongNoteTracker } from '../../../session/play/long-note-tracker.ts';
import type { GoneDrawObjects } from '../../../chart/note-draw-window.ts';
import type { ChildPool } from '../../../stage/pixi-utils.ts';
import type { BeMusicGameplayBinding } from '../../../skin/be-music/binding.ts';
import type { BeMusicJudgmentKind, BeMusicLaneCover } from '../../../skin/be-music/types.ts';
import type { LaneGeometryContext } from '../../built-in/play-chrome.ts';
import type { PlayfieldLaneRect, PlayfieldSkin } from '../../types.ts';
import type { SideLaneRun } from './measure-line-runs.ts';
import type { GhostLaneOverlay } from './ghost-lanes.ts';
/**
* View-side runtime note alias. Used to keep `this.notes` typed even though the view no longer extends
* `TimedPlayableNote` with extra renderer state — judge status is now tracked through the same `judged` flag
* the engine mutates on the **shared** instance handed in via `engineOptions.preparedChart`. See
* `PlayerOptions.preparedChart` for the design rationale; the alias stays in case future renderer-only state
* needs to attach back here.
*/
export type RuntimeNote = TimedPlayableNote;
/**
* Mine / landmine note (BMS channels D1-D9 / E1-E9 for the 1P / 2P sides). Same shared-instance treatment as
* `RuntimeNote`: the engine mutates `judged` on the same `TimedLandmineNote` instance the renderer's
* `this.mineNotes` array already references, so there is no separate `hit` flag for the view to keep in sync.
*
* The engine decides when a mine detonates (by the judge ruleset, see docs/player-spec.md#landmines): it plays the
* explosion sample (`#WAV00`) and drains the gauge by the mine's damage, without a verdict or a combo change. The
* playable notes are untouched, so a regular note near the mine is judged as usual.
*/
export type RuntimeMineNote = TimedLandmineNote;
/**
* What the shared playfield and the built-in chrome read of the running play (`ctx.play`): the chart and its notes and
* scroll, the lanes laid out (`laneX`, which the lanes pass fills), the play state and the engine's scores, the lane
* effects and bombs, the BGA's timelines and textures, the clocks, the pause and the exit fade. The play session
* (`PlaySession`) is one; the view reads it and writes only the lanes it lays out and the BGA videos it plays.
*/
/** A judgment's timing on a side's plate: the signed offset (ms, > 0 late) and until when it shows (chart seconds). */
export interface JudgeSideTiming {
judge: JudgmentKind;
deltaMs: number;
until: number;
}
export interface PlayfieldRuntime {
/** A seek (or a sought earlier course stage) made the play practice. */
readonly practice?: boolean;
/** Where the play skin is moved and how far it is scaled (LR2's 1 / 2 + the arrows); where it is drawn without one. */
readonly skinAdjust?: { readonly x: number; readonly y: number; readonly scale: number };
readonly chart: LibraryChart | undefined;
readonly resolvedChart: BeMusicJSON | undefined;
readonly resolvedPlayChart: ResolvedChart | undefined;
readonly laneChannels: string[];
readonly chartPlayVariant: ChartPlayVariant;
/** The play variant of the chart a battle mode converted (`chartPlayVariant` is the converted one's). */
readonly battleSourceVariant?: ChartPlayVariant;
readonly laneX: Map<string, PlayfieldLaneRect>;
readonly notes: RuntimeNote[];
/**
* The notes the lanes draw: `notes`, and past a seamless PRACTICE loop's end the next round's (the engine's
* `renderNotes`), which nobody judges.
*/
readonly drawNotes: RuntimeNote[];
readonly mineNotes: RuntimeMineNote[];
readonly invisibleNotes: TimedPlayableNote[];
readonly maxLongNoteBeatSpan: number;
readonly timingResolver: TimingResolver | undefined;
/** The chart's BPM GUIDE labels, BPM changes to `#SPEED` changes. */
readonly bpmGuideEvents: readonly import('../../../chart/bpm-guide.ts').BPMGuideEvent[];
readonly scrollMapper: ScrollDistanceMapperLike | undefined;
readonly laneTimelineBeats: Float64Array;
readonly scrollHiSpeed: HiSpeedTransition;
readonly tempo: number;
readonly playbackTempo?: number;
readonly playState: PlayState;
readonly score: ScoreSummary;
/** The 2P player of a two-player play (LR2 BATTLE): its scores, play state and the engine's gauge for it. */
readonly secondPlayer:
| { readonly score: ScoreSummary; readonly playState: PlayState; readonly gauge?: PlayerGaugeSummary }
| undefined;
/** The score readout, easing toward the score after each judgment. */
readonly displayedScore: number;
readonly gaugeState: PlayerGaugeSummary;
readonly fastCount: number;
readonly slowCount: number;
readonly lastJudge: string;
readonly lastJudgeUntil: number;
readonly lastJudgeAt: number | undefined;
readonly judgeSideState: Record<
'1P' | '2P',
{
judge: JudgmentKind | '';
until: number;
combo: number;
courseCombo?: number;
/** The timings the judge detail reads: the plate's own judgment's, and the last of the keys and of the scratch. */
timings?: { last?: JudgeSideTiming; keys?: JudgeSideTiming; scratch?: JudgeSideTiming };
}
>;
readonly judgeWindows: BeMusicJudgeWindows | undefined;
readonly lastImpulseAt: number | undefined;
readonly lastImpulseKind: BeMusicLaneKind | undefined;
readonly chartBPMRange: PlayTempoRange | undefined;
readonly playMoments: {
failedAtMs?: number;
allNotesDoneAtMs?: number;
outroAtMs?: number;
gaugeRiseAtMs?: number;
gaugeMaxAtMs?: number;
};
readonly assetsLoading: boolean;
readonly longNotes: LongNoteTracker;
readonly scratchInputs?: ReadonlyMap<string, { angle: number; direction: 1 | -1; atMs: number }>;
readonly lanePressedAt: Map<string, number>;
readonly laneReleasedAt: Map<string, number>;
readonly pressedChannels: Set<string>;
/**
* The key beams by channel: when each came on, and when each began fading out after its key went up. The view
* retires a beam whose fade has played out; a family maps the channels onto its own timers (the LR2 view onto LR2's
* key-on bank).
*/
readonly keyBeamStartedAt: Map<string, number>;
readonly keyBeamFadeStartedAt: Map<string, number>;
/**
* How many times the play has lifted every finger off the touch lanes (each pause, releasing the lanes they held): a
* view following the fingers forgets the ones down before the latest lift.
*/
readonly touchLiftCount: number;
readonly bombStartedAt: Map<string, number>;
readonly bombJudge: Map<string, BeMusicJudgmentKind>;
/**
* A ghost's recorded presses and judgments to draw over the lanes (`ghost-lanes.ts`): present only on a playfield a
* lane-overlay ghost presents over the play, never on the play itself.
*/
readonly ghostLanes?: GhostLaneOverlay;
/** The replay ghost’s lane bank, when presented beside the live play. */
readonly ghostSide?: '2P';
readonly hasBGA: boolean;
/** The camera shown in the BGA frame in place of the chart's BGA (`PlayScene.setBGACamera`), when one is. */
readonly bgaCamera?: BGAFeed | undefined;
/** An LRX chart's composited BGA (`media/lrx-bga-compositor.ts`), shown when no camera is. */
readonly lrxBGA?: BGAFeed | undefined;
readonly bgaTimeline: {
base: BGACue[];
layer: BGACue[];
layer2?: BGACue[];
poor: BGACue[];
opacity?: BGAOpacityTimelines;
};
readonly nonstopBGATimelines: NonstopStageBGATimeline[] | undefined;
readonly poorBGAMode?: 0 | 1 | 2;
readonly poorBGAFallbackKey: string | undefined;
readonly poorBGAFallbackUntilSeconds: number;
readonly lastPoorAt: number;
readonly engineFrame?: Pick<
PlayerUIFramePayload,
'keyBoundBGA' | 'bmsonBGA' | 'reversalActivation' | 'currentSeconds' | 'chartOptions' | 'summary'
>;
readonly bgaTextures: Map<string, Texture>;
readonly bgaLayerTextures: Map<string, Texture>;
readonly bgaVideos: Map<string, { video: HTMLVideoElement; objectURL: string }>;
readonly bgaSubRegionOrigins: Map<string, { x: number; y: number }>;
bgaActiveVideos: Record<string, { key: string; cueSeconds: number } | undefined>;
readonly audioAnalyzer: AudioAnalyzer | undefined;
readonly audioContextStartTime: number;
readonly paused: boolean;
readonly disposed: boolean;
readonly exiting: boolean;
readonly exitFadeOutMs: number;
readonly exitFadeStartedAt: number | undefined;
playClock(): number;
/** True once the play's intro timeline has started. A view attached later seeds its skin timers from the clock. */
hasSceneStarted?(): boolean;
currentSeconds(): number;
currentBeat(seconds: number): number;
nowBPM(seconds: number): number | undefined;
displayBPM(seconds: number): number | undefined;
isIntroPlaying(): boolean;
isAutoplayedChannel(channel: string): boolean;
/** The scratch lanes AUTO SCRATCH plays (empty when it is off, and under a full AUTO play's own switch). */
readonly autoScratchChannels: ReadonlySet<string>;
resolveLaneCovers(): readonly BeMusicLaneCover[];
resolveLongNoteMode(note: RuntimeNote): BeMusicLongNote['mode'];
resolveChartDurationSeconds(): number;
resolveVisibleMs(
cover: BeMusicLaneCover | undefined,
bpm: number | undefined,
scrollRate: number,
): number | undefined;
resolveJudgeRuleset(): string;
resolveChartMs(): number | undefined;
}
/**
* A play view's own drawing around the shared playfield, which the frame pass (`view/shared/play-frame.ts`) and the
* playfield's passes call at their places in each frame. Each family view composes its own; nothing is overridden.
*/
export interface PlayChrome {
/** Adds the view's own layers inside the skin layer, once, before the layer tree is put together. */
attachLayers?(): void;
/** Draws the view's chrome (the skin and overlay layers) for the frame, on a stage of `width` x `height`. */
draw(width: number, height: number): void;
/** Draws the view's late text into the text layer, after the bombs. */
drawText?(seconds: number): void;
/** `channel`'s bomb went out (its effect has played out): the view stops what it started for it. */
bombRetired?(channel: string): void;
}
/** The view's members the playfield passes use (a play view's members of these names), with the running play as `play`. */
export interface PlayfieldContext extends LaneGeometryContext {
/** The frame's play options, for the options that only change what the playfield draws. */
playOptions?: import('@be-music/player-scene-model').PlayOptions;
readonly drawsLift?: boolean;
readonly options: Readonly<
Pick<
PlaySessionOptions,
| 'beMusicEffects'
| 'showInvisibleNotes'
| 'bpmGuide'
| 'bpmGuideKinds'
| 'judgeTimingMs'
| 'visualConstant'
| 'noteDurationMs'
| 'constantFadeMs'
>
>;
/** How the family's skin answers the playfield: the stage, the lanes, the note and bomb cells, the effect lengths. */
readonly playfieldSkin: PlayfieldSkin;
readonly chrome: PlayChrome;
readonly laneLayer: Graphics;
readonly shutterLayer: Graphics;
readonly overlay: Text;
readonly noteLayerPool: ChildPool;
/** The layer the notes and bar lines draw in; LR2's NABEATSU sways it. */
readonly noteLayer: { readonly position: { set(x: number, y: number): void } };
readonly bombLayerPool: ChildPool;
readonly textLayerPool: ChildPool;
readonly skinBinding: BeMusicGameplayBinding | undefined;
readonly noteOverscan: number;
drawCursor:
| {
notes: readonly RuntimeNote[];
mines: readonly TimedLandmineNote[];
seconds: number;
note: number;
mine: number;
}
| undefined;
readonly goneDrawObjects: GoneDrawObjects;
measureBeatCache: { chartId: string | undefined; beats: number[] };
measureLineRuns: { signature: number; runs: SideLaneRun[] } | undefined;
readonly audioFrame: AudioFeatures | undefined;
}
|