What’s wrong with my Key and Value? I do not know, never seen it. Where is the cause of this error? Can someone tell me.
StatTypes is an enum, StatBase is a class.
[SerializeField] private Dictionary<StatTypes, StatBase> _statDictionary;
public bool TryGetStat(StatTypes type, out StatBase stat)
{
lock (_statDictionary)
if (_statDictionary.TryGetValue(type, out stat)) //error at line 99
return true;
return false;
}
Update: I used ConcurrentDictionary instead. It throws a similar error at line 1570.
I can not afford to understand this script.
bucketNo = (hashcode & 0x7fffffff) % bucketCount;
DivideByZeroException: Division by zero
System.Collections.Generic.Dictionary`2[GameSystems.StatSystem.StatTypes,GameSystems.StatSystem.StatBase].TryGetValue (StatTypes key, GameSystems.StatSystem.StatBase& value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:592)
GameSystems.StatSystem.StatDictionary.TryGetStat (StatTypes type, GameSystems.StatSystem.StatBase& stat) (at Assets/Scripts/GameSystems/StatSystems/StatDictionary/StatDictionary.cs:99)
GameSystems.StatSystem.EntityStatDictionary.get_Health () (at Assets/Scripts/GameSystems/StatSystems/StatDictionary/EntityStatDictionary.cs:40)
GameSystems.StatSystem.EntityStatDictionary.SetupLinkers () (at Assets/Scripts/GameSystems/StatSystems/StatDictionary/EntityStatDictionary.cs:313)
GameSystems.EntitySystems.EntityComponent.Load () (at Assets/Scripts/GameSystems/EntitySystems/EntityComponent.cs:172)
GameSystems.EntitySystems.EntityComponent.get_Entity () (at Assets/Scripts/GameSystems/EntitySystems/EntityComponent.cs:35)
GameSystems.EntitySystems.EntityComponent.Start () (at Assets/Scripts/GameSystems/EntitySystems/EntityComponent.cs:20)