Skip to main content

Overview

The TypeLibrary is a central component of FrostySdk that manages the runtime type system for Frostbite assets. It dynamically loads, constructs, and provides access to EBX class definitions specific to each game.

Key Features

  • Dynamic Type Generation: Creates .NET types from Frostbite class definitions at runtime
  • Type Reflection: Maps GUIDs and hashes to type names and instances
  • SDK Caching: Compiles and caches type assemblies for improved performance
  • Type Hierarchy: Manages inheritance and type relationships

Core Classes

TypeLibrary

Main static class providing type management functionality.

Initialization

Initialize

Initializes the TypeLibrary and optionally loads a cached SDK.
bool
default:"true"
Whether to load the cached SDK assembly for the current profile
Example:

GetSdkVersion

Retrieves the version number of the currently loaded SDK.
Returns: SDK version number, or 0 if no SDK is loaded.

Type Creation and Access

GetType (by name)

Retrieves a type by its name.
string
required
The name of the type to retrieve
Returns: The Type object, or null if not found.

GetType (by GUID)

Retrieves a type by its unique identifier.
Guid
required
The GUID of the type
Returns: The Type object, or null if not found.

GetType (by hash)

Retrieves a type by its FNV hash.
uint
required
The FNV-1 hash of the type name
Returns: The Type object, or null if not found.

Type Queries

GetTypes

Retrieves all types that inherit from or match a specific type.
Type
The base type to search for
string
The name of the base type
Returns: Array of all matching types. Example:

GetConcreteTypes

Retrieves all concrete (non-abstract) types from the loaded SDK.
Returns: Array of all concrete types.

GetDerivedTypes

Retrieves all types that inherit from a specific type.
Type
required
The base type to search for derivatives
Example:

Type Checking

IsSubClassOf

Checks if a type or object is a subclass of another type.
object
The object to check
Type | string
The type to check
string
required
The name of the base type
Returns: true if the type is a subclass or exact match. Example:

Object Creation

CreateObject (by name)

Creates a new instance of a type by name.
string
required
The name of the type to instantiate
Returns: New instance of the type, or null if type not found.

CreateObject (by GUID)

Creates a new instance of a type by GUID.
Guid
required
The GUID of the type to instantiate
Example:

Reflection Subsystem

TypeLibrary.Reflection

Provides GUID and hash-based type lookups.

LoadClassInfoAssets

Loads type information from TypeInfoAsset entries and builds lookup cache.
AssetManager
required
The asset manager containing TypeInfoAsset entries
Example:

LookupGuid

Finds the GUID for a type by name.
string
required
The type name to look up
Returns: The type’s GUID, or Guid.Empty if not found.

LookupType (by GUID)

Finds the type name for a GUID.
Guid
required
The GUID to look up
Returns: The type name, or the GUID as string if not found.

LookupType (by hash)

Finds the Type object for a FNV hash.
uint
required
The FNV-1 hash of the type name
Returns: The Type object, or null if not found.

Cache Management

  • ReadCache: Loads type information from cache file. Returns true if successful.
  • WriteToCache: Saves current type information to cache.
Cache Location: Caches/{ProfileName}_typeinfo.cache

SDK Building

LoadClassesSDK

Loads class definitions from an SDK text file.
Stream
required
Stream containing SDK class definitions
Returns: DbObject containing parsed class definitions.

BuildModule

Builds a dynamic assembly from class definitions.
string
required
Output filename for the compiled assembly (without .dll extension)
DbObject
required
Class definitions from LoadClassesSDK
Example:

Helper Methods

InitializeArrays

Initializes array properties on an object instance.
Automatically called during object creation to ensure List properties are instantiated.

Usage Examples

Complete Initialization Flow

Type Hierarchy Navigation

GUID-Based Type Resolution

Working with Reflection Cache

Performance Considerations

  • SDK Loading: The first initialization can be slow. Use cached SDKs when possible.
  • Type Lookups: GUID and hash lookups build internal dictionaries on first use.
  • Cache Files: Type info caches significantly improve startup time.
  • Assembly Generation: Building dynamic assemblies is expensive - save to disk.

Thread Safety

TypeLibrary operations are not thread-safe. Initialize and load types on a single thread before accessing from multiple threads.

Best Practices

  1. Initialize Once: Call TypeLibrary.Initialize() once at application startup
  2. Cache Aggressively: Always use ReadCache() and WriteToCache() for reflection data
  3. Validate Types: Check for null returns from GetType() before using
  4. SDK Versioning: Use GetSdkVersion() to detect SDK changes
  5. Type Checking: Prefer IsSubClassOf() over direct type comparison for polymorphism