Game.Prefabs.MailAccumulation
Assembly:
Assembly-CSharp (game runtime assembly; Cities: Skylines 2 game code is typically compiled into Assembly-CSharp)
Namespace:
Game.Prefabs
Type:
class
Base:
ComponentBase
Summary:
Component used on service/zone prefabs to configure mail accumulation behavior. The class exposes editor-configurable fields for whether mail must be collected and for sending/receiving accumulation rates. When a prefab is converted to an Entity, this component writes a MailAccumulationData component to the Entity with the configured values. The class is exposed in the editor menu under "Services/" and is intended for use on ServicePrefab and ZonePrefab types via the ComponentMenu attribute.
Fields
-
public bool m_RequireCollect
Flag indicating whether mail collection is required. This value is copied into MailAccumulationData.m_RequireCollect during prefab initialization. -
public float m_SendingRate = 1f
Sending accumulation rate (default 1.0). This value is written to the X component of MailAccumulationData.m_AccumulationRate during initialization. -
public float m_ReceivingRate = 1f
Receiving accumulation rate (default 1.0). This value is written to the Y component of MailAccumulationData.m_AccumulationRate during initialization.
Properties
- This class does not declare any properties.
Constructors
public MailAccumulation()
Implicit default constructor. No custom construction logic is defined in the class.
Methods
-
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Override provided but empty — this component does not add any component types at archetype creation time. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the runtime component type required on entities created from prefabs: -
Adds ComponentType.ReadWrite
() to the provided components set so the entity will have a MailAccumulationData component. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called during prefab-to-entity conversion/initialization. Behavior: - Calls base.Initialize(entityManager, entity).
- Creates a MailAccumulationData instance and sets:
- m_RequireCollect = m_RequireCollect (from the prefab/component field)
- m_AccumulationRate.x = m_SendingRate
- m_AccumulationRate.y = m_ReceivingRate
- Writes the configured MailAccumulationData to the entity via entityManager.SetComponentData(entity, componentData).
Notes: - MailAccumulationData is the ECS component holding runtime mail accumulation state; from usages here it contains at least a boolean m_RequireCollect and a 2-component accumulation rate (accessed as m_AccumulationRate.x and .y). - The class is decorated with: [ComponentMenu("Services/", new Type[] { typeof(ServicePrefab), typeof(ZonePrefab) })] which places it in the editor component menu under Services and restricts its intended prefab targets.
Usage Example
// Typical prefab component values are set in the editor. During conversion to an Entity,
// the Initialize method writes the data to the MailAccumulationData component:
public override void Initialize(EntityManager entityManager, Entity entity)
{
base.Initialize(entityManager, entity);
MailAccumulationData componentData = default(MailAccumulationData);
componentData.m_RequireCollect = m_RequireCollect;
componentData.m_AccumulationRate.x = m_SendingRate; // send rate
componentData.m_AccumulationRate.y = m_ReceivingRate; // receive rate
entityManager.SetComponentData(entity, componentData);
}
This ensures entities spawned from the prefab have MailAccumulationData initialized with the configured send/receive rates and collection requirement.