1681-engine / index / Prepainter
Class: Prepainter<T> ​
Defined in: src/assets/Prepainter.ts:56
Paints ahead the big textures a player may need next (the maps beyond the current one's doors, the next level's backdrop) so the step into them finds them ready instead of painting them there and then — a large map's ground was two seconds of main-thread work, which froze the first step through every door. It also frees the rest: each such texture is one big image, and a long session through thirty-odd places kept every one of them.
Whatever is not ready yet is the caller's to paint on arrival, as before; a painter that cannot start or fails only means nothing is painted ahead.
Type Parameters ​
| Type Parameter |
|---|
T |
Constructors ​
Constructor ​
new Prepainter<T>(options): Prepainter<T>;Defined in: src/assets/Prepainter.ts:63
Parameters ​
| Parameter | Type |
|---|---|
options | PrepainterOptions<T> |
Returns ​
Prepainter<T>
Accessors ​
holding ​
Get Signature ​
get holding(): ReadonlySet<string>;Defined in: src/assets/Prepainter.ts:90
Ids held as textures now.
Returns ​
ReadonlySet<string>
Methods ​
destroy() ​
destroy(): void;Defined in: src/assets/Prepainter.ts:109
Stops painting; textures already made are left to the registry.
Returns ​
void
enter() ​
enter(current, next): void;Defined in: src/assets/Prepainter.ts:71
Stands on current: its texture (painted by the caller on arrival, or ahead) and its neighbours' are kept, every other one this prepainter held is freed, and the neighbours not yet painted are started.
Parameters ​
| Parameter | Type |
|---|---|
current | T |
next | readonly T[] |
Returns ​
void
painting() ​
painting(id): boolean;Defined in: src/assets/Prepainter.ts:85
Whether id is being painted right now (so a caller may wait for it a moment rather than paint it again).
Parameters ​
| Parameter | Type |
|---|---|
id | string |
Returns ​
boolean
prepare() ​
prepare(item): void;Defined in: src/assets/Prepainter.ts:95
Starts painting item unless it is painted or under way.
Parameters ​
| Parameter | Type |
|---|---|
item | T |
Returns ​
void