Documentation ¶
Index ¶
- Constants
- type BitSet
- type ComponentPool
- type CustomWorld
- type DestroySystem
- type Entity
- type EntityData
- type Filter
- type InitSystem
- type PackedEntity
- type PostDestroySystem
- type PreInitSystem
- type RunSystem
- type System
- type SystemType
- type Systems
- type World
- func (w *World) DelEntity(entity Entity)
- func (w *World) Destroy()
- func (w *World) Filter(idx int) *Filter
- func (w *World) NewEntity() Entity
- func (w *World) PackEntity(entity Entity) PackedEntity
- func (w *World) UnpackEntity(packedEntity PackedEntity) (Entity, bool)
- func (w *World) UpdateFilters(e Entity, componentType uint16, add bool)
Constants ¶
const DEBUG = true
DEBUG mode constant.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitSet ¶
type BitSet []chunkType
BitSet is collection of bits.
type ComponentPool ¶
type ComponentPool interface { New() Recycle(idx uint32) }
ComponentPool - interface for all user component pools.
type CustomWorld ¶
type CustomWorld interface { NewEntity() Entity Destroy() DelEntity(entity Entity) PackEntity(entity Entity) PackedEntity UnpackEntity(packedEntity PackedEntity) (Entity, bool) InternalWorld() *World }
CustomWorld - interface for all user worlds.
type DestroySystem ¶
type DestroySystem interface {
Destroy(systems *Systems)
}
DestroySystem - interface for Destroy() systems.
type Entity ¶
type Entity = uint32
Entity - ID of container with data, cant be cached somehow, use PackedEntity instead!
type EntityData ¶
EntityData - container for keeping internal entity data.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter - container for keeping constraints-filtered entities.
func (*Filter) EntitiesWithLock ¶
EntitiesWithLock increases counter for protect filter from changes and returns filtered entities.
type InitSystem ¶
type InitSystem interface {
Init(systems *Systems)
}
InitSystem - interface for Init() systems.
type PackedEntity ¶
type PackedEntity struct {
// contains filtered or unexported fields
}
PackedEntity - packed version of Entity, useful for saving as cached data somewhere.
type PostDestroySystem ¶
type PostDestroySystem interface {
PostDestroy(systems *Systems)
}
PostDestroySystem - interface for PostDestroy() systems.
type PreInitSystem ¶
type PreInitSystem interface {
PreInit(systems *Systems)
}
PreInitSystem - interface for PreInit() systems.
type RunSystem ¶
type RunSystem interface {
Run(systems *Systems)
}
RunSystem - interface for Run() systems.
type System ¶
type System interface {
SystemTypes() SystemType
}
System - base interface for all systems.
type SystemType ¶
type SystemType uint8
SystemType - bit flags for supported types definition.
const ( // PreInitSystemType declares PreInitSystem support. PreInitSystemType SystemType = 1 << iota // InitSystemType declares InitSystem support. InitSystemType // RunSystemType declares RunSystem support. RunSystemType // DestroySystemType declares DestroySystem support. DestroySystemType // PostDestroySystemType declares PostDestroySystem support. PostDestroySystemType )
type Systems ¶
type Systems struct {
// contains filtered or unexported fields
}
Systems - container for systems, worlds, shared data.
func NewSystems ¶
func NewSystems(shared interface{}) *Systems
NewSystems returns new instance of Systems.
func (*Systems) Add ¶
Add registers user system based on SystemType flags. System should implements interface for all requested types.
func (*Systems) Destroy ¶
func (s *Systems) Destroy()
Destroy processes DestroySystem / PostDestroySystem systems execution.
func (*Systems) Init ¶
func (s *Systems) Init()
Init processes PreInitSystem / InitSystem systems execution.
func (*Systems) SetWorld ¶
func (s *Systems) SetWorld(key string, world CustomWorld) *Systems
SetWorld saves instance of user world to use later inside systems.
func (*Systems) Shared ¶
func (s *Systems) Shared() interface{}
Shared returns optional shared user data.
func (*Systems) World ¶
func (s *Systems) World(key string) CustomWorld
World returns instance of user world saved with SetWorld().
type World ¶
type World struct { Pools []ComponentPool Entities []EntityData // contains filtered or unexported fields }
World - container for all data.
func NewWorld ¶
func NewWorld(entitiesCount uint32, pools []ComponentPool, filters []Filter) *World
NewWorld returns new instance of World.
func (*World) DelEntity ¶
DelEntity removes exist entity from world. All attached components will be removed first.
func (*World) PackEntity ¶
func (w *World) PackEntity(entity Entity) PackedEntity
PackEntity packs Entity to save outside from world.
func (*World) UnpackEntity ¶
func (w *World) UnpackEntity(packedEntity PackedEntity) (Entity, bool)
UnpackEntity tries to unpack data to Entity, returns unpacked entity and success of operation.