Skip to content

Projection Service

The IProjectionService is IdleKit's solution to provide an estimation of the player's future ICurrency income at any point in time. It calculates payout projections which represent the amount of currency that the player will earn, over a period of time. These earnings can be any currency which is being generated automatically, for instance, via an automated IGeneratorEntity.

IPayoutProjection can be used for a number of purposes. Internally within IdleKit they are used to work out predicted IMilestone completion times. But they could also be passed to the backend and used for rewarded Leaderboard generation, or for push notifications informing the player how much currency they have earned since they left the game.

Overview

Below demonstrates how different services and tools use currency projections in IdleKit.

projectionservice

  • The DebugTimeSkipTool uses the IProjectionService to calculate how much the player should gain after x hours. We recommend you to replicate this functionality when implementing timeskips within your game.

  • IEventService also uses the service to estimate when the milestones will be completed when the player backgrounds the app - OnApplicationPause - and every 15 seconds. This means that if the player returns to the app after an event is over, they will still receive the correct milestone rewards that they would have if they had been constantly active within the game.

Components

Payout Projection

The model class represents the payout that the game can generate before a certain expiry timestamp. It contains a timestamp and an ICurrency generation rate per millisecond for all currencies. This value is calculated by the IProjectionService.

The following graph shows the Payout Projections for a particular ICurrency with multiple generators and timed boosts expiring at different timestamps. The X axis denotes the timestamp while the Y axis shows the payout of the ICurrency per millisecond. Each Payout Projection expires when an ITimedBoost expires with the last projection having an indefinite expiration time with payoutRate composed of all automated generators payout (no boost).

payoutprojections

Projection Service

The main IService interface for all the projection functionality. It can provide the completion timestamp to achieve a certain amount of currencies or the amount of currencies the game produces at a certain timestamp in the future without any player input (automatic generation). Internally, it generates the payout projections and passes them into the IProjectionCalculator, which performs the actual projection calculations.

Projection Calculator

The IProjectionCalculator is the helper class that handles the actual calculation of the projections. The default implementation of the IProjectionCalculator in IdleKit takes the payout projections calculated by the IProjectionService and use it to approximate the earnings or completion date.