module

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 3 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModule

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

BaseModule implements the Module interface{}

func NewBaseModule

func NewBaseModule(name string) *BaseModule

NewBaseModule creates a BaseModule

func (*BaseModule) Init

func (mod *BaseModule) Init() error

Init implements Module Init method

func (*BaseModule) Logger

func (mod *BaseModule) Logger() *log.ContextLogger

Logger returns the Module logger

func (*BaseModule) Name

func (mod *BaseModule) Name() string

Name implements Module Name method

func (*BaseModule) Shutdown

func (mod *BaseModule) Shutdown()

Shutdown implements Module Shutdown method

func (*BaseModule) Start

func (mod *BaseModule) Start()

Start implements Module Start method

func (*BaseModule) Update

func (mod *BaseModule) Update(now time.Time, dt time.Duration)

Update implements Module Update method

type Manager

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

Manager used to manages a group of modules

func NewManager

func NewManager() *Manager

NewManager creates a Manager

func (*Manager) Add

func (m *Manager) Add(mod Module) Module

Add adds a module to the manager

func (*Manager) Find

func (m *Manager) Find(t reflect.Type) Module

Find finds the first added module from the manager by type

func (*Manager) FindAll

func (m *Manager) FindAll(t reflect.Type) []Module

FindAll finds all modules from the manager by type

func (*Manager) Get

func (m *Manager) Get(i int) Module

Get returns ith module

func (*Manager) Init

func (m *Manager) Init() error

Init initializes all modules

func (*Manager) Len

func (m *Manager) Len() int

Len returns the number of modules

func (*Manager) Shutdown

func (m *Manager) Shutdown()

Shutdown shutdowns all modules in reverse order

func (*Manager) Start

func (m *Manager) Start()

Start starts all modules

func (*Manager) Update

func (m *Manager) Update(now time.Time, dt time.Duration)

Update updates all modules

type Module

type Module interface {
	// Name returns the name of module
	Name() string
	// Init initializes the module
	Init() error
	// Start starts the module
	Start()
	// Shutdown shutdwons the module
	Shutdown()
	// Update updates the module per frame
	Update(time.Time, time.Duration)
}

Module represents a generic logic module

Jump to

Keyboard shortcuts

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