Skip to content

Game.Prefabs.SimulationWarning

Assembly:
Assembly-CSharp (game code / modding assembly)

Namespace:
Game.Prefabs

Type:
class

Base:
ComponentBase

Summary:
SimulationWarning is a prefab component used to mark a notification/icon entity with one or more notification categories. It is annotated with a ComponentMenu attribute so it appears under "Notifications/" in the editor (linked with NotificationIconPrefab). At initialization time it updates the NotificationIconDisplayData.m_CategoryMask on the entity by OR-ing bits for each IconCategory in m_Categories. The class overrides GetPrefabComponents and GetArchetypeComponents but leaves them empty (no extra prefab/archetype component registration performed here).


Fields

  • public IconCategory[] m_Categories
    Array of IconCategory values that this prefab should add to the entity's NotificationIconDisplayData category mask. During Initialize, each entry causes the corresponding bit to be set in NotificationIconDisplayData.m_CategoryMask (via m_CategoryMask |= (uint)(1 << (int)category)). If left null or empty, no category bits are changed.

Properties

  • None declared on this type.

Constructors

  • public SimulationWarning()
    Default parameterless constructor (compiler-generated). No special construction logic is defined in the source.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Empty override. The method is available to add component types that should be present on the prefab, but this implementation does not add any.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Empty override. The method is available to add component types that should be present on the entity archetype, but this implementation does not add any.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Initializes the component on the given entity. Behavior:

  • Calls base.Initialize(entityManager, entity).
  • If m_Categories is not null, retrieves the entity's NotificationIconDisplayData component, and for each IconCategory in m_Categories sets the corresponding bit in componentData.m_CategoryMask using a left shift and bitwise OR: componentData.m_CategoryMask |= (uint)(1 << (int)m_Categories[i]);
  • Writes the modified NotificationIconDisplayData back to the entity with entityManager.SetComponentData(entity, componentData).

Notes and cautions: - This assumes the entity already has a NotificationIconDisplayData component; otherwise entityManager.GetComponentData(entity) will fail. - The bit-shifted mask assumes IconCategory enum values are within [0..31]; using values >= 32 would overflow the 32-bit mask and should be avoided or handled differently.

Usage Example

// Example: creating a prefab or configuring the SimulationWarning component in code
var prefab = new EntityPrefab(); // hypothetical prefab creation
var simWarning = new SimulationWarning();
simWarning.m_Categories = new IconCategory[] {
    IconCategory.Simulation,    // example enum values
    IconCategory.Warning
};
// Add simWarning to prefab (actual API depends on prefab creation code)
// When the prefab is instantiated, Initialize(...) will set the corresponding bits
// on the entity's NotificationIconDisplayData.m_CategoryMask.

Additional implementation note: - The class is primarily data-driven: in the Unity editor / prefab authoring workflow you'd assign m_Categories in the inspector for the NotificationIconPrefab so that instantiated notification icon entities automatically include the desired category bits.