EventContent
IEventContent
IEventContent is an extension of IContent that allows for a Milestone-based progression instead of an IStage based progression. A combination of both progression types is also possible.
Note
This is usually implemented as a Limited Time Event feature where players have a period of time to complete as many milestones as possible and claim their rewards after the event has ended.
As a player plays an IEventContent, they complete a linear track of IMilestone objects. Each milestone targets a specific ICurrency and specifies a target amount. These rewards exist in the main IContent, so an IEventSettings object is used to map IMilestone rewards to their counterpart entries in the core IContent.
Once a player is ready to claim their rewards, a globally available IEventSettings object is used via the IEventService to claim them when the player has returned to the main IContent. Refer to EventSettings for more information.
Note
This is done to avoid potential situations where data for the IEventContent is not available.
EventContent
A concrete implementation of IEventContent. Along with the concrete implementations of other event-related interfaces, this provides everything required to run an event.
Relationships
IEventContent — This interface extends IContent and defines a list of IMilestone objects as well as properties for IEventContentData.
IEventContentData — This interface extends IContentData and contains a list of IMilestoneData ids.
Note
There is no IEventContentSavedData
as the IEventContent just uses the IContentSavedData
IMilestone — This interface defines properties for IMilestoneData and IMilestoneSavedData, as well as properties associated with milestone progress and methods to activate and deactivate them.
IMilestoneData — This interface defines properties for the target ICurrency and the amount of ICurrency to collect.
IMilestoneSavedData — This interface defines a property used to serialize the milestone progress.
See EventSettings for more information on the rest of this diagram.
Runtime Flow
Milestone Logic
When an IContent is loaded, a check is done to determine if it is an IEventContent instance. If this is true, IMilestone objects are loaded and the current IMilestone is activated.
An active IMilestone tracks the ICurrency defined at currencyId and sends a ProgressMilestoneStateAction
each time it detects a positive change in that currency. Once the IMilestone has surpassed the targetAmount it dispatches a MilestoneClaimableAction
.
IEventContent listens to the MilestoneClaimableAction
and updates the milestoneCompletionInfo associated with IMilestoneData id.
The next eligible (not completed) IMilestone in the list is then activated if one exists, and the process repeats until all milestones are claimable or the event has finished.
Note
In addition to completing the IMilestone when its target is reached while playing the event, IdleKit provides another way to determine the completion time of the milestones using the Projection Service. If the player has automated any generator, the IProjectionService will calculate an estimated completion time for the milestones. The projected (estimated) completion time will be stored in the milestoneCompletionInfo that are used during the rewards claiming process.
Reward Claiming
After an event is complete, the reward claiming process can be performed in a IContent id that matches claimInContentId.
The claiming process look into the milestones and rewards mappings in the associated milestoneCompletionInfo. Each MilestoneCompletionInfo contains a timestamp and the corresponding milestone. If any timestamp from the list of milestoneCompletionInfo is before the event endTime, a ClaimEventRewardsStateAction
will be dispatched to grant the rewards associated with the completed milestones and set the boolean
value areRewardsClaimed to true.
Clearing Event Saved Data
Each limited-time event is identified based on an uniqueEventContentId. This means that an eventContentId can be reused multiple times without having persisting saved data. When loading an IContent, all content-specific saved data is deleted if the following conditions are true:
- The IEventContent has expired, specified by its associated IEventSettingsData
- The user's current active content is not the expired IEventContent
If the user is in an expired Content, they are forced into the main Content, and the content-specific saved data is deleted once the player loads the main Content.
Note
The IEventSettings is global and not content-specific, so it is not deleted when the event has expired.