Game.Areas.Geometry
Assembly: Assembly-CSharp
Namespace: Game.Areas
Type: struct
Base: Unity.Entities.IComponentData
, Unity.Entities.IQueryTypeParameter
, Colossal.Serialization.Entities.IEmptySerializable
Summary:
Represents basic geometric metadata for an area used by the game's ECS (Entity Component System). Stores a 3D bounding volume (Bounds3
), the geometric center as a float3
, and a precomputed surface area. Implementing IComponentData
makes this usable as an ECS component; IQueryTypeParameter
allows it to be used in queries; IEmptySerializable
indicates simple/empty serialization support for the game's serialization system.
Fields
-
public Bounds3 m_Bounds
Represents the axis-aligned 3D bounds of the area. Used for spatial tests, culling or overlap queries.Bounds3
comes fromColossal.Mathematics
. -
public float3 m_CenterPosition
The center position of the geometry (typically the centroid or the bounding-box center) in world or local coordinates depending on context. Useful for positioning, distance calculations or LOD decisions. -
public float m_SurfaceArea
A single-precision float storing the surface area of the area/geometry. Can be used for gameplay logic, weighting, or performance heuristics (e.g., larger areas may require different processing).
Properties
- This struct does not expose any C# properties; it only contains public fields.
Constructors
public Geometry()
Structs in C# have an implicit parameterless constructor. By default,m_Bounds
will be its default value,m_CenterPosition
will befloat3.zero
, andm_SurfaceArea
will be0f
. Initialize explicitly when creating instances to avoid default/empty values.
Methods
- This type does not define any methods. Behavior is entirely data-driven; operations on geometry should be implemented elsewhere (systems, utility functions, or jobs).
Usage Example
// Example: Creating an entity with a Geometry component and setting its data.
using Unity.Entities;
using Unity.Mathematics;
using Colossal.Mathematics;
using Game.Areas;
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(typeof(Geometry));
var entity = entityManager.CreateEntity(archetype);
// Construct or compute a Bounds3 as appropriate for your data.
// This example uses placeholder values — replace with actual bounds computation.
Bounds3 bounds = new Bounds3(new float3(-1, 0, -1), new float3(1, 2, 1)); // example constructor
float3 center = (bounds.Min + bounds.Max) * 0.5f;
float surfaceArea = 4.0f; // compute based on your geometry
entityManager.SetComponentData(entity, new Geometry {
m_Bounds = bounds,
m_CenterPosition = center,
m_SurfaceArea = surfaceArea
});
Additional notes:
- Because Geometry
is a pure data container, any transformations, area computations, or updates should be performed in systems (e.g., Conversion systems, update jobs) that set or refresh this component.
- The IEmptySerializable
marker implies minimal/custom serialization handling — ensure serializer expectations (if any) are met when persisting/loading components.