Game.Notifications.Icon
Assembly: Game
Namespace: Game.Notifications
Type: struct
Base: System.ValueType
Summary:
Icon is a lightweight ECS component (IComponentData) that represents a notification icon in the world. It stores the icon's world position, priority, clustering layer and flags used by the game's notification/marker system. The struct is serializable via Colossal.Serialization (ISerializable) so it can be persisted and loaded. It is intended to be used as component data on an Entity in Unity's ECS.
Fields
-
public Unity.Mathematics.float3 m_Location
Stores the world position of the icon. This value is written and read during serialization and used to position the notification/gizmo in the world. -
public IconPriority m_Priority
Icon priority enum (stored as a byte during serialization). Determines ordering/visibility priority for icons. -
public IconClusterLayer m_ClusterLayer
Cluster layer enum (stored as a byte during serialization when supported by save version). Used by the icon clustering system to group icons. -
public IconFlags m_Flags
Flag enum for additional per-icon state (stored as a byte during serialization when supported by save version). The specific flags control runtime behavior/appearance. -
public int m_ClusterIndex
Runtime-only integer index used for clustering. Note: this field is not serialized/deserialized in the provided implementation (it is intended for runtime cluster bookkeeping only).
Properties
This type defines no C# properties (it exposes public fields and implements interfaces instead).
Constructors
public Icon()
No explicit constructor is defined in source; the default parameterless value-type constructor is used. Initialize fields manually or with an object initializer when creating an Icon instance.
Methods
-
public bool Equals(Icon other)
Implements IEquatable. Compares m_Location, m_Priority, m_ClusterLayer and m_Flags for equality. Note: comparison does not include m_ClusterIndex. The method uses single-ampersand (&) boolean combining so comparisons are evaluated without short-circuiting. -
public override int GetHashCode()
Returns the hash code of m_Location (calls m_Location.GetHashCode()). This means icons with different priority/flags but equal locations will produce the same hash code. -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Serializes the icon into writer. The implementation writes: - float3 location
- byte priority
- byte clusterLayer
-
byte flags Note that priority/clusterLayer/flags are cast to byte when written.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Deserializes data from reader into the struct. It reads: - float3 location
- byte priority (always read) If reader.context.version >= Version.iconClusteringData then it also reads:
- byte clusterLayer
- byte flags These bytes are cast back into the corresponding enums. The code relies on a save-version check (Version.iconClusteringData) to decide whether cluster/flag data is present.
Usage Example
// Create an Icon and add it as component data to an entity
using Unity.Entities;
using Unity.Mathematics;
using Game.Notifications;
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = em.CreateEntity();
// Initialize icon
Icon icon = new Icon {
m_Location = new float3(100f, 0f, 200f),
m_Priority = IconPriority.High,
m_ClusterLayer = IconClusterLayer.Default,
m_Flags = IconFlags.None,
m_ClusterIndex = -1 // runtime-initialized
};
// Add to entity
em.AddComponentData(e, icon);
// Example: serializing manually (used by game save system)
var writer = /* IWriter implementation provided by engine */;
icon.Serialize(writer);
// Example: deserializing manually
var reader = /* IReader implementation provided by engine */;
Icon loaded = new Icon();
loaded.Deserialize(reader);
Additional notes for modders: - IconPriority, IconClusterLayer, IconFlags and Version are defined elsewhere; consult the game's notification/clustering code for valid values and semantics. - m_ClusterIndex is not persisted to disk; it's used at runtime by clustering logic. - Equals and GetHashCode focus mainly on location and a subset of fields — be careful when using this type in hashed collections if you expect other fields to affect identity.