Documentation
¶
Overview ¶
Package game provides runtime infrastructure for loading and managing game entities. It bridges static data structures with active game objects that participate in the event system.
This package is rule-agnostic and focuses solely on infrastructure concerns like entity lifecycle, event bus integration, and state management patterns.
Example:
// Create context with game infrastructure
ctx := context.Background()
gameCtx, err := game.NewContext(eventBus, characterData)
if err != nil {
// Handle validation error
}
// Access data through getter methods
data := gameCtx.Data()
bus := gameCtx.EventBus()
// Load entity (implementation in rulebook/entity package)
character, err := LoadCharacterFromContext(ctx, gameCtx)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context[T any] struct { // contains filtered or unexported fields }
Context provides a consistent pattern for loading game entities from data. It combines the entity's data with the game infrastructure needed for runtime operations.
The generic type T represents the data structure for the specific entity being loaded. For example: Context[RoomData], Context[CharacterData], etc.
This pattern ensures:
- Consistent loading signatures across all entity types
- Self-contained data (T has everything needed to reconstruct the entity)
- Access to game infrastructure (event bus, future systems)
- Clean separation between data and behavior
Context is immutable after creation to guarantee validity.
func NewContext ¶
NewContext creates a new Context with the provided infrastructure and data. Both eventBus and data are required - returns error if either is nil/zero.