Game.Prefabs.RandomLikeCountData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter
Summary:
Component data used by the game's ECS to describe how "like" counts (for example: social reactions, viral events or similar randomized counters) are generated for a prefab. Provides separate percentages for educated vs uneducated audiences, ranges for randomization of amounts and active days, a continuous multiplier, and an integer range used for "go viral" behavior. This struct is intended to be attached to prefab entities so systems can query and produce randomized like counts consistently across instances.
Fields
-
public float m_EducatedPercentage
Percentage (0–1 expected) of the audience classified as "educated" for the purposes of calculating likes. Systems can use this to weight or bias the randomization logic for different audience types. -
public float m_UneducatedPercentage
Percentage (0–1 expected) of the audience classified as "uneducated". Typically used together with m_EducatedPercentage to split the audience; the two do not necessarily need to sum to 1 depending on game logic. -
public float2 m_RandomAmountFactor
A float2 representing a min/max range used to randomize the base amount of likes (e.g., {min, max}). Systems read this to produce a random scalar multiplier or direct amount within this range. -
public float2 m_ActiveDays
A float2 representing the minimum and maximum number of days the likes remain "active" or continue accruing (e.g., {minDays, maxDays}). Used to determine duration for which the randomized liking behavior persists. -
public float m_ContinuousFactor
A continuous multiplier applied across ticks/frames/days to smooth or scale ongoing like accumulation (for example a decay or growth factor). -
public int2 m_GoViralFactor
An int2 representing a discrete range (e.g., {minChance, maxChance} or {minThreshold, maxThreshold}) used by the "go viral" logic. Systems can use this range to determine whether and how strongly an item goes viral.
Properties
- (none)
Constructors
public RandomLikeCountData()
Structs in C# provide a default parameterless constructor which initializes numeric fields to zero. Populate fields explicitly when creating an instance to ensure intended behavior.
Methods
- (none)
Implements marker interfaces IComponentData and IQueryTypeParameter; no instance methods are defined on this struct.
Usage Example
using Unity.Entities;
using Unity.Mathematics;
using Game.Prefabs;
// Create and add component to an entity (EntityManager approach)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(typeof(RandomLikeCountData));
var entity = entityManager.CreateEntity(archetype);
var likeData = new RandomLikeCountData
{
m_EducatedPercentage = 0.6f,
m_UneducatedPercentage = 0.4f,
m_RandomAmountFactor = new float2(10f, 50f), // random likes between 10 and 50
m_ActiveDays = new float2(1f, 7f), // active between 1 and 7 days
m_ContinuousFactor = 1.05f, // slight growth per tick/day
m_GoViralFactor = new int2(1, 100) // e.g., viral chance threshold range
};
entityManager.SetComponentData(entity, likeData);
// In a system, query entities with RandomLikeCountData and use values to compute like counts