Ein Daten-Registry ist ein effizienter globaler Speicherplatz für USTRUCT-getaggte Datenstrukturen. Data Registries unterstützen synchronen und asynchronen Datenzugriff und benutzerdefinierte Zwischenspeicherverhalten. Sie sind für die Arbeit mit allgemeinen Read-Only-Daten gedacht.
Data Registries sind Teil eines Plugins. Die Data Registries Quickstart kann Sie durch den Prozess begleiten und Sie mit einigen Grundkonzepten vertraut machen. Für spezifische sitzungsbasierte Daten wie den Fortschritt in einer Geschichte oder den aktuellen Status des Charakters, verwenden Sie das Save-Game-System der Engine.
Sie können Ihre Data Registry konfigurieren, damit Sie Daten aus einer Reihe verschiedener Quellen laden, generieren und diese mithilfe von Asset-Scanning und manueller Registrierung ausfüllen kann. Data Registries ähneln Zusammengesetzten Daten-Tabellen, aber können neben standardmäßigen Tabellenzeilen auch Kurvendaten speichern und können anstelle der manuellen Zusammenführung mehrerer Tabellen eine Indirektionsschicht verwenden.
Data Sources
Data Registries gather data items from two types of sources, Data Registry Sources and Meta Data Registry Sources. These sources are not the actual data items, instead the Data Registry uses them to find or generate data items. The order in which data sources appear within a Data Registry matters, if a specific data item is not found in one source, then the Data Registry will look in the sources that appear after it in the list.
This creates the potential for override and fallback behavior, and enables context-specific sources to override generic ones.
The Data Registry plugin includes built-in Data Registry Sources and Meta Data Registry Sources that wrap Data Tables (UDataTable) and Curve Tables (UCurveTable).
Data Registry Sources
The Data Registry directly owns a set of Data Registry Source objects that you can create and configure in an array within the Data Registry Asset.
These objects represent interfaces to specific data sources where the Data Registry can find information, such as an individual data table or a web database.
You can create child classes of UDataRegistrySource if you want to handle other types of data, or implement different indirection rules to map identifiers to data items.
Any child class you create will appear in the dropdown list when you add new data sources to a Data Registry Asset.
Meta Data Registry Sources
Meta Data Registry Sources create and own other data sources at runtime. Rather than explicitly list all data sources, Meta Data Registry Sources use generic rules, such as scanning a set of user-named paths, to locate Assets that contain data items. They can also listen for manual registration of specific Assets.
Because Meta Data Registry Sources are dynamically generated, data sources (and the data items within those sources) that they discover load into the Data Registry at runtime.
Similar to Data Registry Sources, you can create your own child classes to handle other data types, create different scanning rules, and so on. To do this, override the UMetaDataRegistrySource class.
Any child classes you create will appear in the dropdown list as options when you add new Data Sources to a Data Registry Asset.
Identifiers
Das Data-Registry-Plugin verwendet seine eigenen Identifier-Typen, um Data Registries sowie die einzelnen Data Items, die sie enthalten, zu identifizieren und zu durchsuchen. Obwohl diese Identifikatoren string-based names sind, agieren die FDataRegistryType- (für Data Registry Assets) und FDataRegistryId-Strukturen (für einzelne Elemente innerhalb einer Data Registry) als Wrapper und bieten nützliche Funktionen innerhalb des Editors.
FDataRegistryType identifiziert ein Data Registry Asset, während FDataRegistryId eine Data Registry und ein spezifisches darin enthaltenes Data Item identifiziert. Sie können diese Identifier-Typen verwenden, wenn Sie Data Registry Assets finden oder einzelne darin enthaltene Data Items abrufen müssen.
Jedes Data Registry Asset benötigt einen einzigartigen Namen im Feld Registry-Typ. Wenn zwei Data Registry Assets denselben Namen in diesem Feld haben, wird das System nur einen von ihnen erkennen und ausfüllen. Wenn mehrere Datenelemente denselben Identifikationswert (Name oder Gameplay-Tag) gemeinsam nutzen, liest die Registrierung alle Elemente, aber Abrufvorgänge greifen nur auf das erste Element zu, welches das Datenregistrierungs-Asset geladen hat; sehen Sie den Abschnitt über data sources, um Informationen über die Reihenfolge zu erhalten, in der Datenelemente geladen werden.
Entwickler, die C++ verwenden, können dieses Verhalten ändern, indem sie eine Data-Registry-Child-Klasse erstellen und die Funktion ResolveDataRegistryId überschreiben.
Data Registry Asset Identifiers
While setting up a Data Registry Asset, developers must set the Registry Type field to a unique name value. This is the identifier for the Data Registry.
After setting this value, FDataRegistryType fields across the editor will immediately add the new Data Registry name to their dropdown list.
This prevents user error resulting from spelling mistakes when referencing the Data Registry in other Assets, and makes the selection process quicker and easier.
Data Item Identifiers
Identifying an individual data item, such as a row within a data table, requires specifying the Data Registry Asset and the data item itself. The FDataRegistryId type contains both identifiers. Its Data Registry Type field will appear as a dropdown list, from which you can select any known Data Registry by its identifying name.
After selecting a Data Registry's name from that dropdown list, the Data Registry ID field will change to accommodate the Data Registry.
If the Data Registry's ID Format uses a Gameplay Tag, the user interface will display a filtered list containing that Gameplay Tag and all of its children. If the Data Registry's ID Format did not use a Gameplay Tag, the user interface will display a dropdown list of all known rows that the Data Registry Asset contains.
Wenn Sie ein Data Registry Asset bearbeiten, werden Ihre Änderungen möglicherweise nicht sofort in anderen Assets übernommen, die es über Data Item Identifiers referenzieren. Wenn das passiert, könnten die Data Item Identifiers obsolete Zeilen in ihren Dropdown-Listen enthalten. Klicken Sie im Asset, das die Data Registry referenziert (nicht im Data Registry Asset selbst), auf die Schaltfläche Kompilierung, um das Interface mit den aktuellen Data-Item-Informationen zu aktualisieren.
Da FDataRegistryId einen FDataRegistryType-Member (genannt RegistryType) hat, können Sie das Data Registry Asset finden, das die Zeile enthält, ohne einen separaten FDataRegistryType-Identifier zu benötigen.
Dynamic Identifier Resolution
By default, the system looks up data items by searching for the value of the ItemName field of the FDataRegistryId you supply. If this is not the ideal behavior for your project, you can create your own UDataRegistry subclass and override the MapIdToResolvedName function to include additional FDataRegistryResolverScope structs in the local scope. By overriding the ResolveIdToName function within your FDataRegistryResolverScope subclasses, you can remap the incoming row names, even using dynamic or player-specific information. After resolving an ID, the system produces an FDataRegistryLookup which is guaranteed to be unique (within the system) and is used as the caching unique ID.
Quick Function Reference
Die folgenden Funktionen sind nützlich, um sich mit Data Registries vertraut zu machen. Das ist keine vollständige Referenz, aber diese Funktionen sind die Grundlagen, die Sie benötigen werden, um auf Ihre Daten zuzugreifen, nachdem Sie Data Registries in Ihrem Projekt eingerichtet haben.
| Function | Description |
|---|---|
| Returns a pointer to the |
| Takes a name or |
| Searches for a Data Registry by |
| Searches the Data Registry for the data item that corresponds to the |
| Populates a map with a pointer to the engine's |
| Finds the curve that corresponds to the |
| Similar to |
Caching struct pointers that you retrieve from a Data Registry can be unsafe. While some data items are always available, others load dynamically and the Data Registry can unload them without warning. If you are potentially dealing with data that can be unloaded, the recommended practice is to use the data immediately after retrieving it, or cache your own copy rather than keeping the pointer from the Data Registry.
Integration mit Game Features
Das Data-Registry-Plugin kann sowohl Data Registries als auch individuelle Data Registry Sources aus Game-Feature-Plugins hinzufügen. Für Details zur Funktionsweise dieses Prozesses wenden Sie sich an die Seite Game Features and Modular Gameplay.