add get id data type function

This commit is contained in:
Le Duc Anh
2025-10-11 09:50:36 +07:00
parent 3de4b27bb9
commit 2b7ad0e335
@@ -23,6 +23,7 @@ namespace ModelRenderer.Scripts.GameData
}
}
#region Dictionary for mapping id with other stuffs
public Dictionary<uint, DATA_TYPE> essence_id_data_type_map = new Dictionary<uint, DATA_TYPE>();
public Dictionary<int, uint> essence_index_id_map = new Dictionary<int, uint>();
public Dictionary<uint, object> essence_id_data_map = new Dictionary<uint, object>();
@@ -46,7 +47,9 @@ namespace ModelRenderer.Scripts.GameData
public Dictionary<uint, DATA_TYPE> addon_id_data_type_map = new Dictionary<uint, DATA_TYPE>();
public Dictionary<int, uint> addon_index_id_map = new Dictionary<int, uint>();
public Dictionary<uint, object> addon_id_data_map = new Dictionary<uint, object>();
#endregion
#region Arrays for storing the data
public EQUIPMENT_ADDON[] equipment_addon_array = new EQUIPMENT_ADDON[0];
public WEAPON_MAJOR_TYPE[] weapon_major_type_array = new WEAPON_MAJOR_TYPE[0];
public WEAPON_SUB_TYPE[] weapon_sub_type_array = new WEAPON_SUB_TYPE[0];
@@ -283,6 +286,7 @@ namespace ModelRenderer.Scripts.GameData
public FASHION_SUITE_ESSENCE[] fashion_suite_essence_array = new FASHION_SUITE_ESSENCE[0];
public FASHION_BEST_COLOR_CONFIG[] fashion_best_color_config_array = new FASHION_BEST_COLOR_CONFIG[0];
public SIGN_AWARD_CONFIG[] sign_award_config_array = new SIGN_AWARD_CONFIG[0];
#endregion
public int load_data(string pathname = "")
{
@@ -1480,6 +1484,34 @@ namespace ModelRenderer.Scripts.GameData
return id;
}
/// <summary>
/// Go through the id - DATA_TYPE map and return the id with the given data type.
/// </summary>
/// <param name="idSpace">The id space to search in. Each id space has its own id - DATA_TYPE map.</param>
/// <param name="dataType">The data type to search for.</param>
/// <returns>The id with the given data type. Return 0 if no id is found.</returns>
public uint get_id_with_data_type(ID_SPACE idSpace, DATA_TYPE dataType)
{
switch (idSpace)
{
case ID_SPACE.ID_SPACE_ESSENCE:
foreach (var item in essence_id_data_type_map)
{
if (item.Value == dataType)
{
return item.Key;
}
}
break;
// TODO: Add other id spaces here.
default:
return 0;
}
return 0;
}
void add_id_data(ID_SPACE idSpace, uint id, object data)
{
switch (idSpace)