CharacterDatabase

Singleton database that provides hash-based lookup for CharacterFactory instances. Subclasses ScriptableFactoryDatabase to index all character factories by their CharacterID at startup.

Definition

Namespace: Paragon.Townskeep.CharacterSystem Assembly: Townskeep.dll

[SingletonSettings(AssetPath = "Character/Character Database")]
public class CharacterDatabase : ScriptableFactoryDatabase<CharacterDatabase, CharacterFactory>

Inheritance: ParagonScriptableObjectSingletonScriptableObject<CharacterDatabase>ScriptableFactoryDatabase<CharacterDatabase, CharacterFactory>CharacterDatabase

Remarks

CharacterDatabase is a concrete implementation of the generic ScriptableFactoryDatabase for the character system. It acts as the central registry for all CharacterFactory assets, indexing them by the CharacterID defined in their CharacterData.

On OnEnable(), the base class queries ScriptableFactoryRegistry for all CharacterFactory instances and builds a Dictionary<int, CharacterFactory> keyed by each factory's GetHashCode() (which returns CharacterData.CharacterID).

The asset is auto-created at Resources/Character/Character Database via the [SingletonSettings] attribute.

Quick Lookup

Goal
How

Get a factory by character ID

CharacterDatabase.GetFactory(characterID)

Get all character factories

Via ScriptableFactoryRegistry.GetAllFactoriesOfType<CharacterFactory>()

Methods

GetFactory (inherited)

Retrieves a CharacterFactory by its character ID.

Parameter
Type
Description

characterID

int

The CharacterID from CharacterData

Returns: The CharacterFactory matching the given ID.

circle-exclamation

Usage Example

See Also

Last updated