DataContainer
A base frostbite DataContainer, the highest class in the Frostbite container instance hierarchy. All instances present in game data partitions (ebx) are derived from this type.
Summary
Properties
Name | Type |
---|---|
typeInfo | TypeInformation |
isLazyLoaded | bool |
isReadOnly | bool |
instanceGuid | Guid | nil |
partitionGuid | Guid | nil |
partition | DatabasePartition | nil |
Methods
Method | Returns |
---|---|
Is(typeName: string) | bool |
Eq(other: DataContainer) | bool |
AsDC() | DataContainer |
Clone() | DataContainer |
Clone(guid: Guid) | DataContainer |
ReplaceReferences(with: DataContainer | nil) | void |
MakeWritable() | void |
RegisterLoadHandler(callback: callable) | ContainerCallback | nil |
RegisterLoadHandler(context: any, callback: callable) | ContainerCallback | nil |
RegisterLoadHandlerOnce(callback: callable) | ContainerCallback | nil |
RegisterLoadHandlerOnce(context: any, callback: callable) | ContainerCallback | nil |
Static members
Name | Type |
---|---|
DataContainer.typeInfo | TypeInformation |
Properties
typeInfo
Type information for this instance. You can get the specific type of this instance via instance.typeInfo.name
.
isLazyLoaded
bool
Indicates whether this instance is being lazy-loaded.
isReadOnly
bool
Indicates whether this instance is read-only, which is the case for instances loaded from data. Changes to read-only instances will throw an error.
instanceGuid
Guid | nil
The Guid of this instance, if it has one assigned to it.
partitionGuid
Guid | nil
The Guid of the partition that contains this instance, if there is one. Only instances loaded from data are inside partitions.
partition
DatabasePartition | nil
The DatabasePartition that contains this instance, if there is one. Only instances loaded from data are inside partitions.
Methods
Is
Is(typeName: string): bool
Checks if an instance is of a specific type. This will return true
for matching child types too (eg. calling :Is('Asset')
on a SoundAsset will return true
).
Parameters
Name | Type | Description |
---|---|---|
typeName | string | The type name to check against. |
Returns
Type | Description |
---|---|
bool | Whether this instance is of the provided type. |
Eq
Eq(other: DataContainer): bool
Checks if two instances are pointing to the same data. This performs reference equality checks, not value equality.
Parameters
Name | Type | Description |
---|---|---|
other | DataContainer | The instance to check against. |
Returns
Type | Description |
---|---|
bool | Whether this instance points to the same data as other . |
AsDC
AsDC(): DataContainer
Returns a reference to the same instance as a DataContainer type. This is usually helpful when you have to upcast a more generic type to make it match the type definition of a property or an array.
Returns
Type | Description |
---|---|
DataContainer | The same instance but upcasted to a DataContainer. |
Clone
Clone(): DataContainer
Creates a shallow clone of this instance, which is essentially the equivalent of creating a new instance of the same type and assigning the values of this instance to all of its properties. Any properties that contain structure types (eg. Vec3) will be cloned when assigning, while properties that contain instance types (eg. DataContainer) will be referencing the same instance.
Returns
Type | Description |
---|---|
DataContainer | The newly created instance. |
Clone
Clone(guid: Guid): DataContainer
Creates a shallow clone of this instance and assigns it the provided Guid, which is essentially the equivalent of creating a new instance of the same type with the provided Guid and assigning the values of this instance to all of its properties. Any properties that contain structure types (eg. Vec3) will be cloned when assigning, while properties that contain instance types (eg. DataContainer) will be referencing the same instance.
Parameters
Name | Type | Description |
---|---|---|
guid | Guid | The Guid to assign to the cloned instance. |
Returns
Type | Description |
---|---|
DataContainer | The newly created instance. |
ReplaceReferences
ReplaceReferences(with: DataContainer | nil)
Replaces all registered references to the current instance with references to the provided instance. Passing nil
will clear all references to this instance.
Parameters
Name | Type | Description |
---|---|---|
with | DataContainer | nil | The instance to set the references to, or nil to clear them. |
MakeWritable
MakeWritable()
Makes a read-only instance writable. This is useful for modifying loaded game data. As this is a quite expensive operation, it is recommended to only use it on instances you plan to modify.
RegisterLoadHandler
RegisterLoadHandler(callback: callable): ContainerCallback | nil
Registers a callback that will be called once this lazy-loaded instance has finished loading. The callback will keep getting called between level loads.
Parameters
Name | Type | Description |
---|---|---|
callback | callable | A callback in the form function(instance: DataContainer) . |
Returns
Type | Description |
---|---|
ContainerCallback | nil | A callback handle that can be used to deregister the callback, or nil if this instance is not lazy-loaded. |
RegisterLoadHandler
RegisterLoadHandler(context: any, callback: callable): ContainerCallback | nil
Registers a callback that will be called once this lazy-loaded instance has finished loading. The callback will keep getting called between level loads.
Parameters
Name | Type | Description |
---|---|---|
context | any | The context to pass to the provided callback. |
callback | callable | A callback in the form function(context: any, instance: DataContainer) . |
Returns
Type | Description |
---|---|
ContainerCallback | nil | A callback handle that can be used to deregister the callback, or nil if this instance is not lazy-loaded. |
RegisterLoadHandlerOnce
RegisterLoadHandlerOnce(callback: callable): ContainerCallback | nil
Registers a callback that will be called once this lazy-loaded instance has finished loading. The callback will get called once and then get automatically deregistered.
Parameters
Name | Type | Description |
---|---|---|
callback | callable | A callback in the form function(instance: DataContainer) . |
Returns
Type | Description |
---|---|
ContainerCallback | nil | A callback handle that can be used to deregister the callback, or nil if this instance is not lazy-loaded. |
RegisterLoadHandlerOnce
RegisterLoadHandlerOnce(context: any, callback: callable): ContainerCallback | nil
Registers a callback that will be called once this lazy-loaded instance has finished loading. The callback will get called once and then get automatically deregistered.
Parameters
Name | Type | Description |
---|---|---|
context | any | The context to pass to the provided callback. |
callback | callable | A callback in the form function(context: any, instance: DataContainer) . |
Returns
Type | Description |
---|---|
ContainerCallback | nil | A callback handle that can be used to deregister the callback, or nil if this instance is not lazy-loaded. |
Static members
typeInfo
The type information for the DataContainer type.