Game.Prefabs.PostConfigurationData
Assembly:
Assembly-CSharp
Namespace:
Game.Prefabs
Type:
struct
Base:
System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
Represents configuration data for the in-game postal/post service prefab. This component holds a reference to the post service prefab entity and several integer configuration values that control how mail accumulates and how much outgoing mail is sent. Because it implements IComponentData it is a plain ECS component suitable for attaching to an entity (for example, a prefab or manager entity). Implementing IQueryTypeParameter makes it usable in certain query APIs.
Fields
-
public Entity m_PostServicePrefab
Reference to the Entity that represents the post service prefab (the building/manager prefab used to create post service instances). Use this to spawn instances or to inspect prefab-specific settings. -
public int m_MaxMailAccumulation
Maximum amount of mail that can accumulate in the system before some game behavior should treat the mail as "full" (for example: trigger deliveries, service degradation, or UI warnings). Typical values depend on game economy tuning; treat as a non-negative integer. -
public int m_MailAccumulationTolerance
Tolerance threshold used to determine when accumulation is considered problematic or when the system may start applying penalties or increased service priority. Lower values make the system more sensitive to accumulation. -
public int m_OutgoingMailPercentage
Percentage (0–100) of accumulated mail that is sent out/removed from the local system per delivery cycle. This controls how aggressive outgoing mail distribution is. Values outside 0–100 are possible at runtime (since this is an int) but should be avoided.
Properties
- This struct exposes no C# properties (only public fields).
As an IComponentData it behaves like a plain data container; modify fields directly when using EntityManager or system logic.
Constructors
public PostConfigurationData()
Default parameterless constructor provided by the runtime (value-type). You can create and initialize the struct with an object initializer as shown in the usage example below.
You can also define a custom constructor when creating the struct in your mod code if desired:
var cfg = new PostConfigurationData
{
m_PostServicePrefab = postPrefabEntity,
m_MaxMailAccumulation = 1000,
m_MailAccumulationTolerance = 200,
m_OutgoingMailPercentage = 25
};
Methods
- This struct has no methods. It is pure data used by systems that implement post/mail behavior.
Notes for modders
- To apply or change this configuration at runtime use EntityManager (or the relevant DOTS API) to AddComponentData or SetComponentData for the entity that represents the post system or prefab.
- Because this type is a simple blittable struct (IComponentData), it is safe and efficient to use in Jobs and Burst-compiled systems.
- If you want persistent changes across saves, ensure you modify the appropriate prefab/entity that is serialized by the game or hook into the game's prefab/config loading flow.
- Respect expected ranges for the integer fields (for example outgoing percentage 0–100) to avoid unexpected gameplay behavior.
Usage Example
// Example: attach configuration to a post-manager entity at startup
using Unity.Entities;
public class PostConfigBootstrap
{
public void Configure(EntityManager em, Entity postManagerEntity, Entity postPrefabEntity)
{
var config = new PostConfigurationData
{
m_PostServicePrefab = postPrefabEntity,
m_MaxMailAccumulation = 1200,
m_MailAccumulationTolerance = 150,
m_OutgoingMailPercentage = 30
};
// Add or update the component on the entity
if (em.HasComponent<PostConfigurationData>(postManagerEntity))
em.SetComponentData(postManagerEntity, config);
else
em.AddComponentData(postManagerEntity, config);
}
}