using UnityEngine;
namespace DTT.Utils.Optimization.Demo
{
internal class LazyDictionaryBehaviour : MonoBehaviour
{
///
/// This dictionary holds, for each tag, a reference to all the game objects with that tag. The operation
/// to retrieve the game objects will only be done the first time the value is used.
///
private readonly LazyDictionary
_lazyDictionary = new LazyDictionary();
///
/// The tag of enemies.
///
private const string ENEMIES_TAG = "Enemies";
///
/// The tag of friends.
///
private const string FRIENDS_TAG = "Friends";
///
/// Initializes the lazy dictionary with the operations to retrieve the tagged game objects.
///
private void Awake()
{
_lazyDictionary.Add(ENEMIES_TAG, () => GameObject.FindGameObjectsWithTag(ENEMIES_TAG));
_lazyDictionary.Add(FRIENDS_TAG, () => GameObject.FindGameObjectsWithTag(FRIENDS_TAG));
}
}
}