heroiclabs / hiro

The server interface for the Hiro game framework.
https://heroiclabs.com/hiro/
Apache License 2.0
23 stars 10 forks source link

Hiro

The server interface for the Hiro game framework.

Hiro is a client and server framework built on top of Nakama server to rapidly build high performance, flexible, and composable gameplay systems like Achievements, Energies, Event Leaderboards, and much more.

The code is divided into a Go package of interfaces and a client package for one of these supported languages and game engines:

This repository maintains the public interfaces which make it easy to use the library from inside a Nakama game server project to extend and build additional gameplay systems. You can explore the features with an API client when you import the "hiro-openapi.yml" collection.

To learn more about Hiro and integrate it into your game project, have a look at these resources:

Reach out to Heroic Labs for more information about how to license Hiro as a developer or as part of a game studio.

Setup

  1. Set up the Go toolchain.

  2. Set up your Nakama project with Go.

  3. Add Hiro to your project as a dependency:

    go get "github.com/heroiclabs/hiro@latest"
  4. Sign up to the Heroic Cloud and contact us to obtain licenses to Hiro.

  5. Download and unzip the package. Add "hiro.bin" to your codebase.

  6. Follow the usage instructions for how to get started.

Usage

The game framework initializes and returns the configured gameplay systems with Init:

package main

import (
    "context"
    "database/sql"
    "github.com/heroiclabs/hiro"
    "github.com/heroiclabs/nakama-common/runtime"
)

func InitModule(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, initializer runtime.Initializer) error {
    systems, err := hiro.Init(ctx, logger, nk, initializer, "hiro.bin", "LicenseKey",
        hiro.WithEconomySystem("economy.json", true),
        hiro.WithEnergySystem("energy.json", true),
        hiro.WithInventorySystem("inventory.json", true))
    if err != nil {
        return err
    }

    // systems.GetEnergySystem().Get(...)
    // ...

    return nil
}

For examples on how to write data definitions for the gameplay systems have a look at the documentation.

License

This codebase is licensed under the Apache-2 License.