cardinal

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: LGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PreUpdate runs before the main update.
	PreUpdate = ecs.PreUpdate
	// Update runs during the main update phase.
	Update = ecs.Update
	// PostUpdate runs after the main update.
	PostUpdate = ecs.PostUpdate
	// Init runs once during world initialization.
	Init = ecs.Init
)
View Source
const MinEpochFrequency = 10

Variables

This section is empty.

Functions

func RegisterSystem

func RegisterSystem[T any](world *World, system func(*T), opts ...SystemOption)

Types

type BaseSystemState

type BaseSystemState struct {
	// contains filtered or unexported fields
}

func (*BaseSystemState) Logger

func (b *BaseSystemState) Logger() *zerolog.Logger

TODO: pass init args (similar to boot info) to get system name in logger. Logger returns the logger for the world.

func (*BaseSystemState) Tick

func (b *BaseSystemState) Tick() uint64

Tick returns the current tick of the world.

func (*BaseSystemState) Timestamp

func (b *BaseSystemState) Timestamp() time.Time

Timestamp returns the current timestamp of the world.

type Command added in v0.10.0

type Command = command.Payload

type CommandContext added in v0.10.0

type CommandContext[T Command] struct {
	Payload T
	Persona string
}

type Contains

type Contains[T any] = ecs.Contains[T]

type EntityID added in v0.10.0

type EntityID = ecs.EntityID

type Event added in v0.10.0

type Event = event.Payload

type Exact

type Exact[T any] = ecs.Exact[T]

type OtherWorld

type OtherWorld struct {
	Region       string
	Organization string
	Project      string
	ShardID      string
}

OtherWorld is a type that represents the address of an external service.

func (OtherWorld) SendCommand added in v0.10.0

func (o OtherWorld) SendCommand(state *BaseSystemState, cmd command.Payload)

SendCommand sends a command to an external service.

Example:

import external "another-game-shard/system"

// Define a shard address of one of your game shards. const MatchmakingService ecs.ServiceAddress = "world.argus.rampage.matchmaking"

func GameSystem(state *GameSystem) error {
  MatchmakingService.Send(state, &external.EndGameCommand{
    Winner: "Team 1",
  })
}

type Ref

type Ref[T ecs.Component] = ecs.Ref[T]

type SystemHook added in v0.10.0

type SystemHook = ecs.SystemHook

SystemHook defines when a system should be executed in the update cycle.

type SystemOption added in v0.10.0

type SystemOption func(*systemConfig)

SystemOption is a function that configures a SystemConfig.

func WithHook

func WithHook(hook SystemHook) SystemOption

WithHook returns an option to set the system hook.

type Tick added in v0.10.0

type Tick struct {
	// contains filtered or unexported fields
}

type WithCommand

type WithCommand[T Command] struct {
	// contains filtered or unexported fields
}

func (*WithCommand[T]) Iter added in v0.10.0

func (c *WithCommand[T]) Iter() iter.Seq[CommandContext[T]]

type WithEvent

type WithEvent[T Event] struct {
	// contains filtered or unexported fields
}

func (*WithEvent[T]) Emit added in v0.10.0

func (e *WithEvent[T]) Emit(evt T)

type WithSystemEventEmitter

type WithSystemEventEmitter[T ecs.SystemEvent] = ecs.WithSystemEventEmitter[T]

type WithSystemEventReceiver

type WithSystemEventReceiver[T ecs.SystemEvent] = ecs.WithSystemEventReceiver[T]

type World

type World struct {
	// contains filtered or unexported fields
}

World represents your game world and serves as the main entry point for Cardinal.

func NewWorld

func NewWorld(opts WorldOptions) (*World, error)

NewWorld creates a new game world with the specified configuration.

func (*World) StartGame

func (w *World) StartGame()

StartGame launches your game and runs it until stopped.

func (*World) Tick added in v0.10.0

func (w *World) Tick(ctx context.Context, timestamp time.Time) error

type WorldOptions

type WorldOptions struct {
	Region              string               // Region the shard is deployed to
	Organization        string               // The organization that owns this world
	Project             string               // Name of the project within the organization
	ShardID             string               // Unique ID for of world's instance
	TickRate            float64              // Number of ticks per second
	SnapshotStorageType snapshot.StorageType // Snapshot storage type
	SnapshotRate        uint32               // Number of ticks per snapshot
	Debug               *bool                // Enable debug server
}

Directories

Path Synopsis
internal
ecs

Jump to

Keyboard shortcuts

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