Game.Prefabs.AmbienceEmitterData
Assembly:
Game (assembly containing game types; exact assembly name as shipped with Cities: Skylines 2 may vary)
Namespace:
Game.Prefabs
Type:
struct
Base:
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
A lightweight ECS component used to mark an entity as an ambience emitter and carry the data needed by systems that process environmental sound/ambience. Contains a category/type for the ambience and a scalar intensity value. This struct is intended for use with Unity DOTS (Entities) in the Cities: Skylines 2 modding environment.
Fields
-
public GroupAmbienceType m_AmbienceType
Represents the category or kind of ambience produced by this emitter (for example, traffic, nature, crowd, industrial, etc.). The exact enum values are defined by GroupAmbienceType elsewhere in the codebase. Use this to filter or select appropriate audio/ambient handling per group. -
public float m_Intensity
A floating-point scalar controlling how strong or loud the ambience should be for this emitter. The codebase does not enforce a strict range in this struct; typical usage will treat values in a 0..1 range, but larger values may be used depending on downstream systems. Tune and test in-game to achieve the desired audible result.
Properties
- This type defines no managed properties; it exposes two public fields only.
Constructors
public AmbienceEmitterData()
Structs in C# always have a default parameterless constructor that zero-initializes fields. No explicit constructors are declared in the source.
(If you prefer a convenience constructor in your mod, you can create one in helper code when creating the component data.)
Methods
- This struct declares no methods. It is a plain data container (IComponentData) and a query-type marker (IQueryTypeParameter) used by systems and jobs.
Remarks / Notes
- IComponentData: This component is a pure data component that can be attached to entities via EntityManager or in an authoring workflow.
- IQueryTypeParameter: Allows this type to be used as a type parameter in ECS queries (for example, in Jobs or System queries that accept query-type parameters).
- Because this component is a simple value type, it is cheap to add/remove and copy between entities.
- Check the implementation of ambience-related systems in the game to understand how they interpret m_Intensity and m_AmbienceType (e.g., whether intensity is multiplied by distance attenuation, clamped, or aggregated across multiple emitters).
Usage Example
// Add or set AmbienceEmitterData on an entity using EntityManager
var emitter = entityManager.CreateEntity();
// Set as a simple ambience emitter with medium intensity
var ambience = new AmbienceEmitterData
{
m_AmbienceType = GroupAmbienceType.Nature, // example enum value
m_Intensity = 0.75f
};
entityManager.AddComponentData(emitter, ambience);
// Later, to modify intensity:
var current = entityManager.GetComponentData<AmbienceEmitterData>(emitter);
current.m_Intensity = 0.9f;
entityManager.SetComponentData(emitter, current);