nw::kernel::ObjectSystem

struct ObjectSystem : public nw::kernel::Service

The object system creates, serializes, and deserializes entities.

Public Functions

ObjectSystem(MemoryResource *scope)
ObjectSystem(const ObjectSystem&) = delete
ObjectSystem(ObjectSystem&&) = default
ObjectSystem &operator=(ObjectSystem&) = delete
ObjectSystem &operator=(ObjectSystem&&) = default
~ObjectSystem()
void destroy(ObjectHandle obj)

Destroys a single object.

template<typename T>
T *get(ObjectHandle obj)

Gets an object.

ObjectBase *get_object_base(ObjectHandle obj) const

Gets an object.

ObjectBase *get_by_tag(StringView tag, int nth = 0) const

Gets object by tag.

ObjectBase *alloc(ObjectType object_type)
template<typename T>
T *load_file(const std::filesystem::path &archive)

Loads an object from file system

Note

Player objects (BIC) loaded from the file system will be loaded as instances, all others as blueprints.

template<typename T>
T *load(Resref resref)

Loads an object from resource system.

template<typename T>
T *load_instance(const GffStruct &archive)

Loads an object from gff isntance.

template<typename T>
T *load_instance(const nlohmann::json &archive)

Loads an object from json isntance.

Player *load_player(StringView cdkey, StringView resref)

Loads an object from resource system.

template<typename T>
T *make()

Creates a new object.

Area *make_area(Resref area)

Creates an area object.

Module *make_module()

Creates a module object

Warning

: nw::kernel::resman().load_module(...) must be called before this.

void run_instantiate_callback(ObjectBase *obj)

Run instantiate callback.

void set_instantiate_callback(void (*callback)(ObjectBase*))

Set instatiate callback.

bool valid(ObjectHandle obj) const

Determines of object handle is valid.

MemoryResource *allocator() const noexcept

Gets the memory allocator for the servce.

inline virtual void initialize(ServiceInitTime)

Initializes a service

Note

Every service will be called with as many values as exist in ServiceInitTime. it’s up to the service itself to filter/ignore what’s not relevant to them.

Public Static Attributes

static const std::type_index type_index = {typeid(ObjectSystem)}