Game.Companies.CompanyNotifications
Assembly: Assembly-CSharp.dll
Namespace: Game.Companies
Type: public struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
Component used to track company-related notification state in ECS. It stores counters and Entity references for two specific notification types: "no input" (e.g., company not receiving required supplies) and "no customers" (e.g., business has no customers). The struct implements ISerializable so its state can be saved/loaded by the game's serialization system and is usable as an ECS component (IComponentData / IQueryTypeParameter).
Fields
-
public short m_NoInputCounter
Counter that tracks how long (in ticks/frames or another unit the game uses) a company has been without input/supplies. Used to determine when to raise/clear a "no input" notification. -
public short m_NoCustomersCounter
Counter that tracks how long a company has had no customers. Used to determine when to raise/clear a "no customers" notification. -
public Entity m_NoInputEntity
Entity reference associated with the "no input" notification. Typically points to the notification entity (or other related entity) so systems can manage or remove that notification. -
public Entity m_NoCustomersEntity
Entity reference associated with the "no customers" notification. Typically points to the notification entity (or other related entity) so systems can manage or remove that notification.
Notes: Fields are plain value types and will be default-initialized (numeric fields to 0, Entity fields to Entity.Null) if the struct is created via the default constructor or added uninitialized to an entity.
Properties
- None.
This struct exposes no properties — only public fields.
Constructors
public CompanyNotifications()
No explicit constructor is defined in the source. The default parameterless constructor will initialize numeric fields to 0 and Entity fields to Entity.Null (the standard default for value types in C#). If you need non-default initial values, assign them after creating the struct instance.
Methods
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the component state from a serialized stream using reader.Read for each field in the following order: m_NoInputCounter, m_NoCustomersCounter, m_NoInputEntity, m_NoCustomersEntity. The method uses out/ref parameters to populate the struct fields. This must be kept consistent with Serialize to ensure correct save/load behavior. -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component state to a serialized stream using writer.Write for each field in the following order: m_NoInputCounter, m_NoCustomersCounter, m_NoInputEntity, m_NoCustomersEntity. The serialization order must match Deserialize.
Implementation details: - The methods are generic over reader/writer interfaces used by the game's serialization system (IReader/IWriter). - The serialization order is critical; altering it will break compatibility with existing saved data unless handled carefully.
Usage Example
// Add the component to an entity and initialize values
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
var companyEntity = em.CreateEntity();
// Create and initialize
CompanyNotifications notifs = new CompanyNotifications
{
m_NoInputCounter = 0,
m_NoCustomersCounter = 0,
m_NoInputEntity = Entity.Null,
m_NoCustomersEntity = Entity.Null
};
// Add to entity
em.AddComponentData(companyEntity, notifs);
// Later, update counters in a system (example in an ECS system)
var cn = em.GetComponentData<CompanyNotifications>(companyEntity);
cn.m_NoInputCounter++;
if (cn.m_NoInputCounter > SOME_THRESHOLD)
{
// create or link a notification entity and store it in m_NoInputEntity
}
em.SetComponentData(companyEntity, cn);
Additional notes: - Because this is an IComponentData, prefer modifying it within systems using EntityManager or ComponentDataFromEntity/ArchetypeChunk APIs to avoid race conditions. - The fact it implements ISerializable makes it automatically participate in the game's save/load pipeline (assuming the serialization system is configured to handle this component type). Ensure any changes to fields or serialization order are versioned or handled to preserve save compatibility.