Overview
TheTypeLibrary 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
GetSdkVersion
Retrieves the version number of the currently loaded SDK.Type Creation and Access
GetType (by name)
Retrieves a type by its name.string
required
The name of the type to retrieve
GetType (by GUID)
Retrieves a type by its unique identifier.Guid
required
The GUID of the type
GetType (by hash)
Retrieves a type by its FNV hash.uint
required
The FNV-1 hash of the type name
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
GetConcreteTypes
Retrieves all concrete (non-abstract) types from the loaded SDK.GetDerivedTypes
Retrieves all types that inherit from a specific type.Type
required
The base type to search for derivatives
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
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
CreateObject (by GUID)
Creates a new instance of a type by GUID.Guid
required
The GUID of the type to instantiate
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
LookupGuid
Finds the GUID for a type by name.string
required
The type name to look up
Guid.Empty if not found.
LookupType (by GUID)
Finds the type name for a GUID.Guid
required
The GUID to look up
LookupType (by hash)
Finds the Type object for a FNV hash.uint
required
The FNV-1 hash of the type name
Cache Management
- ReadCache: Loads type information from cache file. Returns
trueif successful. - WriteToCache: Saves current type information to cache.
Caches/{ProfileName}_typeinfo.cache
SDK Building
LoadClassesSDK
Loads class definitions from an SDK text file.Stream
required
Stream containing SDK 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
Helper Methods
InitializeArrays
Initializes array properties on an object instance.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
Best Practices
- Initialize Once: Call
TypeLibrary.Initialize()once at application startup - Cache Aggressively: Always use
ReadCache()andWriteToCache()for reflection data - Validate Types: Check for null returns from
GetType()before using - SDK Versioning: Use
GetSdkVersion()to detect SDK changes - Type Checking: Prefer
IsSubClassOf()over direct type comparison for polymorphism