world

package
v4.2.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type    EventType
	Payload interface{}
}

ffjson: nodecoder

func (*Event) MarshalJSON

func (j *Event) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*Event) MarshalJSONBuf

func (j *Event) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

type EventType

type EventType uint8
const (
	EventTypeError EventType = iota
	EventTypeObjectCreate
	EventTypeObjectDelete
	EventTypeObjectUpdate
	EventTypeObjectChecked
)

func (EventType) MarshalJSON

func (event EventType) MarshalJSON() ([]byte, error)

func (EventType) String

func (event EventType) String() string

type Identifier

type Identifier uint32

func (Identifier) String

func (i Identifier) String() string

type IdentifierRegistry

type IdentifierRegistry struct {
	// contains filtered or unexported fields
}

func NewIdentifierRegistry

func NewIdentifierRegistry() *IdentifierRegistry

func (*IdentifierRegistry) Obtain

func (ir *IdentifierRegistry) Obtain() Identifier

func (*IdentifierRegistry) Release

func (ir *IdentifierRegistry) Release(id Identifier)

type Interface

type Interface interface {
	Start(stop <-chan struct{})
	Events(stop <-chan struct{}, buffer uint) <-chan Event
	GetObjectByDot(dot engine.Dot) interface{}
	GetObjectsByDots(dots []engine.Dot) []interface{}
	CreateObject(object interface{}, location engine.Location) error
	CreateObjectAvailableDots(object interface{}, location engine.Location) (engine.Location, error)
	DeleteObject(object interface{}, location engine.Location) error
	UpdateObject(object interface{}, old, new engine.Location) error
	UpdateObjectAvailableDots(object interface{}, old, new engine.Location) (engine.Location, error)
	CreateObjectRandomDot(object interface{}) (engine.Location, error)
	CreateObjectRandomRect(object interface{}, rw, rh uint8) (engine.Location, error)
	CreateObjectRandomRectMargin(object interface{}, rw, rh, margin uint8) (engine.Location, error)
	CreateObjectRandomByDotsMask(object interface{}, dm *engine.DotsMask) (engine.Location, error)
	LocationOccupied(location engine.Location) bool
	Area() engine.Area
	GetObjects() []interface{}
	IdentifierRegistry() *IdentifierRegistry
}

type World

type World struct {
	// contains filtered or unexported fields
}

func NewWorld

func NewWorld(width, height uint8) (*World, error)

func (*World) Area

func (w *World) Area() engine.Area

func (*World) CreateObject

func (w *World) CreateObject(object interface{}, location engine.Location) error

func (*World) CreateObjectAvailableDots

func (w *World) CreateObjectAvailableDots(object interface{}, location engine.Location) (engine.Location, error)

func (*World) CreateObjectRandomByDotsMask

func (w *World) CreateObjectRandomByDotsMask(object interface{}, dm *engine.DotsMask) (engine.Location, error)

func (*World) CreateObjectRandomDot

func (w *World) CreateObjectRandomDot(object interface{}) (engine.Location, error)

func (*World) CreateObjectRandomRect

func (w *World) CreateObjectRandomRect(object interface{}, rw, rh uint8) (engine.Location, error)

func (*World) CreateObjectRandomRectMargin

func (w *World) CreateObjectRandomRectMargin(object interface{}, rw, rh, margin uint8) (engine.Location, error)

func (*World) DeleteObject

func (w *World) DeleteObject(object interface{}, location engine.Location) error

func (*World) Events

func (w *World) Events(stop <-chan struct{}, buffer uint) <-chan Event

func (*World) GetObjectByDot

func (w *World) GetObjectByDot(dot engine.Dot) interface{}

func (*World) GetObjects

func (w *World) GetObjects() []interface{}

func (*World) GetObjectsByDots

func (w *World) GetObjectsByDots(dots []engine.Dot) []interface{}

func (*World) IdentifierRegistry

func (w *World) IdentifierRegistry() *IdentifierRegistry

func (*World) LocationOccupied

func (w *World) LocationOccupied(location engine.Location) bool

func (*World) Start

func (w *World) Start(stop <-chan struct{})

func (*World) UpdateObject

func (w *World) UpdateObject(object interface{}, old, new engine.Location) error

func (*World) UpdateObjectAvailableDots

func (w *World) UpdateObjectAvailableDots(object interface{}, old, new engine.Location) (engine.Location, error)

Jump to

Keyboard shortcuts

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