Tilemaps are a new placeable asset type that is painted with autotiles in the scene view, with layers, brush, eraser and rectangle, and is drawn at runtime and in the export (#128)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0607221423
commit
33a7b1b63e
30 files changed
+2060
-20
No files matched your search
@@ -139,6 +139,19 @@ function pickIds(input: readonly string[], primary?: string): { ids: string[]; p
|
||||
return { ids, primary: primary && ids.includes(primary) ? primary : ids[ids.length - 1]! };
|
||||
}
|
||||
|
||||
/**
|
||||
* Select leaves the scene view as it is – the map is picked up and moved like any other object.
|
||||
* The other three paint: brush the chosen autotile cell by cell, erase clears, rect fills the box
|
||||
* a drag spans. Painting is a mode on purpose; a map one cannot move would be worse than a click.
|
||||
*/
|
||||
export type TilemapTool = 'select' | 'brush' | 'erase' | 'rect';
|
||||
|
||||
export interface TilemapPaint {
|
||||
tool: TilemapTool;
|
||||
autotileId: string;
|
||||
layerId: string;
|
||||
}
|
||||
|
||||
export type EditorMode = 'edit' | 'play';
|
||||
export type SaveStatus = 'saved' | 'dirty' | 'saving' | 'error' | 'conflict';
|
||||
|
||||
@@ -184,6 +197,12 @@ export class EditorState {
|
||||
notice = '';
|
||||
/** Keys copied in the Animation tab (#102). Lives for the session, across animations and projects. */
|
||||
keyClipboard: KeyClipboard | null = null;
|
||||
/**
|
||||
* What the scene view paints a tilemap with (#128): the tool, the autotile and the layer it goes
|
||||
* on. Editor state, not model state – like the picked tile of the Animation tab, it is a way of
|
||||
* working rather than something the project remembers.
|
||||
*/
|
||||
tilemapPaint: TilemapPaint = { tool: 'select', autotileId: '', layerId: '' };
|
||||
/** The real (saved) model and its undo stack while `project` is the play-mode copy. */
|
||||
private edit: { project: Project; commands: CommandStack } | null = null;
|
||||
|
||||
@@ -603,6 +622,12 @@ export class EditorState {
|
||||
* Shows `message` in the toolbar and, unless `quiet`, keeps it in the console panel. Quiet is
|
||||
* for the play status lines, which state a mode rather than report an event.
|
||||
*/
|
||||
/** Changes what the scene view paints with; the inspector marks it and the view repaints. */
|
||||
setTilemapPaint(patch: Partial<TilemapPaint>): void {
|
||||
this.tilemapPaint = { ...this.tilemapPaint, ...patch };
|
||||
this.emit('selection');
|
||||
}
|
||||
|
||||
setNotice(message: string, level: NoticeLevel = 'info'): void {
|
||||
this.notice = message;
|
||||
if (message !== '' && level !== 'quiet') consoleLog.push(level, message);
|
||||
|
||||
Reference in new issue
Block a user