task

package
v1.1.23 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	bcore.Task
}

func (*Action) OnAbort

func (a *Action) OnAbort(brain bcore.IBrain)

OnAbort

@override Node.OnAbort
@receiver n
@param brain

func (*Action) OnStart

func (a *Action) OnStart(brain bcore.IBrain)

OnStart

@override Node.OnStart
@receiver n
@param brain

type DynamicSubtree

type DynamicSubtree struct {
	Subtree
}

DynamicSubtree 动态子树容器

可以在运行时动态更换子节点

func (*DynamicSubtree) CanDynamicDecorate

func (t *DynamicSubtree) CanDynamicDecorate() bool

CanDynamicDecorate 标志可以运行时动态挂载子节点

@implement bcore.IDecoratorWorker .CanDynamicDecorate
@receiver t
@return bool

func (*DynamicSubtree) DynamicDecorate added in v1.0.3

func (t *DynamicSubtree) DynamicDecorate(brain bcore.IBrain, decorated bcore.IRoot)

DynamicDecorate

@implement IDynamicSubtree.DynamicDecorate
@receiver d
@param brain
@param decorated
@param abort

func (*DynamicSubtree) OnChildFinished added in v1.0.3

func (t *DynamicSubtree) OnChildFinished(brain bcore.IBrain, child bcore.INode, succeeded bool)

OnChildFinished

@override Decorator.OnChildFinished
@receiver s
@param brain
@param child
@param succeeded

func (*DynamicSubtree) PropertiesClassProvider

func (t *DynamicSubtree) PropertiesClassProvider() any

PropertiesClassProvider

@implement INodeWorker.PropertiesClassProvider
@receiver n
@return any

func (*DynamicSubtree) Tag added in v1.0.3

func (t *DynamicSubtree) Tag() string

type DynamicSubtreeProperties

type DynamicSubtreeProperties struct {
	SubtreeProperties
	Tag     string                    `json:"tag"`     // 标签,用于识别子树
	RunMode bcore.DynamicBehaviorMode `json:"runMode"` // 动态子树中断模式
}

DynamicSubtreeProperties 子树容器属性

func (*DynamicSubtreeProperties) GetRunMode added in v1.0.3

func (*DynamicSubtreeProperties) GetTag

func (p *DynamicSubtreeProperties) GetTag() string

type IDynamicSubtree

type IDynamicSubtree interface {
	ISubtree
	Tag() string
	// DynamicDecorate 动态装饰子节点
	//
	// 非线程安全,由调用方自己保证
	// @param brain
	// @param decorated
	DynamicDecorate(brain bcore.IBrain, decorated bcore.IRoot)
}

IDynamicSubtree 动态子树容器

可以在运行时动态更换子节点

type IDynamicSubtreeProperties

type IDynamicSubtreeProperties interface {
	GetTag() string
	GetRunMode() bcore.DynamicBehaviorMode
}

type ISubtree

type ISubtree interface {
	bcore.IDecorator
	// GetPropChildID 获取配置中的子节点ID
	//  @return string
	GetPropChildID() string
	// GetPropChildTag 获取配置中的子节点Tag
	//  @return string
	GetPropChildTag() string
}

ISubtree 静态子树容器

只能在初始化时添加子节点,不允许在运行时改变子节点

type ISubtreeProperties

type ISubtreeProperties interface {
	GetChildID() string
	GetChildTag() string
	GetIsSuccessWhenNotChild() bool
}

type IWaitBBProperties

type IWaitBBProperties interface {
	GetKey() string
	GetRandomDeviation() time.Duration
}

type IWaitProperties

type IWaitProperties interface {
	GetWaitTime() time.Duration
	GetRandomDeviation() time.Duration
	GetForever() bool
	GetResultOnAbort() bool
}

type Subtree

type Subtree struct {
	bcore.Decorator
}

Subtree 静态子树容器

只能在初始化时添加子节点,不允许在运行时改变子节点

func (*Subtree) GetPropChildID

func (t *Subtree) GetPropChildID() string

GetPropChildID

@implement ISubtree.GetPropChildID
@receiver s
@return string

func (*Subtree) GetPropChildTag added in v1.0.3

func (t *Subtree) GetPropChildTag() string

GetPropChildTag

@implement ISubtree.GetPropChildTag
@receiver s
@return string

func (*Subtree) OnAbort

func (t *Subtree) OnAbort(brain bcore.IBrain)

OnAbort

@override Node.OnAbort
@receiver n
@param brain

func (*Subtree) OnChildFinished

func (t *Subtree) OnChildFinished(brain bcore.IBrain, child bcore.INode, succeeded bool)

OnChildFinished

@override bcore.Decorator .OnChildFinished
@receiver s
@param brain
@param child
@param succeeded

func (*Subtree) OnStart

func (t *Subtree) OnStart(brain bcore.IBrain)

OnStart

@override Node.OnStart
@receiver n
@param brain

func (*Subtree) PropertiesClassProvider

func (t *Subtree) PropertiesClassProvider() any

PropertiesClassProvider

@implement INodeWorker.PropertiesClassProvider
@receiver n
@return any

func (*Subtree) SubtreeProperties

func (t *Subtree) SubtreeProperties() ISubtreeProperties

type SubtreeProperties

type SubtreeProperties struct {
	ChildID               string `json:"childID"`               // 默认子节点ID
	ChildTag              string `json:"childTag"`              // 默认子节点Tag
	IsSuccessWhenNotChild bool   `json:"isSuccessWhenNotChild"` // 无子节点时执行是否返回成功
}

SubtreeProperties 子树容器属性

func (*SubtreeProperties) GetChildID added in v1.0.3

func (s *SubtreeProperties) GetChildID() string

func (*SubtreeProperties) GetChildTag added in v1.0.3

func (s *SubtreeProperties) GetChildTag() string

func (*SubtreeProperties) GetIsSuccessWhenNotChild

func (s *SubtreeProperties) GetIsSuccessWhenNotChild() bool

type Wait

type Wait struct {
	bcore.Task
}

Wait 等待

任务节点可以在行为树中使用,使树在此节点上等待,直至指定的 等待时间(Wait Time) 结束。

func (*Wait) OnAbort

func (w *Wait) OnAbort(brain bcore.IBrain)

OnAbort

@override Node.OnAbort
@receiver n
@param brain

func (*Wait) OnStart

func (w *Wait) OnStart(brain bcore.IBrain)

OnStart

@override Node.OnStart
@receiver n
@param brain

func (*Wait) PropertiesClassProvider

func (w *Wait) PropertiesClassProvider() any

PropertiesClassProvider

@implement INodeWorker.PropertiesClassProvider
@receiver n
@return any

func (*Wait) WaitProperties

func (w *Wait) WaitProperties() IWaitProperties

type WaitBB

type WaitBB struct {
	bcore.Task
}

WaitBB 等待黑板时间

与 等待 WaitBB 任务节点的原理类似,但该节点会拉取等待时间黑板值。

func (*WaitBB) OnAbort

func (w *WaitBB) OnAbort(brain bcore.IBrain)

OnAbort

@override Node.OnAbort
@receiver n
@param brain

func (*WaitBB) OnStart

func (w *WaitBB) OnStart(brain bcore.IBrain)

OnStart

@override Node.OnStart
@receiver n
@param brain

func (*WaitBB) PropertiesClassProvider

func (w *WaitBB) PropertiesClassProvider() any

PropertiesClassProvider

@implement INodeWorker.PropertiesClassProvider
@receiver n
@return any

func (*WaitBB) WaitBBProperties

func (w *WaitBB) WaitBBProperties() IWaitBBProperties

type WaitBBProperties

type WaitBBProperties struct {
	Key             string        `json:"key"`             // 引用的黑板键,确定等待时间
	RandomDeviation util.Duration `json:"randomDeviation"` // 随机偏差:允许向 等待时间(WaitTime)属性添加随机时间 WaitTime=WaitTime+RandomDeviation*[-0.5,0.5)
}

WaitBBProperties 等待黑板时间属性

func (*WaitBBProperties) GetKey

func (w *WaitBBProperties) GetKey() string

func (*WaitBBProperties) GetRandomDeviation

func (w *WaitBBProperties) GetRandomDeviation() time.Duration

type WaitProperties

type WaitProperties struct {
	WaitTime        util.Duration `json:"waitTime"`        // 等待时间
	RandomDeviation util.Duration `json:"randomDeviation"` // 随机偏差:允许向 等待时间 WaitTime 属性添加随机时间。 WaitTime = WaitTime + RandomDeviation * [-0.5,0.5)
	Forever         bool          `json:"forever"`         // 永久等待直到被外界打断
	ResultOnAbort   bool          `json:"resultOnAbort"`   // 中断时返回成功还是失败,默认false
}

WaitProperties 等待属性

func (*WaitProperties) GetForever

func (w *WaitProperties) GetForever() bool

func (*WaitProperties) GetRandomDeviation

func (w *WaitProperties) GetRandomDeviation() time.Duration

func (*WaitProperties) GetResultOnAbort added in v1.0.6

func (w *WaitProperties) GetResultOnAbort() bool

func (*WaitProperties) GetWaitTime

func (w *WaitProperties) GetWaitTime() time.Duration

Jump to

Keyboard shortcuts

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