using System; using System.Collections; using System.Collections.Generic; using AYellowpaper.SerializedCollections; using UnityEngine; namespace BITKit.GameSocket { public class UnitySocketService : MonoBehaviour,ISocketService { private readonly Dictionary _sockets=new(); public void Initialize() { _sockets.Clear(); foreach (var x in GetComponentsInChildren()) { _sockets.Add(x.Name, x); } } public IEnumerator> GetEnumerator() { return _sockets.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return _sockets.GetEnumerator(); } public int Count => _sockets.Count; public bool ContainsKey(string key) { return _sockets.ContainsKey(key); } public bool TryGetValue(string key, out ISocketComponent value) { return _sockets.TryGetValue(key, out value); } public ISocketComponent this[string key] => _sockets[key]; public IEnumerable Keys => _sockets.Keys; public IEnumerable Values => _sockets.Values; } }