Documentation ¶
Index ¶
- func NewSelectionForm() form.Form
- func Perform(pos cube.Pos, s Shape, a Action, w *world.World) (revert func())
- func RegisterAction(name string, v func() Action)
- func RegisterShape(name string, v func(r int) Shape)
- func Unbind(i item.Stack) item.Stack
- type Action
- type BindCommand
- type Brush
- type Handler
- type SelectionForm
- type Shape
- type UnbindCommand
- type UndoCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSelectionForm ¶
NewSelectionForm returns a new SelectionForm form.
func Perform ¶
Perform performs the world edit action passed in a specific shape, in the world that is passed. Perform will only ever edit blocks found within the shape passed. Perform returns a function which may be called to undo the modification.
func RegisterAction ¶
RegisterAction registers a function that returns an act.Action with the name of the action passed.
func RegisterShape ¶
RegisterShape registers a function that returns a geo.Shape with the name of the shape passed.
Types ¶
type Action ¶
type Action interface { // At returns the world.Block and world.Liquid behind it that should be placed at a specific x, y and z in the // *world.World passed. // At should use the *rand.Rand instance passed to produce random numbers and must only use the at function to // read blocks at a specific position in the world. // If At returns a nil world.Block, no block will be placed at that position. At(x, y, z int, r *rand.Rand, w *world.World, at func(x, y, z int) world.Block) (world.Block, world.Liquid) // Form returns a form that has to be submitted by a player in order to provide additional values for the // action. Actions that do not need additional data can return nil for this value. The geo.Shape selected by // the *player.Player is passed to the function. Form(s Shape) form.Form }
Action is a brush action that may be performed on all blocks in a Shape through a call to Perform.
type BindCommand ¶
type BindCommand struct { Sub cmd.SubCommand `cmd:"bind"` // contains filtered or unexported fields }
BindCommand implements the binding of a Brush to an item in the player's inventory.
type Brush ¶
type Brush struct {
// contains filtered or unexported fields
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements the brushing of players. It enables activation of brushes and stores the data needed to undo/redo those actions.
func LookupHandler ¶
LookupHandler finds the Handler of a specific player.Player, assuming it is currently online.
func NewHandler ¶
NewHandler creates a new Handler for the *player.Player passed.
func (*Handler) HandleItemUse ¶
HandleItemUse activates the brush on a player's item if present.
func (*Handler) HandleQuit ¶
func (h *Handler) HandleQuit()
HandleQuit deletes the Handler from the handlers map.
func (*Handler) UndoLatest ¶
UndoLatest undoes the latest brush action. If no action was left to undo, false is returned.
type SelectionForm ¶
SelectionForm is a form that is sent when the player binds a brush to an item. It will allow the user to select a brush shape and action, and will follow up with another form with specific buttons to alter the behaviour of the action.
type Shape ¶
type Shape interface { // Inside checks if a specific X, Y and Z is within the shape with centre position (cx, cy, cz). If this is // the case, Inside returns true. Inside(cx, cy, cz, x, y, z int) bool // Dim returns the dimensions of the shape in blocks. Dim() [3]int }
Shape represents a shape over which an Action may be performed through a call to Perform.
type UnbindCommand ¶
type UnbindCommand struct { Sub cmd.SubCommand `cmd:"unbind"` // contains filtered or unexported fields }
UnbindCommand implements unbinding of a Brush previously attached to an item in the player's inventory using /brush bind.
type UndoCommand ¶
type UndoCommand struct { Sub cmd.SubCommand `cmd:"undo"` // contains filtered or unexported fields }
UndoCommand implements the undoing of one of the most recent actions performed by a player using a Brush.