Documentation ¶
Index ¶
- type BBCondition
- func (c *BBCondition) BBConditionProperties() IBBConditionProperties
- func (c *BBCondition) ConditionMet(brain bcore.IBrain, args ...any) bool
- func (c *BBCondition) OnString(brain bcore.IBrain) string
- func (c *BBCondition) PropertiesClassProvider() any
- func (c *BBCondition) StartObserving(brain bcore.IBrain)
- func (c *BBCondition) StopObserving(brain bcore.IBrain)
- type BBConditionProperties
- type BBCooldown
- type BBCooldownProperties
- type BBEntries
- func (e *BBEntries) BBEntriesProperties() IBBEntriesProperties
- func (e *BBEntries) ConditionMet(brain bcore.IBrain, args ...any) bool
- func (e *BBEntries) OnString(brain bcore.IBrain) string
- func (e *BBEntries) PropertiesClassProvider() any
- func (e *BBEntries) StartObserving(brain bcore.IBrain)
- func (e *BBEntries) StopObserving(brain bcore.IBrain)
- type BBEntriesOp
- type BBEntriesProperties
- type Condition
- type ConditionProperties
- type Cooldown
- type CooldownBase
- func (b *CooldownBase) CooldownProperties() ICooldownBaseProperties
- func (b *CooldownBase) InitNodeWorker(worker bcore.INodeWorker) error
- func (b *CooldownBase) OnAbort(brain bcore.IBrain)
- func (b *CooldownBase) OnChildFinished(brain bcore.IBrain, child bcore.INode, succeeded bool)
- func (b *CooldownBase) OnStart(brain bcore.IBrain)
- func (b *CooldownBase) PropertiesClassProvider() any
- type CooldownBaseProperties
- type CooldownProperties
- type Failure
- type IBBConditionProperties
- type IBBCooldownProperties
- type IBBEntriesProperties
- type IConditionProperties
- type ICooldownBaseProperties
- type ICooldownBaseWorker
- type ICooldownProperties
- type IRandomProperties
- type IRepeaterProperties
- type IServiceProperties
- type ITimeMaxProperties
- type ITimeMinProperties
- type IWaitConditionProperties
- type Inverter
- type Random
- type RandomProperties
- type Repeater
- type RepeaterProperties
- type Service
- type ServiceProperties
- type SimpleDecorator
- type Succeeded
- type TimeMax
- type TimeMaxProperties
- type TimeMin
- type TimeMinProperties
- type WaitCondition
- type WaitConditionProperties
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BBCondition ¶
type BBCondition struct {
bcore.ObservingDecorator
}
BBCondition 黑板条件
节点将检查给定的 黑板键(Blackboard Key) 上是否设置了值。
func (*BBCondition) BBConditionProperties ¶
func (c *BBCondition) BBConditionProperties() IBBConditionProperties
func (*BBCondition) ConditionMet ¶
func (c *BBCondition) ConditionMet(brain bcore.IBrain, args ...any) bool
ConditionMet
@implement bcore.IObservingWorker .ConditionMet @receiver o @param brain @param args @return bool
func (*BBCondition) PropertiesClassProvider ¶
func (c *BBCondition) PropertiesClassProvider() any
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
func (*BBCondition) StartObserving ¶
func (c *BBCondition) StartObserving(brain bcore.IBrain)
StartObserving
@override bcore.ObservingDecorator .StartObserving @receiver o @param brain
func (*BBCondition) StopObserving ¶
func (c *BBCondition) StopObserving(brain bcore.IBrain)
StopObserving
@override bcore.ObservingDecorator .StopObserving @receiver o @param brain
type BBConditionProperties ¶
type BBConditionProperties struct { bcore.ObservingProperties Operator bcore.Operator `json:"operator"` // 运算符 Key string `json:"key"` // 黑板键 Value any `json:"value"` }
BBConditionProperties 黑板条件节点属性
func (*BBConditionProperties) GetKey ¶
func (b *BBConditionProperties) GetKey() string
func (*BBConditionProperties) GetOperator ¶
func (b *BBConditionProperties) GetOperator() bcore.Operator
func (*BBConditionProperties) GetValue ¶
func (b *BBConditionProperties) GetValue() any
type BBCooldown ¶
type BBCooldown struct {
CooldownBase
}
BBCooldown cd等待装饰器,与 Cooldown 的区别是冷取时间从黑板读取
每次子节点完成后将等待一段时间才能再次执行
func (*BBCooldown) CooldownTime ¶
func (b *BBCooldown) CooldownTime(brain bcore.IBrain) time.Duration
CooldownTime
@implement ICooldownBaseWorker.CooldownTime @receiver b @param brain @return time.Duration
func (*BBCooldown) PropertiesClassProvider ¶
func (b *BBCooldown) PropertiesClassProvider() any
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
type BBCooldownProperties ¶
type BBCooldownProperties struct {
Key string `json:"key"` // 读取冷取时间的黑板KEY
}
BBCooldownProperties cd等待装饰器属性
func (*BBCooldownProperties) GetKey ¶
func (p *BBCooldownProperties) GetKey() string
type BBEntries ¶
type BBEntries struct {
bcore.ObservingDecorator
}
BBEntries 比较黑板条目(Compare BBEntries)
节点将比较多个 黑板键 的值,并根据结果(等于或不等)阻止或允许节点的执行。
func (*BBEntries) BBEntriesProperties ¶
func (e *BBEntries) BBEntriesProperties() IBBEntriesProperties
func (*BBEntries) ConditionMet ¶
ConditionMet
@implement bcore.IObservingWorker .ConditionMet @receiver o @param brain @param args @return bool
func (*BBEntries) PropertiesClassProvider ¶
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
func (*BBEntries) StartObserving ¶
StartObserving
@override bcore.ObservingDecorator .StartObserving @receiver o @param brain
func (*BBEntries) StopObserving ¶
StopObserving
@override bcore.ObservingDecorator .StopObserving @receiver o @param brain
type BBEntriesOp ¶
type BBEntriesOp int
BBEntriesOp 比较黑板条目操作符
const ( BBEntriesOpEqual BBEntriesOp = iota // 相等 BBEntriesOpNotEqual // 不相等 )
type BBEntriesProperties ¶
type BBEntriesProperties struct { bcore.ObservingProperties Operator BBEntriesOp `json:"operator"` // 运算符 Keys []string `json:"keys"` // 黑板键 Query string `json:"query"` // 自定义查询语句 }
BBEntriesProperties 黑板条件节点属性
func (*BBEntriesProperties) GetKeys ¶
func (b *BBEntriesProperties) GetKeys() []string
func (*BBEntriesProperties) GetOperator ¶
func (b *BBEntriesProperties) GetOperator() BBEntriesOp
func (*BBEntriesProperties) GetQuery ¶
func (b *BBEntriesProperties) GetQuery() string
type Condition ¶
type Condition struct {
bcore.ObservingDecorator
}
Condition 条件装饰器
将根据配置定时检查委托方法,并根据结果(等于或不等)阻止或允许节点的执行。
func (*Condition) ConditionMet ¶
ConditionMet
@implement bcore.IObservingWorker .ConditionMet @receiver o @param brain @param args @return bool
func (*Condition) ConditionProperties ¶
func (c *Condition) ConditionProperties() IConditionProperties
func (*Condition) PropertiesClassProvider ¶
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
func (*Condition) StartObserving ¶
StartObserving
@override bcore.ObservingDecorator .StartObserving @receiver o @param brain
func (*Condition) StopObserving ¶
StopObserving
@override bcore.ObservingDecorator .StopObserving @receiver o @param brain
type ConditionProperties ¶
type ConditionProperties struct { bcore.ObservingProperties ServiceProperties }
ConditionProperties 黑板条件节点属性
type Cooldown ¶
type Cooldown struct {
CooldownBase
}
Cooldown cd等待装饰器
每次子节点完成后将等待一段时间才能再次执行
func (*Cooldown) CooldownTime ¶
CooldownTime
@implement ICooldownBaseWorker.CooldownTime @receiver b @param brain @return time.Duration
func (*Cooldown) PropertiesClassProvider ¶
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
type CooldownBase ¶
type CooldownBase struct { bcore.Decorator ICooldownBaseWorker }
CooldownBase cd等待装饰器
每次子节点完成后将等待一段时间才能再次执行
func (*CooldownBase) CooldownProperties ¶
func (b *CooldownBase) CooldownProperties() ICooldownBaseProperties
func (*CooldownBase) InitNodeWorker ¶
func (b *CooldownBase) InitNodeWorker(worker bcore.INodeWorker) error
InitNodeWorker
@override Node.InitNodeWorker @receiver c @param worker
func (*CooldownBase) OnAbort ¶
func (b *CooldownBase) OnAbort(brain bcore.IBrain)
OnAbort
@override Node.OnAbort @receiver n @param brain
func (*CooldownBase) OnChildFinished ¶
OnChildFinished
@override bcore.Decorator .OnChildFinished @receiver s @param brain @param child @param succeeded
func (*CooldownBase) OnStart ¶
func (b *CooldownBase) OnStart(brain bcore.IBrain)
OnStart
@override Node.OnStart @receiver n @param brain
func (*CooldownBase) PropertiesClassProvider ¶
func (b *CooldownBase) PropertiesClassProvider() any
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
type CooldownBaseProperties ¶
type CooldownBaseProperties struct { StartAfterDecorated bool `json:"startAfterDecorated"` // 是否在子节点完成后才进入cd ResetOnFailure bool `json:"resetOnFailure"` // 子节点取消后是否重置cd FailOnCoolDown bool `json:"failOnCoolDown"` // true:cd时间未到却被请求执行时停用当前节点并返回false false:什么都不做 RandomDeviation util.Duration `json:"randomDeviation"` // 随机偏差:冷却时间 ICooldownBaseWorker.CooldownTime = CooldownTime + RandomDeviation*[-0.5,0.5) }
CooldownBaseProperties cd等待装饰器属性
func (*CooldownBaseProperties) GetFailOnCoolDown ¶
func (p *CooldownBaseProperties) GetFailOnCoolDown() bool
func (*CooldownBaseProperties) GetRandomDeviation ¶
func (p *CooldownBaseProperties) GetRandomDeviation() time.Duration
func (*CooldownBaseProperties) GetResetOnFailure ¶
func (p *CooldownBaseProperties) GetResetOnFailure() bool
func (*CooldownBaseProperties) GetStartAfterDecorated ¶
func (p *CooldownBaseProperties) GetStartAfterDecorated() bool
type CooldownProperties ¶
CooldownProperties cd等待装饰器属性
func (*CooldownProperties) GetCooldownTime ¶
func (p *CooldownProperties) GetCooldownTime() time.Duration
type IBBConditionProperties ¶
type IBBCooldownProperties ¶
type IBBCooldownProperties interface {
GetKey() string
}
type IBBEntriesProperties ¶
type IBBEntriesProperties interface { GetOperator() BBEntriesOp GetKeys() []string GetQuery() string }
type IConditionProperties ¶
type IConditionProperties interface { IServiceProperties }
type ICooldownBaseProperties ¶
type ICooldownBaseWorker ¶
type ICooldownProperties ¶
type IRandomProperties ¶
type IRandomProperties interface {
GetProbability() float64
}
type IRepeaterProperties ¶
type IRepeaterProperties interface {
GetTimes() int
}
type IServiceProperties ¶
type ITimeMaxProperties ¶
type ITimeMinProperties ¶
type IWaitConditionProperties ¶
type IWaitConditionProperties interface { }
type Random ¶
Random 随机装饰器
将根据配置的概率决定是否执行子节点。
func (*Random) OnChildFinished ¶
OnChildFinished
@override bcore.Decorator .OnChildFinished @receiver s @param brain @param child @param succeeded
func (*Random) PropertiesClassProvider ¶
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
type RandomProperties ¶
type RandomProperties struct {
Probability float64 `json:"probability"` // 概率,必须0<=probability<=1
}
RandomProperties 随机节点属性
func (*RandomProperties) GetProbability ¶
func (r *RandomProperties) GetProbability() float64
type Repeater ¶
Repeater 条件装饰器
将根据配置定时检查委托方法,并根据结果(等于或不等)阻止或允许节点的执行。
func (*Repeater) OnChildFinished ¶
OnChildFinished
@override bcore.Decorator .OnChildFinished @receiver s @param brain @param child @param succeeded
func (*Repeater) PropertiesClassProvider ¶
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
type RepeaterProperties ¶
type RepeaterProperties struct {
Times int `json:"times"` // 循环次数 0或负值将永远循环
}
RepeaterProperties 黑板条件节点属性
func (*RepeaterProperties) GetTimes ¶
func (r *RepeaterProperties) GetTimes() int
type Service ¶
Service 服务.
节点通常连接至合成(Composite)节点或任务(Task)节点,只要其分支被执行,它们就会以定义的频率执行。 这些节点常用于检查和更新黑板。它们取代了其他行为树系统中的传统平行(Parallel)节点。
func (*Service) OnChildFinished ¶
OnChildFinished
@override bcore.Decorator .OnChildFinished @receiver s @param brain @param child @param succeeded
func (*Service) PropertiesClassProvider ¶
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
type ServiceProperties ¶
type ServiceProperties struct { Interval util.Duration `json:"interval"` // 执行间隔,配0则为行为树默认时间轮间隔 RandomDeviation util.Duration `json:"randomDeviation"` // 随机偏差:将一个随机范围数值添加至服务节点的 时间间隔 Interval 。Interval = Interval + RandomDeviation * [-0.5,0.5) }
ServiceProperties 服务节点属性
func (*ServiceProperties) GetInterval ¶
func (s *ServiceProperties) GetInterval() time.Duration
func (*ServiceProperties) GetRandomDeviation ¶
func (s *ServiceProperties) GetRandomDeviation() time.Duration
type SimpleDecorator ¶
SimpleDecorator 简单装饰器基类
子节点完成时强制返回失败
func (*SimpleDecorator) OnAbort ¶
func (f *SimpleDecorator) OnAbort(brain bcore.IBrain)
OnAbort
@override Node.OnAbort @receiver n @param brain
func (*SimpleDecorator) OnChildFinished ¶
OnChildFinished
@override bcore.Decorator .OnChildFinished @receiver s @param brain @param child @param succeeded
func (*SimpleDecorator) OnStart ¶
func (f *SimpleDecorator) OnStart(brain bcore.IBrain)
OnStart
@override Node.OnStart @receiver n @param brain
type TimeMax ¶
TimeMax 最大时限装饰器
限制最大时限内必须返回结果
func (*TimeMax) OnChildFinished ¶
OnChildFinished
@override bcore.Decorator .OnChildFinished @receiver s @param brain @param child @param succeeded
func (*TimeMax) PropertiesClassProvider ¶
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
func (*TimeMax) TimeMaxProperties ¶
func (m *TimeMax) TimeMaxProperties() ITimeMaxProperties
type TimeMaxProperties ¶
type TimeMaxProperties struct { Limit util.Duration `json:"limit"` // 最大时限 RandomDeviation util.Duration `json:"randomDeviation"` // 随机偏差:将一个随机范围数值添加至服务节点的 Limit 值。Limit = Limit + RandomDeviation * [-0.5,0.5) WaitForChildButFail bool `json:"waitForChildButFail"` // true:超时后依然等待子节点完成,但将修改结果为失败 false:超时后立即关闭子节点 }
TimeMaxProperties 最大时限装饰器属性
func (TimeMaxProperties) GetLimit ¶
func (t TimeMaxProperties) GetLimit() time.Duration
func (TimeMaxProperties) GetRandomDeviation ¶
func (t TimeMaxProperties) GetRandomDeviation() time.Duration
func (TimeMaxProperties) GetWaitForChildButFail ¶
func (t TimeMaxProperties) GetWaitForChildButFail() bool
type TimeMin ¶
TimeMin 最小时限装饰器
限制子节点至少须执行xx时限
func (*TimeMin) OnChildFinished ¶
OnChildFinished
@override bcore.Decorator .OnChildFinished @receiver s @param brain @param child @param succeeded
func (*TimeMin) PropertiesClassProvider ¶
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
func (*TimeMin) TimeMinProperties ¶
func (m *TimeMin) TimeMinProperties() ITimeMinProperties
type TimeMinProperties ¶
type TimeMinProperties struct { Limit util.Duration `json:"Limit"` // 最小时限 RandomDeviation util.Duration `json:"randomDeviation"` // 随机偏差:将一个随机范围数值添加至服务节点的 Limit 值。Limit = Limit + RandomDeviation * [-0.5,0.5) FinishOnChildFailure bool `json:"finishOnChildFailure"` // true:子节点返回false时,当前节点会立即停用并返回false false:子节点返回时,当前节点会等到直到达到时间限制后才停用 }
TimeMinProperties 最小时限装饰器属性
func (TimeMinProperties) GetFinishOnChildFailure ¶
func (t TimeMinProperties) GetFinishOnChildFailure() bool
func (TimeMinProperties) GetLimit ¶
func (t TimeMinProperties) GetLimit() time.Duration
func (TimeMinProperties) GetRandomDeviation ¶
func (t TimeMinProperties) GetRandomDeviation() time.Duration
type WaitCondition ¶
WaitCondition 条件等待装饰器
将阻塞等待条件成功才开始执行分支
func (*WaitCondition) PropertiesClassProvider ¶
func (o *WaitCondition) PropertiesClassProvider() any
PropertiesClassProvider
@implement INodeWorker.PropertiesClassProvider @receiver n @return any
type WaitConditionProperties ¶
type WaitConditionProperties struct {
ConditionProperties
}
WaitConditionProperties 条件等待装饰器属性