Skip to content

Collector & Generator

Base Collector

The purpose of any IBaseCollectorEntity is to produce an amount of ICurrency at a set interval. The IBaseCollectorEntity class houses all the common functionality between generators and collectors, such as Duration, PayoutAmount, and purchase/collect behaviours.

Collector

The ICollectorEntity is designed to be a unique gameplay mechanic that can be purchased and allows players to collect non-game currency after a pre-set duration has elapsed manually.

components

Generator

The IGeneratorEntity is an essential concept of IdleKit. It enables the player to purchase, collect from, and automate the generators so they can start generating currencies, which allows further purchases (upgrades) of generator units and progression through the game (stages).

components

A key difference between generators and collectors is that generators can be automated to generate currency even while the player is offline, while players must manually collect from collectors. Generators also have unit targets.

Relationship

Below denotes the relationship between IBaseCollectorEntity with ICollectorEntity and IGeneratorEntity, along with short descriptions of each component and how they work with one another.

components

IBaseCollectorEntity

The IBaseCollectorEntity contains the shared fields for ICollectorEntity and IGeneratorEntity. It includes references to an associated saved data object" that persists its state and a static data object" that contains all its settings.

Note

For more information on IEntity, please visit the Understanding Entities page.

IGeneratorEntity

The IGeneratorEntity is an IEntity that represents a currency generator in a specific IStage. It is a self-contained controller that handles all logic of the particular Generator. In addition to fields in IBaseCollectorEntity, it contains references to an associated IGeneratorUnitTargetSequence and functionality related to its automation.

ICollectorEntity

The ICollectorEntity is an IEntity that represents a currency collector in a specific IContent. It is a self-contained controller that handles all logic of the particular collector.

IBaseCollectorEntityData

The IBaseCollectorEntityData is the IEntityData associated with the IBaseCollectorEntity. It holds references to the IBaseCollectorData and IBaseCollectorBalanceData for this base collector entity.

IGeneratorEntityData

The IGeneratorEntityData also contains an additional reference to an associated IGeneratorUnitTargetSequenceData. This data varies per stage.

ICollectorEntityData

Each ICollectorEntityData has a unique ICollectorData and ICollectorBalanceData pairing since Collectors persist within an IContent and do not change between Stages.

IBaseCollectorEntitySavedData

The IBaseCollectorEntitySavedData is the ISavedData associated with the IBaseCollectorEntity that stores all of its persisting save states, such as the purchase state and production state.

IGeneratorEntitySavedData

The IGeneratorEntitySavedData stores additional save state information, such as the generator unit count and automation state.

IBaseCollectorData

The IBaseCollectorData is one of the static data objects referenced in the IBaseCollectorEntityData. This data does not vary on a per-stage basis; as a result, the id within this data is often the name a generator is referred to by. The id is referenced in entities such as Goals or PlotPoints.

Tip

generator-05 means the IGeneratorEntity that has the IGeneratorData with id generator-05.

IBaseCollectorBalanceData

The IBaseCollectorBalanceData is the static data object that contains all balance values for an IBaseCollectorEntity, such as payout, duration, and upgrade requirements.

IGeneratorBalanceData

The IGeneratorBalanceData contains stage-specific balance values for the Generator, such as automation requirements and unit costs. This data varies per stage.

IGeneratorUnitTargetSequence, IGeneratorUnitTargetSequenceData, and IGeneratorUnitTargetData

These static data are specific to Generators. The IGeneratorUnitTargetSequence contains a collection of IGeneratorUnitTargetData referenced by the IGeneratorUnitTargetSequenceData. The player can reach unit targets by purchasing a certain number of generator units (customers). There is usually an associated reward that would be granted when reaching a target.

Generator States

The runtime of the IBaseCollectorEntity controller consists of various generator states that contain different sets of behaviours. They follow a State Pattern where each State implements the behaviour specific to that state (see https://en.wikipedia.org/wiki/State_pattern). When the IBaseCollectorEntity is initialized, it is set to a particular state depending on the information persisting in the IBaseCollectorEntitySavedData.

Throughout gameplay, the IBaseCollectorEntity would potentially move into a different state based on the player's actions. Currently, the following states are available in IdleKit.

IAutoCollectState

The IGeneratorEntity is in the AutoCollectState when it is automated. In this state, ICurrency would produce and collect currency automatically without user inputs. The IGeneratorEntity must be automated to be in this state. An ICollectorEntity will never enter this state since it cannot be automated.

IProduceState

The IBaseCollectorEntity is in the ProduceState when it is in the process of producing ICurrency for the player to collect. The IBaseCollectorEntity must be purchased, and the collection of the output currencies is not available yet.

IWaitToBuyState

This is the default IBaseCollectorEntity state before any user interaction. It stays dormant and does not produce until it is purchased. Once it is purchased, it would move to the ProduceState.

IWaitToCollectState

The IBaseCollectorEntity moves to this state from the ProduceState when the output currency generation is completed and available for the player to collect. After it is collected, the IBaseCollectorEntity moves to the ProduceState again.

Collector States

collector-states

When a Collector is purchased, it enters the WaitToCollectState if CanCollectOnBuy is true and ProduceState if false. Collectors cannot be automated, so they will never enter the AutoCollectState.

Generator States

generator-states

When a Generator is purchased, it always enters the IProduceState.

Shared Actions

During runtime, the IBaseCollectorEntity controller uses actions and state actions to communicate with the rest of IdleKit. There are derived implementations for all Base Collector actions and state actions, so other components can listen to the Generator/Collector specific Actions or the generic shared Base Collector actions.

There are also additional state actions and state actions specific to Generators, such as AutomateGeneratorStateAction or GeneratorUnitTargetHitStateAction.

Note

For more information on the Actions system, please refer to the Understanding Actions page.