Scripting API

Scripting API

PrefabInstance

Struct in Abyss.Core.Scenes, from Abyss.Core.

The mark on an entity that came from a prefab, saying which one.

public struct PrefabInstance

Remarks

A component rather than a list the loader kept, for the reason which scene an entity is in is a mark on it (see SceneId): a list goes stale the moment anything else touches the world — an entity that died is still in it and an entity something else reparented is in the wrong part of it — and a capture that asks the world cannot be wrong in either direction.

It holds an identity, not a path and not an index. A path is a string and a component is plain bytes; an index into anything would be a number that means something only in the process that wrote it, which is the rule the whole scene format is built on. A AssetGuid is sixteen bytes that mean the same thing in every process, which is exactly what makes it the thing a file already writes down.

Two ulongs, the fewest sixteen bytes fit in: a field's value travels as a FieldValue, which holds every one of a whole number's 64 bits exactly. Nobody is meant to edit these, and only the inspector's Debug view shows them.

Only the root of an instance carries it. Everything under it is recognized by being under it, which is what lets a capture write one reference instead of a subtree — see Capture; what of that the prefab supplied, rather than the scene added, carries PrefabPart.

Constructors

PrefabInstance

public PrefabInstance(AssetGuid prefab)

Marks an entity as the root of an instance of prefab.

Parameters

  • prefab: The prefab's identity.

Properties

Prefab

public readonly AssetGuid Prefab { get; }

Which prefab this entity is an instance of.

Fields

Low

public ulong Low

Bytes 0 to 7 of the prefab's identity.

High

public ulong High

Bytes 8 to 15 of the prefab's identity.