betree

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS = iota
	ERROR   = iota
)
View Source
const (
	COMPOSITE = "composite"
	DECORATOR = "decorator"
	ACTION    = "action"
	CONDITION = "condition"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	BaseNode
}

func (*Action) Init

func (a *Action) Init()

type BaseNode

type BaseNode struct {
	Type string
	Name string
}

func (*BaseNode) GetName

func (b *BaseNode) GetName() string

func (*BaseNode) GetType

func (b *BaseNode) GetType() string

func (*BaseNode) Init

func (b *BaseNode) Init()

func (*BaseNode) OnEnter

func (b *BaseNode) OnEnter(tick int64)

*

  • Enter method, override this to use. It is called every time a node is
  • asked to execute, before the tick itself. *
  • @method enter
  • @param {Tick} tick A tick instance.

*

func (*BaseNode) OnExec

func (b *BaseNode) OnExec(tick int64) bool

*

  • Tick method, override this to use. This method must contain the real
  • execution of node (perform a task, call children, etc.). It is called
  • every time a node is asked to execute. *
  • @method tick
  • @param {Tick} tick A tick instance.

*

func (*BaseNode) OnExit

func (b *BaseNode) OnExit(tick int64)

*

  • Exit method, override this to use. Called every time in the end of the
  • execution. *
  • @method exit
  • @param {Tick} tick A tick instance.

*

func (*BaseNode) SetName

func (b *BaseNode) SetName(name string)

type BehaviorList

type BehaviorList struct {
	vector.Vector[IBaseNode]
}

func (*BehaviorList) AddChild

func (b *BehaviorList) AddChild(name string, pNode IBaseNode)

func (*BehaviorList) DelChild

func (b *BehaviorList) DelChild(name string)

func (*BehaviorList) GetChild

func (b *BehaviorList) GetChild(name string) IBaseNode

func (*BehaviorList) GetChildCount

func (b *BehaviorList) GetChildCount() int

func (*BehaviorList) Less

func (b *BehaviorList) Less(i, j int) bool

type BehaviorTree

type BehaviorTree struct {
	BehaviorList
}

func NewBeTree

func NewBeTree() *BehaviorTree

func (*BehaviorTree) Init

func (b *BehaviorTree) Init()

func (*BehaviorTree) OnExec

func (b *BehaviorTree) OnExec(tick int64)

type Composite

type Composite struct {
	BaseNode
	BehaviorList
}

func (*Composite) Init

func (c *Composite) Init()

type Condition

type Condition struct {
	BaseNode
}

func (*Condition) Init

func (c *Condition) Init()

type Decorator

type Decorator struct {
	BaseNode
	// contains filtered or unexported fields
}

func (*Decorator) GetChild

func (d *Decorator) GetChild() IBaseNode

GetChild

func (*Decorator) Init

func (d *Decorator) Init()

func (*Decorator) SetChild

func (d *Decorator) SetChild(child IBaseNode)

type DecoratorN

type DecoratorN struct {
	Decorator
}

func (*DecoratorN) OnExec

func (d *DecoratorN) OnExec(tick int64) bool

它将它的Child Node执行 后返回的结果值做额外处理后,再返回给它的Parent Node

type IAction

type IAction interface {
	IBaseNode
}

type IBaseNode

type IBaseNode interface {
	OnEnter(tick int64)
	OnExec(tick int64) bool
	OnExit(tick int64)
	Init()
	GetType() string
	GetName() string
	SetName(string)
}

type IBehaviorList

type IBehaviorList interface {
	AddChild(string, IBaseNode)
	DelChild(string)
	GetChild(string) IBaseNode
	GetChildCount() int
}

type IBehaviorTree

type IBehaviorTree interface {
	IBehaviorList
	Init()
	OnExec(int64)
}

type IComposite

type IComposite interface {
	IBaseNode
	IBehaviorList
}

type ICondition

type ICondition interface {
	IBaseNode
}

type IDecorator

type IDecorator interface {
	IBaseNode
	SetChild(child IBaseNode)
	GetChild() IBaseNode
}

type PSelector

type PSelector struct {
	Composite
}

并发

func (*PSelector) OnExec

func (p *PSelector) OnExec(tick int64) bool

当执行本类型Node时,它将从begin到end迭代执行自己的Child Node: 如遇到一个Child Node执行后返回True,那停止迭代, 本Node向自己的Parent Node也返回True;否则所有Child Node都返回False, 那本Node向自己的Parent Node返回False。

type PSequence

type PSequence struct {
	Composite
}

并发

func (*PSequence) OnExec

func (p *PSequence) OnExec(tick int64) bool
	  当执行本类型Node时,它将从begin到end迭代执行自己的Child Node:
   如遇到一个Child Node执行后返回False,那停止迭代,
   本Node向自己的Parent Node也返回False;否则所有Child Node都返回True,
   那本Node向自己的Parent Node返回True。

type Selector

type Selector struct {
	Composite
}

func (*Selector) OnExec

func (s *Selector) OnExec(tick int64) bool

当执行本类型Node时,它将从begin到end迭代执行自己的Child Node: 如遇到一个Child Node执行后返回True,那停止迭代, 本Node向自己的Parent Node也返回True;否则所有Child Node都返回False, 那本Node向自己的Parent Node返回False。

type Sequence

type Sequence struct {
	Composite
}

func (*Sequence) OnExec

func (s *Sequence) OnExec(tick int64) bool
	  当执行本类型Node时,它将从begin到end迭代执行自己的Child Node:
   如遇到一个Child Node执行后返回False,那停止迭代,
   本Node向自己的Parent Node也返回False;否则所有Child Node都返回True,
   那本Node向自己的Parent Node返回True。

Jump to

Keyboard shortcuts

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