Skip to content

Game.Areas.LabelExtents

Assembly:
Game (inferred)

Namespace:
Game.Areas

Type:
public struct

Base:
Implements Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.IEmptySerializable

Summary:
Represents a 2D axis-aligned bounding extents used for label placement/area labelling. This struct is a DOTS dynamic buffer element (IBufferElementData) so multiple extents can be stored per entity. It wraps a Colossal.Mathematics.Bounds2 and is marked with InternalBufferCapacity(2) to hint an initial buffer capacity of 2 elements.


Fields

  • public Bounds2 m_Bounds
    Holds the 2D bounding box (min/max as float2). Bounds2 comes from Colossal.Mathematics and represents an axis-aligned rectangle in 2D space used to define the label extent.

Properties

  • None. This type exposes only a plain public field and no properties.

Constructors

  • public LabelExtents(float2 min, float2 max)
    Initializes the LabelExtents with the provided minimum and maximum 2D coordinates. Internally constructs a Bounds2 from min and max.

Methods

  • None. This struct only contains a field and a constructor; behavior is provided by consumers via the DOTS buffer APIs.

Notes / Additional Information

  • InternalBufferCapacity(2) attribute: provides a default inline capacity for the dynamic buffer when created via EntityManager.AddBuffer(). It reduces allocations when up to 2 elements are stored.
  • IEmptySerializable: indicates compatibility with the Colossal.Serialization system used by the game for serialization; no extra data is required beyond the fields.
  • Common usage scenarios: storing multiple label extents per entity (for areas with several labelable sub-rectangles), passing extents to layout or culling systems, or serializing extents with the game's save system.
  • Types referenced:
  • Bounds2 (Colossal.Mathematics): contains float2 min/max.
  • float2 (Unity.Mathematics): 2D vector type used for coordinates.

Usage Example

using Unity.Entities;
using Unity.Mathematics;
using Colossal.Mathematics;
using Game.Areas;

// ... inside some system or initialization code:
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = em.CreateEntity(); // or get an existing entity

// Add a dynamic buffer for LabelExtents to the entity
DynamicBuffer<LabelExtents> buffer = em.AddBuffer<LabelExtents>(e);

// Create and add extents
float2 min = new float2(0f, 0f);
float2 max = new float2(10f, 5f);
buffer.Add(new LabelExtents(min, max));

// The buffer can hold multiple extents; InternalBufferCapacity(2) will preallocate space for 2 elements.