Exemple #1
0
 private void CheckRegisteredComponent <T>(SubscribableBehaviour subscribableBehaviour, TaskCompletionSource <T> tcs) where T : SubscribableBehaviour
 {
     if (subscribableBehaviour is T behaviour)
     {
         tcs.SetResult(behaviour);
     }
 }
Exemple #2
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());
     }
 }
Exemple #3
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}.");
     }
 }
Exemple #4
0
        public async Task CacheAndRegister(SubscribableBehaviour subscribableBehaviour)
        {
            await Cache(subscribableBehaviour);

            Ref.RegisterComponent(subscribableBehaviour);
        }
Exemple #5
0
 public void UnregisterComponent(SubscribableBehaviour unregisterBehaviour)
 {
     Debug.Log($"Unegistering {unregisterBehaviour} from ComponentContainer {this}.");
     _objectDictionary.Remove(unregisterBehaviour.GetType());
 }