Documentation
¶
Index ¶
- Constants
- func RegisterSystem[T any](world *World, system func(*T), opts ...SystemOption)
- type BaseSystemState
- type Command
- type CommandContext
- type Contains
- type EntityID
- type Event
- type Exact
- type OtherWorld
- type Ref
- type SystemHook
- type SystemOption
- type Tick
- type WithCommand
- type WithEvent
- type WithSystemEventEmitter
- type WithSystemEventReceiver
- type World
- type WorldOptions
Constants ¶
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 )
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 CommandContext ¶ added in v0.10.0
type OtherWorld ¶
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 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 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 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.
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
}