Let a value be a bundle of named fields
PropertyValue was number | string | boolean | list. A struct joins it, which costs two things the typechecker found rather than I did. An object on a data edge used to mean a live entity, so asEntity would have taken a struct for one and asString would have read .name off it. EntityHandle now carries a symbol brand – a symbol so no field name can impersonate it, and it never serializes, which suits a thing that exists only while the game runs. It is built in exactly one place. String(value) would have written a struct as [object Object] at 39 call sites. They go through textOf(), which is identical for primitives. normalizeGraph dropped everything but primitives from node params, so the List node lost its value on every save ([3,1,4] round-tripped to undefined). Variables were spared: they have a schema, params have none.
This commit is contained in:
1 parent
3b3f374e10
commit
2cf788eedd
34 files changed
+284
-82
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import type { TextureAsset, TextureFrame } from './Asset';
|
||||
import type { PropertyBag } from './Properties';
|
||||
import { type PropertyBag, textOf } from './Properties';
|
||||
import { findAsset, type Project } from './Project';
|
||||
|
||||
/** Mirrors `TextureStore::isValidName` on the server, where the name is derived from the bytes. */
|
||||
@@ -56,7 +56,7 @@ export function textureRefIds(asset: TextureAsset): string[] {
|
||||
}
|
||||
|
||||
export function resolveTexture(project: Project, props: PropertyBag): TextureRef | null {
|
||||
const id = String(props.texture ?? '');
|
||||
const id = textOf(props.texture ?? '');
|
||||
if (!id) return null;
|
||||
const asset = findAsset(project, id);
|
||||
if (asset) return asset.type === 'texture' ? refFor(asset, null) : null;
|
||||
@@ -68,7 +68,7 @@ function refFor(asset: TextureAsset, frame: TextureFrame | null): TextureRef | n
|
||||
if (!isTextureFile(asset.file)) return null;
|
||||
return {
|
||||
file: asset.file,
|
||||
smooth: String(asset.props.filter ?? 'linear') !== 'nearest',
|
||||
smooth: textOf(asset.props.filter ?? 'linear') !== 'nearest',
|
||||
rect: frame ? { x: frame.x, y: frame.y, w: frame.w, h: frame.h } : null,
|
||||
sourceWidth: asset.width,
|
||||
sourceHeight: asset.height,
|
||||
|
||||
Reference in new issue
Block a user