Ananke Csv Master Advanced Guide 2: Allowing Duplicate IDs

Back to Table of Contents

Allowing Duplicate IDs

By default, Ananke CSV Master stores data in Dictionary structures, which prohibits duplicate IDs.

However, there are scenarios where allowing duplicates can be beneficial – for example, when mapping multiple hit information entries to a single skill ID.

To accommodate such use cases, Ananke Csv Master provides an option to allow duplicate IDs.

Configuration

In the Basic Information section when adding values to a DataSet, you’ll find the “Index Duplicatable” setting.
Setting this to true allows the system to import data with duplicate IDs without raising errors.

After changing this setting, click Save Header to store your changes, then re-generate your classes using Create ScriptableObject and Importer.

Accessing Data with Duplicate IDs

When working with duplicate IDs, the data access pattern changes slightly.
Here’s an example using the MasterDataHolder we created in our previous guide.

The original access pattern looked like this:

MasterDataHolder.Instance.PlayerData.CharacterData["p001"].Name;

This structure used a Dictionary<key, Data> format.

When duplicate IDs are allowed, the structure changes to Dictionary<key, List<Data>>. Consequently, you need to specify a List index when accessing the data.

Add an index accessor [0] to access the data like this:

MasterDataHolder.Instance.PlayerData.CharacterData["p001"][0].Name;

Note that [0] is a List element accessor – attempting to access an index beyond the list’s bounds will throw an exception.

Next

コメント

タイトルとURLをコピーしました