public void UpdateNotifications() { foreach (NotificationInfo notificationInfo in allNotifications) { GameObject notificationPredicate = Instantiate(notificationInfo.notificationPredicatePrefab, transform); bool notificationSatisfied = notificationPredicate.GetComponent <INotificationPredicate>().EvaluatePredicate(); if (notificationSatisfied) { Debug.Log("Notification Satisfied!"); if (!addedNotifications.Contains(notificationInfo)) { OnNotificationAdded?.Invoke(notificationInfo); addedNotifications.Add(notificationInfo); } } else { Debug.Log("Notification Not Satisfied!"); if (allNotifications.Contains(notificationInfo)) { OnNotificationDeleted?.Invoke(notificationInfo); addedNotifications.Remove(notificationInfo); } } Destroy(notificationPredicate); } }
public void Notify(Notification notification) { notifications.Enqueue(notification); OnNotificationAdded?.Invoke(notification); }