Game.Triggers.LifePathEvent
Assembly: Assembly-CSharp (game assembly)
Namespace: Game.Triggers
Type: public struct
Base: System.ValueType, IComponentData, IQueryTypeParameter, ISerializable
Summary:
LifePathEvent is an ECS component used by the game to represent a "life path" event tied to an entity. It stores a reference to the event prefab, the target entity affected by the event, and the scheduled date/time (in the game's internal uint format). The struct implements ISerializable so it can be read/written by the game's binary serialization system and implements IQueryTypeParameter so it can participate in entity queries.
Fields
-
public Entity m_EventPrefab
Reference to the event prefab entity that should be used/instantiated when the life path event triggers. This is typically an Entity that points to a prefab defined elsewhere in the game data. -
public Entity m_Target
The entity that the life path event targets. This is the entity that will be affected by the event when it occurs (for example, a citizen, building, or other in-game entity). -
public uint m_Date
Unsigned integer storing the scheduled date/time for the life path event. The value uses the game's internal encoding for dates/times (modders should treat it as an opaque uint unless converting with game date/time utilities).
Properties
- This type exposes no properties. All data is stored in public fields.
Constructors
public LifePathEvent()
Structs in C# have an implicit default constructor that zero-initializes fields. Typical use is to create and set the fields after construction. Example initialization shown in the Usage Example below.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component data to the provided writer in this order: m_EventPrefab, m_Target, m_Date. This is used by the game's serialization pipeline to persist the component state. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the component data from the provided reader in the same order as serialization (m_EventPrefab, m_Target, m_Date). The method reads directly into the struct's fields via ref locals.
Notes: - The Serialize/Deserialize methods are generic and depend on the game's IWriter/IReader abstractions; ensure the same ordering is respected when extending or manually manipulating serialized data. - Since this is an IComponentData, it is meant to be attached to entities via the EntityManager or within ECS systems.
Usage Example
// Example: creating an entity and attaching a LifePathEvent component
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
// Assume eventPrefabEntity and targetEntity are valid Entity values retrieved earlier,
// and scheduledDate is a uint representing the game's internal date encoding.
Entity lifeEventEntity = entityManager.CreateEntity();
entityManager.AddComponentData(lifeEventEntity, new LifePathEvent {
m_EventPrefab = eventPrefabEntity,
m_Target = targetEntity,
m_Date = scheduledDate
});
Additional tips: - Use the game's date/time helper functions (if available) to construct or interpret m_Date rather than guessing the encoding. - When creating or instantiating m_EventPrefab, ensure the referenced prefab entity is valid in the same world/scene context. - To find entities with LifePathEvent attached, use Entity queries that include the LifePathEvent component (IQueryTypeParameter support).