The autotile asset is renamed to tile and gains a plain None (1 × 1) kind, which is now the default; older projects load their autotiles as floor tiles (#131)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a65132bb5a
commit
732f6518ae
35 files changed
+786
-617
No files matched your search
@@ -79,7 +79,7 @@ import { SHADER_KEY, shaderParamDefs } from '../properties/shaders';
|
||||
*/
|
||||
export function deserializeProject(raw: unknown, fallbackId = ''): Project {
|
||||
const r = asRecord(raw);
|
||||
const rawAssets = (Array.isArray(r.assets) ? r.assets : []).map(asRecord);
|
||||
const rawAssets = (Array.isArray(r.assets) ? r.assets : []).map(asRecord).map(migrateAsset);
|
||||
|
||||
// Pass 1: asset ids and their effective schemas, needed to coerce overrides in pass 2.
|
||||
const schemas = new Map<string, PropertySchema>();
|
||||
@@ -176,7 +176,7 @@ export function deserializeProject(raw: unknown, fallbackId = ''): Project {
|
||||
} else if (type === 'sound') {
|
||||
const file = typeof a.file === 'string' && isSoundFile(a.file) ? a.file : '';
|
||||
assets.push({ id, type, name, props, file });
|
||||
} else if (type === 'autotile') {
|
||||
} else if (type === 'tile') {
|
||||
// A picture naming nothing is kept, like an animation's dangling root: it reads as missing
|
||||
// in the tab and comes back when the texture it named is restored by an undo.
|
||||
const pictures = (Array.isArray(a.pictures) ? a.pictures : []).filter(
|
||||
@@ -505,7 +505,7 @@ function normalizeTracks(raw: unknown): AnimationTrack[] {
|
||||
|
||||
/**
|
||||
* The layers of a tilemap. A cell whose key is not a pair of whole numbers, or which names nothing,
|
||||
* is dropped; one naming a deleted autotile is kept, like an animation's dangling row, so an undo
|
||||
* is dropped; one naming a deleted tile is kept, like an animation's dangling row, so an undo
|
||||
* brings the drawing back. A doubled layer id is dropped as a doubled node is.
|
||||
*/
|
||||
function normalizeLayers(raw: unknown): TilemapLayer[] {
|
||||
@@ -537,6 +537,17 @@ function normalizeBag(raw: unknown, schema: PropertySchema, sparse: boolean): Pr
|
||||
return bag;
|
||||
}
|
||||
|
||||
/**
|
||||
* A tile was called an autotile before it could be a plain one (#131). Such an asset had no kind
|
||||
* but the autotile blocks, and one written without a kind meant a floor – which it has to stay now
|
||||
* that a missing kind means a plain tile.
|
||||
*/
|
||||
function migrateAsset(a: Record<string, unknown>): Record<string, unknown> {
|
||||
if (a.type !== 'autotile') return a;
|
||||
const props = asRecord(a.props);
|
||||
return { ...a, type: 'tile', props: { ...props, kind: props.kind ?? 'floor' } };
|
||||
}
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> {
|
||||
return value && typeof value === 'object' ? (value as Record<string, unknown>) : {};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user