Chris' Tutorials
Docs/Calendar Time

Class

AgeService

Generated GDScript class reference for CalendarTime.AgeService.

StatusCurrent
Versionv2.0
UpdatedGenerated from GDScript addon source
Source note:This page rendered plugin-owned docs or generated metadata inside unified Astro docs shell.

AgeService — a rough counter that bumps an AgeState when time advances. Services are RefCounted, not Nodes. This is the rule for every service in the plugin: no _ready, no _process, no scene tree, no NOTIFICATION_PREDELETE. Services are config + behaviour bound to GameClock; consumers (e.g. AgeComponent) are the scene-tree things. A Resource (RefCounted) that binds a GameClock and listens to its signal bus (game_seconds_advanced / date_changed) to advance the main AgeState in clock.age_registry (the clock's own per-clock AgeStateRegistry, constructed in GameClock._init). The AgeComponent (the scene-tree thing) holds per-game-object AgeState references and updates them when the registry fires age_progressed. Why this service keeps a GameClock reference (despite subscribing to its bus for events): it reads clock.calendar.get_scale() to convert elapsed game-seconds into the configured time unit (seconds / minutes / hours / days). Without the clock reference, no scale → no unit conversion. Drive modes (see AgeSettings.UpdateTime):

  • GAME_TIME_ELAPSED — advance per clock.signal_bus.game_seconds_advanced (sum of game seconds the clock moved).
  • DATE_CHANGED — advance once per day boundary crossed, by the full day's game seconds (so day-aligned ageing doesn't drift from sub-day frames).
  • REAL_TIME_ELAPSED — not supported on a RefCounted service. A scene-tree wrapper would be required to drive a per-frame tick; if you configure it, a warning is emitted at construction and the service stays idle until the clock emits game-time or date-changed events. Owned by the clock (clock.age_service). One age service per clock.

Source: addons/calendar_time/ageing/age_service.gd

Syntax

class AgeService extends Resource

Members

NameKindSummary
service_idPropertyUnique identifier for this service instance. Used for serialization (see Keys.SERVICE_ID) and for routing debug output. Setter re-registers the AgeState in `clock.age_registry` under the new key (and rebinds `main_age_id`) so changing the id post-construction keeps the registry in sync. Set BEFORE passing the service to consumers to avoid two services with the same default id colliding on a single clock's registry.
registryProperty
new_stateProperty
starting_agePropertyWhere the age service tells about changes to the age
age_settingsPropertyDefines how ageing operates inside the service
clockPropertyThe clock the service ages with. Subscribes to its bus for time_elapsed / date_changed. Set by the clock (clock.age_service setter wires `clock = self`). Setter also ensures the state is registered in `clock.age_registry` under `service_id`. This handles the `.tres`-load case where _init runs without a clock (the .tres has no clock ref), then the GameClock.age_service setter wires `clock = self` — at which point we register the state in the just-assigned clock's registry.
registryProperty
age_state_idProperty
seconds_changeProperty
progress_ageMethod
change_in_unitsProperty
change_in_ageProperty
registryProperty
stateProperty
scaleProperty
seconds_to_game_unitsMethod
validateMethod
okProperty
to_dictMethod
from_dictMethod
dataProperty
SCHEMA_VERSIONFieldBumped when an on-disk key changes shape. v2 stored service identity under the key "id"; v3 stores it under "service_id".
SERVICE_IDFieldSchema v3 key. Written by to_dict().
AGE_STATE_IDField
LEGACY_IDFieldLegacy v1/v2 key. Read-only — from_dict() auto-migrates it to SERVICE_ID when no SERVICE_ID is present. See MIGRATION.md §5.
get_keysMethod

Source

addons/calendar_time/ageing/age_service.gd

Plugin docs root:gdscript/plugins/calendar_time_dev/docs