fsm

package
v0.0.0-...-1c5f5a9 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseState

type BaseState struct {
	Name  string
	Owner *FSM
}

func (*BaseState) GetName

func (slf *BaseState) GetName() string

func (*BaseState) GetOwner

func (slf *BaseState) GetOwner() *FSM

type FSM

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

func NewFSM

func NewFSM() *FSM

func (*FSM) AddState

func (slf *FSM) AddState(states ...State)

AddState 添加状态

func (*FSM) Launch

func (slf *FSM) Launch(initial State)

Launch 启动状态机

func (*FSM) RemoveState

func (slf *FSM) RemoveState(stateName string)

RemoveState 删除状态

func (*FSM) TransitionTo

func (slf *FSM) TransitionTo(stateName string, msg map[string]any)

TransitionTo 切换状态

type State

type State interface {
	// OnEnter 进入状态
	OnEnter(msg map[string]any)
	// OnExit 退出状态
	OnExit()
	// OnUpdate 更新状态
	OnUpdate(delta any)
	// GetName 状态名称
	GetName() string
	// GetOwner 状态机
	GetOwner() *FSM
}

Jump to

Keyboard shortcuts

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