Game.Triggers.Chirp
Assembly:
Assembly-CSharp (game code / modding assembly)
Namespace:
Game.Triggers
Type:
struct
Base:
IComponentData, IQueryTypeParameter, ISerializable
Summary:
Represents a single "chirp" (short social message) used by the game's trigger/notification system. Stored as an ECS component (IComponentData) and supports custom (de)serialization via ISerializable. Contains the sender entity, creation frame, like counts and growth/virality parameters as well as compatibility-aware serialization that reads/writes fields depending on save/version flags.
Fields
-
public Entity m_Sender
Entity that created/sent the chirp. Written first during serialization and restored first during deserialization. -
public uint m_CreationFrame
Frame index when the chirp was created. Serialized after m_Sender. -
public uint m_Likes
Current number of likes the chirp has. Present in save versions >= Version.chirpLikes. Default initialized to 0 in the constructor. -
public uint m_TargetLikes
Target likes used for random/gradual propagation behavior. Present in save versions >= Version.randomChirpLikes. Default 0. -
public uint m_InactiveFrame
Frame when the chirp became inactive (used to time reactivation / lifetime). Present in save versions >= Version.randomChirpLikes. Default 0. -
public int m_ViralFactor
Integer multiplier / factor affecting how viral the chirp is. Present in save versions >= Version.randomChirpLikes. Default initialized to 1. -
public float m_ContinuousFactor
Float factor used for continuous-like growth behavior. Present in save versions >= Version.continuousChirpLikes. Default initialized to 0.2f. -
public ChirpFlags m_Flags
Flags describing chirp state/metadata. Stored as a single byte in serialization (cast to/from byte). Present in save versions >= Version.chirpLikes. Default is 0.
Properties
- None. (All data members are public fields; no C# properties are declared in this struct.)
Constructors
public Chirp(Entity sender, uint creationFrame)
Initializes a new Chirp with the provided sender and creation frame. Sets default values:- m_Likes = 0
- m_Flags = 0
- m_TargetLikes = 0
- m_InactiveFrame = 0
- m_ViralFactor = 1
- m_ContinuousFactor = 0.2f
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the chirp fields to the given writer in this order:- m_Sender (Entity)
- m_CreationFrame (uint)
- m_Likes (uint)
- m_Flags (written as a byte)
- m_TargetLikes (uint)
- m_InactiveFrame (uint)
- m_ViralFactor (int)
- m_ContinuousFactor (float)
The writer must be compatible with the game's IWriter; the code assumes the same ordering on read.
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads fields from a reader, honoring save-version compatibility:- Always reads m_Sender and m_CreationFrame.
- If reader.context.version >= Version.chirpLikes:
- Reads m_Likes and a byte for flags (m_Flags).
- If reader.context.version >= Version.randomChirpLikes:
- Reads m_TargetLikes, m_InactiveFrame, and m_ViralFactor.
- If reader.context.version >= Version.continuousChirpLikes:
- Reads m_ContinuousFactor.
Fields not present in older save versions remain at their default values from construction (or default struct values if constructed by deserialization without calling the constructor).
Usage Example
// Creating a chirp component for an entity
Entity sender = ...; // some existing entity
uint currentFrame = (uint)Time.frameCount;
Chirp chirp = new Chirp(sender, currentFrame);
// Adjusting runtime values
chirp.m_TargetLikes = 50;
chirp.m_ViralFactor = 2;
chirp.m_ContinuousFactor = 0.25f;
// Serialization (example; actual writer comes from game's save system)
writer.Write(chirp.m_Sender);
writer.Write(chirp.m_CreationFrame);
writer.Write(chirp.m_Likes);
writer.Write((byte)chirp.m_Flags);
writer.Write(chirp.m_TargetLikes);
writer.Write(chirp.m_InactiveFrame);
writer.Write(chirp.m_ViralFactor);
writer.Write(chirp.m_ContinuousFactor);
// When deserializing, code checks save version and fills only available fields,
// leaving newer fields at their defaults when loading older saves.
Notes: - ChirpFlags and Version are external enums/constants referenced by the struct; consult their definitions for full semantics of flags and version thresholds. - Because Chirp is an ECS component (IComponentData), it's intended to be stored on entities and queried via Unity.Entities/ECS systems. Serialization routines allow persisting chirps across saves while maintaining backward compatibility with older save formats.