import { type Position, type PropertyBag, toPosition, type Vec2 } from './Properties'; /** * An asset placed inside a scene. Overrides are sparse: only keys the user changed are stored, * everything else follows the asset. */ export interface SceneObject { id: string; assetId: string; /** Falls back to the asset name when empty. */ name: string; /** Relative to the parent, `z` included; see `hierarchy.ts` for world coordinates. */ position: Position; /** * Editor-only shift of where this object and everything below it is drawn – never part of the * game. It pulls apart objects that sit on top of each other without moving them for real. */ editorOffset: Vec2; overrides: PropertyBag; /** * Parent object of the same scene, empty string = top level. Children move with their parent and * are removed with it; behaviors treat their parent as the "owner" the graph acts on. */ parentId: string; /** * The template object inside the container asset this one was instantiated from, empty for * everything else – the link that lets template changes reach the instances later on. */ templateId: string; } export function createSceneObject( id: string, assetId: string, position: Vec2 | Position, parentId = '', ): SceneObject { return { id, assetId, name: '', position: toPosition(position), editorOffset: { x: 0, y: 0 }, overrides: {}, parentId, templateId: '', }; }