using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DictionariesFSM<T>
{
private Dictionary<string, T> dictionary;
public DictionariesFSM()
{
this.dictionary = new Dictionary<string, T>();
}
public T GetValue(string key, T defaultValue = default)
{
T value;
if (!dictionary.TryGetValue(key, out value))
{
value = defaultValue;
}
return value;
}
public bool HasKey(string key)
{
return dictionary.ContainsKey(key);
}
public void SetValue(string key, T value)
{
if (!HasKey(key))
{
dictionary.Add(key, value);
}
else
{
dictionary[key] = value;
}
}
public void DeleteKey(string key)
{
if (HasKey(key))
dictionary.Remove(key);
}
public void ClearDictionary()
{
dictionary.Clear();
}
}