Ejemplo n.º 1
0
 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());
     }
 }
Ejemplo n.º 2
0
 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}.");
     }
 }
Ejemplo n.º 3
0
 public void UnregisterComponent(SubscribableBehaviour unregisterBehaviour)
 {
     Debug.Log($"Unegistering {unregisterBehaviour} from ComponentContainer {this}.");
     _objectDictionary.Remove(unregisterBehaviour.GetType());
 }