component

package
v0.0.0-...-53e25cf Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2012 License: BSD-3-Clause Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDestroyType

func CheckDestroyType(registered_type, type_to_check Type) bool

func CheckInitializeType

func CheckInitializeType(registered_type, type_to_check Type) bool

func FinalizeRegistration

func FinalizeRegistration()

func IsValidType

func IsValidType(t Type) bool

func RegisterDestroyTypes

func RegisterDestroyTypes(registered_type Type, collection_types ...Type)

init_types enumerates all the types that will be available in Component.Destroy

func RegisterInitializeTypes

func RegisterInitializeTypes(registered_type Type, collection_types ...Type)

init_types enumerates all the types that will be available in Component.Initialize

func RegistrationFinalized

func RegistrationFinalized() bool

Types

type Base

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

base is a useful class to embedded because it takes care of the Initialized and Destroyed for you

func (*Base) Destroy

func (this *Base) Destroy(parent Collection)

Destroy finializes the destruction of a component. If a component does not call Component.Destroy() at the end of their overloaded Destroy() that component's Destroy will be called again next initialization loop

func (*Base) Destroyed

func (this *Base) Destroyed() bool

Destroyed returns whether or not a component has called Initialize

func (*Base) Initialize

func (this *Base) Initialize(parent Collection)

Initialize finializes the initialization of a component. If a component does not call Component.Initialize() at the end of their overloaded Initialize() that component's Initialize will be called again next initialization loop

func (*Base) Initialized

func (this *Base) Initialized() bool

Initialized returns whether or not a component has called Initialize

type Collection

type Collection interface {
	GetComponent(requested_type Type) interface{}
}

Collections are basically "Game Objects". They are access controlled however, and will error if an invalid component is accessed. They may also provide a default "garbage" version of that component.

type Component

type Component interface {
	LoadData(data Data)
	Initialize(parent Collection)
	Initialized() bool
	Destroy(parent Collection)
	Destroyed() bool
	GetType() Type
}

The interface which components have to meet to be components

type Data

type Data interface {
	GetType() Type
}

Data types should be POD that can be serialized via GOB

func CreateData

func CreateData(registered_type Type) Data

type RegistrationList

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

func MakeRegistrationList

func MakeRegistrationList(len, cap int) (r RegistrationList)

func (*RegistrationList) AddNewRegistrationID

func (t *RegistrationList) AddNewRegistrationID() (id int)

func (*RegistrationList) Check

func (t *RegistrationList) Check(id int, collection_type Type) bool

func (*RegistrationList) Register

func (t *RegistrationList) Register(id int, collection_types ...Type)

func (*RegistrationList) RegistrationIDCount

func (t *RegistrationList) RegistrationIDCount() int

returns the number of the RegistrationIDCount

type Type

type Type *int

func RegisterComponentType

func RegisterComponentType(name string, component_factory func() Component, data Data) (registered_type Type)

Registers a new type of component with a factory to make it, it is expected to be called during initialization Name must be unique, component_data must be

type TypeSlice

type TypeSlice []Type

func (TypeSlice) Len

func (p TypeSlice) Len() int

func (TypeSlice) Less

func (p TypeSlice) Less(i, j int) bool

func (TypeSlice) Swap

func (p TypeSlice) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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