Game.Events.AttendingEvent
Assembly:
Assembly-CSharp (game/mod runtime assembly where gameplay types are typically located)
Namespace: Game.Events
Type: struct
Base:
System.ValueType
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable
Summary: AttendingEvent is a small ECS component struct used to mark an entity as "attending" a particular event. It holds a single Entity reference (m_Event) pointing to the event entity. The struct implements ISerializable so it can be read/written by the Colossal.Serialization system and implements IQueryTypeParameter to be usable in query parameters within Unity DOTS/Entities contexts. This component is typically used in game logic or systems that need to know which event an entity is associated with (for example, citizens attending a festival).
Fields
public Unity.Entities.Entity m_Event
This field stores the Entity that represents the event being attended. Use Unity.Entities.Entity.Null to represent "no event". The field is serialized/deserialized by the ISerializable implementation so the component can be saved/loaded with the game's serialization pipeline.
Properties
- (none)
This struct exposes no properties — only a public field. Treat m_Event as the primary data member.
Constructors
public AttendingEvent()
No explicit constructors are defined in source; the default parameterless constructor will value-initialize the struct (m_Event == Entity.Null). You can construct an instance with an object initializer:new AttendingEvent { m_Event = someEventEntity }
.
Methods
-
public void Deserialize<TReader>(TReader reader) where TReader : Colossal.Serialization.Entities.IReader
Reads the component data from the provided reader. The implementation reads a single Entity into m_Event. This is used by the game's serialization system when loading or streaming entities. -
public void Serialize<TWriter>(TWriter writer) where TWriter : Colossal.Serialization.Entities.IWriter
Writes the component data to the provided writer. The implementation writes the m_Event Entity so the association is preserved across save/load and network serialization as supported by the Colossal serialization pipeline.
Usage Example
// Example: assign an event entity to a citizen entity using the EntityManager
using Unity.Entities;
using Game.Events;
void MarkEntityAsAttending(EntityManager entityManager, Entity citizenEntity, Entity eventEntity)
{
var attending = new AttendingEvent { m_Event = eventEntity };
if (entityManager.HasComponent<AttendingEvent>(citizenEntity))
{
entityManager.SetComponentData(citizenEntity, attending);
}
else
{
entityManager.AddComponentData(citizenEntity, attending);
}
}
// Example: check whether an entity is attending a specific event
bool IsAttendingEvent(EntityManager entityManager, Entity citizenEntity, Entity eventEntity)
{
if (!entityManager.HasComponent<AttendingEvent>(citizenEntity))
return false;
var attending = entityManager.GetComponentData<AttendingEvent>(citizenEntity);
return attending.m_Event == eventEntity;
}