Game.Prefabs.EventAchievementComponent
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Component used on Event prefabs to define achievements that should be awarded or processed when the event runs. The component holds an array of EventAchievementSetup entries (serializable) which are copied into the entity's DynamicBuffer
Fields
public EventAchievementSetup[] m_Achievements
Holds the list of achievements configured on the prefab. Each entry specifies an AchievementId, an optional frame delay before processing, and whether to bypass internal counters. This field is serialized and intended to be set in the prefab inspector.
Inner struct: EventAchievementSetup
- public AchievementId m_ID
Identifier for the achievement to trigger.
- public uint m_FrameDelay
Number of frames to wait before the achievement is processed (copied into EventAchievementData).
- public bool m_BypassCounter
When true, indicates the achievement should bypass counting logic (behavior defined by achievement systems).
Properties
- None declared on this component.
Constructors
public EventAchievementComponent()
Default parameterless constructor (implicit). Initialization logic happens in Initialize(EntityManager, Entity) rather than the constructor.
Methods
-
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds runtime archetype requirements for this prefab. Implementation adds ComponentType.ReadWrite() to the provided set so spawned entities include the EventAchievement component. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds prefab component requirements. Implementation adds ComponentType.ReadWrite() so the prefab entity has a DynamicBuffer to receive the configured achievements. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called when the prefab is converted into an ECS entity. Retrieves the DynamicBufferfrom the entity and populates it by copying each entry from m_Achievements into the buffer (mapping m_ID, m_FrameDelay, m_BypassCounter). This is where prefab data is transferred into runtime ECS data.
Usage Example
// Example: The component copies m_Achievements into the entity buffer during Initialize.
// You can read the buffer after the prefab has been initialized to inspect configured achievements.
public class ExampleUsage
{
public void InspectAchievements(EntityManager entityManager, Entity prefabEntity)
{
if (entityManager.HasComponent<EventAchievementData>(prefabEntity))
{
var buffer = entityManager.GetBuffer<EventAchievementData>(prefabEntity);
foreach (var item in buffer)
{
// item.m_ID, item.m_FrameDelay, item.m_BypassCounter are available here
UnityEngine.Debug.Log($"Achievement {item.m_ID} delay {item.m_FrameDelay} bypass {item.m_BypassCounter}");
}
}
}
}
Notes and tips: - Configure m_Achievements on the Event prefab in the editor/inspector to control which achievements an event produces. - The component ensures the prefab entity has the necessary ECS components (EventAchievementData buffer) so systems can process achievements at runtime.