La referencia de API proviene de los comentarios de documentación de Go en el código fuente y está redactada en inglés.
package steam
import "github.com/nsgo-dev/game/pkg/online/steam"Resumen
Package steam is experimental: its API and documented formats may change in a minor release. See the API stability policy. defines the engine-facing boundary for Steamworks user stats, achievements, leaderboards and rich presence. Native adapters implement Driver, while tests can use a fake without loading the Steam SDK.
Índice
- Variables
- type Driver
- type Entry
- type Platform
- func New(cx *core.Scope, driver Driver) (*Platform, error)
- func (p *Platform) Close() error
- func (p *Platform) Init(done func(Player, error))
- func (p *Platform) Player() Player
- func (p *Platform) Scores(board string, friends bool, limit int, done func([]Entry, error))
- func (p *Platform) SetPresence(key, value string, done func(error))
- func (p *Platform) SetStatFloat(id string, value float64, done func(error))
- func (p *Platform) SetStatInt(id string, value int64, done func(error))
- func (p *Platform) SignedIn() bool
- func (p *Platform) StoreStats(done func(error))
- func (p *Platform) Tick()
- func (p *Platform) Unlock(id string, done func(error))
- func (p *Platform) UploadScore(board string, score int64, keepBest bool, done func(error))
- type Player
Variables
var (
// ErrUnavailable reports that no Steamworks driver is available: New was given a nil scope or driver.
// ErrClosed reports a call on a Platform that is nil or has been closed.
ErrClosed = errors.New("steam: closed")
// ErrUnauthenticated reports that the driver initialized without a signed-in Steam user.
ErrUnauthenticated = errors.New("steam: unauthenticated")
)Tipos
type Driver interface {
Init(context.Context) (Player, error)
SetAchievement(context.Context, string) error
SetStatInt(context.Context, string, int64) error
SetStatFloat(context.Context, string, float64) error
StoreStats(context.Context) error
UploadScore(context.Context, string, int64, bool) error
QueryScores(context.Context, string, bool, int) ([]Entry, error)
SetRichPresence(context.Context, string, string) error
RunCallbacks()
Shutdown() error
}Driver is implemented by a Steamworks adapter. Calls are synchronous at the boundary and Platform posts completion callbacks to its core scope.
type Entry struct {
Rank int
SteamID, PersonaName string
Score int64
}Entry is one leaderboard row.
type Platform struct {
// contains filtered or unexported fields
}Platform wraps a Driver for one core scope. Use it from the scope's goroutine; every completion callback runs there through Scope.Post, and none runs once the scope is disposed.
func New(cx *core.Scope, driver Driver) (*Platform, error)New creates a Steam platform around driver and closes it when cx is disposed. A nil scope or driver returns ErrUnavailable.
func (p *Platform) Close() errorClose signs the user out and shuts the driver down. Later calls report ErrClosed; closing again does nothing.
func (p *Platform) Init(done func(Player, error))Init initializes the driver and signs the user in. done receives the player, or ErrUnauthenticated when the driver returns no Steam ID, or ErrClosed on a closed Platform.
func (p *Platform) Player() PlayerPlayer returns the signed-in user, or the zero Player before Init succeeds and after Close.
func (p *Platform) Scores(board string, friends bool, limit int, done func([]Entry, error))Scores queries up to limit entries of board, from the global range or, with friends, the player's friends.
func (p *Platform) SetPresence(key, value string, done func(error))SetPresence sets the rich presence key to value.
func (p *Platform) SetStatFloat(id string, value float64, done func(error))SetStatFloat sets the FLOAT stat id. Call StoreStats to commit it to Steam.
func (p *Platform) SetStatInt(id string, value int64, done func(error))SetStatInt sets the INT stat id. Call StoreStats to commit it to Steam.
func (p *Platform) SignedIn() boolSignedIn reports whether Init has signed in a Steam user.
func (p *Platform) StoreStats(done func(error))StoreStats commits the stats and achievements set since the last store.
func (p *Platform) Tick()Tick pumps the driver's Steam callbacks; call it once per fixed step.
func (p *Platform) Unlock(id string, done func(error))Unlock sets the achievement id. Call StoreStats to commit it to Steam.
func (p *Platform) UploadScore(board string, score int64, keepBest bool, done func(error))UploadScore submits score to board. With keepBest, Steam keeps the player's better score; otherwise it overwrites it.
type Player struct{ SteamID, PersonaName string }Player is the signed-in Steam user.