timer

command
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Command timer demonstrates the timer component as observable state. Five timers run side by side: a one-shot that fires once and stays readable, a repeating timer that restarts itself, a timer created paused and started by a key press, and two grouped timers whose sets are paused and resumed together by the P key - the combat bar freezes while the ui bar keeps counting.

Timers advance on their own each fixed tick; a game never calls an update function on them. Completions are read straight from the component - timer.Timer.JustCompleted against the current tick is the completion edge, and timer.Timer.CompletedOn keeps the tick of the last fire for as long as it is useful.

Group state lives in the timer.Groups resource, provided by castrum.WithTimer alongside the timer system. A group pause never writes the timers it holds: their Running fields stay as they were, and only their accumulation stops.

Each timer is its own entity, so any number of them can run for the same game: this program keeps five handles and reads them.

Run from the repository root:

go run ./examples/timer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL