Skip to content

Game.UI.InGame.NotificationInfo

Assembly: Assembly-CSharp (game assembly)
Namespace: Game.UI.InGame

Type: class

Base: System.Object, System.IComparable

Summary:
NotificationInfo is a lightweight container used by the in-game notification system to group and manage notification targets and their display priority. It wraps the information carried by a Notification instance (entity, target and priority) and maintains an internal list of targets so multiple related targets can be merged under a single notification entry. Comparison is provided so NotificationInfo objects can be sorted by priority when the UI decides display order.


Fields

  • private readonly System.Collections.Generic.List<Unity.Entities.Entity> m_Targets
    Holds the list of target Entities associated with this notification. The list is initialized in the constructor with a default capacity of 10 and starts containing the initial notification.target. Used to aggregate multiple targets for a single notification and to compute the current target count.

Properties

  • public Unity.Entities.Entity entity { get; }
    The originating entity for the notification. Populated from the Notification passed to the constructor.

  • public Unity.Entities.Entity target { get; }
    The primary target entity for the notification (also the first element of m_Targets).

  • public int priority { get; }
    Numeric priority value copied from the Notification. Used by CompareTo to determine sort order.

  • public int count { get; }
    Returns the number of targets currently stored in m_Targets. Implemented as m_Targets?.Count ?? 0. Because m_Targets is initialized in the constructor this will normally be the current list count.

Constructors

  • public NotificationInfo(Notification notification)
    Creates a new NotificationInfo from a Notification instance. Copies notification.entity, notification.target and notification.priority into the corresponding properties and initializes m_Targets with the initial target. Assumes the provided Notification has the expected fields; it does not perform null checks on Notification (Notification is expected to be a valid object/struct in this codebase).

Methods

  • public void AddTarget(Unity.Entities.Entity otherTarget)
    Adds another target entity to the internal m_Targets list if it is not already present. Uses List.Contains to avoid duplicates. Note: not thread-safe; calling code should handle synchronization if used from multiple threads.

  • public int CompareTo(NotificationInfo other)
    Implements IComparable. Returns this.priority - other.priority. When used for sorting, a negative return value indicates this instance has a lower priority value than other. Larger numeric priority values will sort after smaller ones using the default ascending sort.

Usage Example

// Create from an existing Notification (assumes a Notification object is available)
var info = new NotificationInfo(notification);

// Add an additional target (will be ignored if already present)
info.AddTarget(anotherTargetEntity);

// Check how many targets are aggregated
int targetCount = info.count;

// Sort a list of NotificationInfo objects by priority (ascending)
var list = new List<NotificationInfo> { info, otherInfo };
list.Sort(); // uses CompareTo -> ascending by priority

Additional notes: - Entity refers to Unity.Entities.Entity (an ECS entity struct). Equality and Contains checks use Entity's equality implementation. - Notification is expected to expose entity, target and priority fields/properties; adjust usage accordingly if Notification's API differs. - This class is a simple data holder and not designed for concurrent access without external synchronization.