devtools

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package devtools installs development-time plugin contributions (MCP bridge prefabs and playtest bots) separately from github.com/nsgo-dev/game/pkg/plugin.

Separating MCP and playtest wiring into this subpackage keeps shipped game binaries that import pkg/plugin from linking pkg/mcp, pkg/playtest, pkg/replay, and their transitive dependencies.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install(h *Host, ps ...Plugin) error

Install validates every plugin in ps against h and the process-global playtest registry before registering anything, then installs their bots, prefabs, and Install hooks in deterministic order (plugins in argument order, Prefabs in slice order, Bots in sorted key order).

Example
package main

import (
	"fmt"

	"github.com/nsgo-dev/game/pkg/entities"
	"github.com/nsgo-dev/game/pkg/mcp"
	"github.com/nsgo-dev/game/pkg/plugin"
	"github.com/nsgo-dev/game/pkg/plugin/devtools"
)

func main() {
	bridge := mcp.New(mcp.Config{})
	host := &devtools.Host{Bridge: bridge}

	kit := devtools.Plugin{
		Name:   "healthkit",
		Module: "example.com/healthkit",
		API:    plugin.APIVersion,
		Prefabs: []devtools.PrefabSpec{
			{Prefab: entities.NewPrefab("patient")},
		},
	}

	if err := devtools.Install(host, kit); err != nil {
		panic(err)
	}
	fmt.Println("installed:", host.Has("healthkit"))
	fmt.Println("has patient prefab:", bridge.HasPrefab("patient"))
}
Output:
installed: true
has patient prefab: true

Types

type Host

type Host struct {
	// Bridge receives plugin Prefabs when non-nil.
	Bridge *mcp.Bridge
	// contains filtered or unexported fields
}

Host holds the development-time registries that Install wires plugins into. Nil fields skip that kind of contribution.

func (*Host) Has

func (h *Host) Has(name string) bool

Has reports whether a devtools plugin named name has been installed on h.

func (*Host) Plugins

func (h *Host) Plugins() []plugin.Installed

Plugins returns the devtools plugins installed on h in installation order.

type Plugin

type Plugin struct {
	// Name uniquely identifies the plugin using the same rule as plugin.yaml's name.
	Name string
	// Module is the plugin's Go module path, matching go.mod and plugin.yaml when set.
	Module string
	// API must equal [plugin.APIVersion].
	API int
	// Prefabs lists prefabs registered on Host.Bridge in slice order.
	Prefabs []PrefabSpec
	// Bots maps playtest bot profile names to factories registered in the process-global playtest registry in sorted key order, once per process per owning plugin.
	Bots map[string]playtest.BotFactory
	// Install is an optional escape hatch called last after all declarative contributions have been validated and registered.
	Install func(*Host) error
}

Plugin declares a plugin's development-time contributions: MCP bridge prefabs and playtest bot profiles.

type PrefabSpec

type PrefabSpec struct {
	// Name is the prefab name registered on the Bridge. When Prefab is set and Name is empty, Prefab.Name() is used.
	Name string
	// Prefab registers an *entities.Prefab via Bridge.RegisterEntityPrefab.
	Prefab *entities.Prefab
	// Scene registers a self-contained single-root *sceneformat.SceneDoc via Bridge.RegisterScenePrefab.
	Scene *sceneformat.SceneDoc
	// Spawn registers a custom mcp.PrefabSpawner via Bridge.RegisterPrefab.
	Spawn mcp.PrefabSpawner
}

PrefabSpec describes one prefab that a devtools Plugin registers on Host.Bridge. Exactly one of Prefab, Scene, or Spawn must be non-nil.

Jump to

Keyboard shortcuts

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