private void CheckComponentRegistered(SubscribableBehaviour subscribableBehaviour) { _awaitingRegister.TryGetValue(subscribableBehaviour.GetType(), out object tcsObject); if (tcsObject != null) { Type tcsType = typeof(TaskCompletionSource <>).MakeGenericType(subscribableBehaviour.GetType()); MethodInfo methodInfo = tcsType.GetMethod("SetResult"); methodInfo?.Invoke(tcsObject, new object[] { subscribableBehaviour }); _awaitingRegister.Remove(subscribableBehaviour.GetType()); } }
public void RegisterComponent(SubscribableBehaviour behaviour) { Debug.Log($"Registering {behaviour} in ComponentContainer {this}."); if (!_objectDictionary.ContainsKey(behaviour.GetType())) { _objectDictionary.Add(behaviour.GetType(), behaviour); behaviour.Destroyed += UnregisterComponent; ComponentRegistered?.Invoke(behaviour); } else { Debug.LogWarning($"Already registered {behaviour} in ComponentContainer {this}."); } }
public void UnregisterComponent(SubscribableBehaviour unregisterBehaviour) { Debug.Log($"Unegistering {unregisterBehaviour} from ComponentContainer {this}."); _objectDictionary.Remove(unregisterBehaviour.GetType()); }