Prefab
// Walks a prefab hierarchy calling a virtual function for each object, which is used to create
// entities for types of objects. A stack is maintained that can be used for setting up an entity
// in relation to ancestor entities. When indexing objects on the prefab stack, the top of the stack
// is -1 and progressively negative indices move towards bottom of stack. Prefab usage must be after
// a scene is finalized and before the scene is released.
class RVAPI Prefab
{
public:
// Callback to load entity type.
typedef void (*FOnLoadType)(Prefab &prefab);
// Get marker position.
const M4f &GetMarker(wcstr name) const;
// Check if object at [n] index on stack exists.
bool IsObject(int n) const;
// Check if name matches [name].
bool IsObjName(wcstr name, int n = -1) const;
// Check if type matches [type].
bool IsObjType(wcstr type, int n = -1) const;
// Get object non-qualified name at [n] index on stack.
wcstr GetObjBaseName(int n = -1) const;
// Get object type at [n] index on stack.
wcstr GetObjType(int n = -1) const;
// Get object qualified name at [n] index on stack.
wcstr GetObjName(int n = -1) const;
// Get object hull path at [n] index on stack.
wcstr GetObjHullPath(int n = -1) const;
// Get object local position at [n] index on stack.
const M4f &GetObjPos(int n = -1) const;
// Get object entity at [n] index on stack. A reference to a created entity can be attached
// to an object for reference by child objects. Use this function to get the entity reference.
Entity &GetObjEnt(int n = -1) const;
// Set node entity at [n] index on stack. A reference to a created entity can be attached to
// an object for reference by child objects. Use this function to set the entity reference.
void SetObjEnt(Entity *entity, int n = -1);
// Load prefab from [path] and placed at [pos] in scene.
void Load(wcstr path, const M4f &pos = M4fIdent());
// Constructor.
Prefab();
// Destructor.
virtual ~Prefab();
protected:
virtual void OnLoadObject() {}
private:
byte wobj[448];
friend class PrefabBridge;
};