Tracking Offline Activity
An offline activity is defined as a game state progression that happens in the game while the app is closed or in the background. These could be IGeneratorEntity automatic collection or ITimedBoost expirations. The moment the app resumes IdleKit's ActivityTrackingService will attempt to process those offline activities by simulating time since the player left the game and updating game state accordingly. This simulation starts when the player exits and brings the game up to date with SystemTime.
The Flow
Note
Any time an action is performed in the game or when the app is sent to the background the GameTime is recorded in the IUserSavedData along with the current ContentId . This serialized timestamp allows the ActivityTrackingService to know the time at which the player went offline.
![]()
Note
Refer to the startup document to learn more about the startup process.
-
During startup or when the app is paused the
ActivityTrackingServicereads the timestamp inIUserSavedDatacorresponding to the currentContentId(the timestamp of the last activity performed in the currentIContent). -
The timestamp from the
IUserSavedDatais used to set theGameTimeas the starting point of the offline catchup. -
After the
IContentis initialized or the app is unpaused (returned to the foreground) before any other gameplay logic happens, theActivityTrackingServicewould then catch up from the previously setGameTimeto the currentSystemTime. -
The first half of the catchup process involves gathering all the
timer listenersthat have expired between theGameTime(start of the offline activities) and theSystemTime(end of the offline activities). The list is then filtered as we are only interested listeners that effect payout in the game (i.e.,timed boosts). Lastly, the list gets sorted based on thetimer listenersendTime chronologically. -
During the second half of the catchup logic, we set the
GameTimeto each sortedtimer listenersexpiration time. Doing so allows us to perform time evaluations before each listener has expired (i.e., performIGeneratorEntitycollect evaluation before anITimedBoostexpires). After all thetimer listenershave been processed, the offline catchup logic is complete, and theGameTimeis set to theSystemTime.