CalendarPlugin class
Plugin for in-game calendar functionality.
Registers the Calendar resource and CalendarSystem to automatically advance the in-game clock each frame, plus the calendar change events.
Usage
app.addPlugin(CalendarPlugin(
config: CalendarConfig.farmingSim(),
));
// Access the calendar in systems
final calendar = world.getResource<Calendar>()!;
if (calendar.dayChangedThisFrame) {
// Handle daily reset
}
// Or subscribe to events
for (final event in world.eventReader<DayChangedEvent>().iter()) {
print('New day: ${event.newDay}');
}
Constructors
- CalendarPlugin({CalendarConfig config = const CalendarConfig(), int initialDay = 1, int? initialHour})
-
Creates a calendar plugin with optional configuration.
const
Properties
- config → CalendarConfig
-
Calendar configuration.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialDay → int
-
Initial day (default: 1).
final
- initialHour → int?
-
Initial hour (default: config.dayStartHour).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
App app) → void - Configures the app with this plugin's functionality.
-
cleanup(
) → void - Optional cleanup when the app is disposed.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited