// returns the index of the component version of the data in the cache public static int GetOrAddDamageIdx(BulletDamageData damageData) { if (!damageStatsCache.IsCreated) { damageStatsCache = new NativeList <BulletDamage>(Allocator.Persistent); } if (!damageIdx.ContainsKey(damageData)) { damageStatsCache.Add(damageData.ToBulletDamage()); damageIdx.Add(damageData, damageStatsCache.Length - 1); } return(damageIdx[damageData]); }