Documentation ¶
Overview ¶
Package ec 提供了一个EC(Entity-Component)组件框架,用于帮助开发者组织代码架构。
在框架中,有以下几个核心概念:
- Entity(实体):代表应用程序中的一个实际对象。以游戏为例,可以是场景、玩家、NPC或物品等。一般情况下,实体只提供生命周期和组件管理两项核心能力,行为和属性将由不同的组件提供。
- Component(组件):为实体提供行为和属性,不同的组件可以为实体提供不同的行为和状态。以游戏为例,我们为实体添加兔子外观组件、飞行组件和挖洞组件,那么将会得到一个既能飞行又能挖洞并且拥有兔子外观的实体。
- Context(上下文):实体的运行环境,通常用于提供全局属性和方法。因为 Golaxy 分布式服务开发框架主要用于服务器逻辑开发,需要支持多线程并发环境,所以提供了运行时上下文(Runtime Context)和服务上下文(Service Context)两个上下文,分别对应本地单线程环境和并发多线程环境。
EC 组件框架基于组合模式,在大多数情况下优于继承模式,开发者可以更好地组织代码,实现高内聚和低耦合的代码架构。
Index ¶
- Variables
- func BindEventComponentDestroySelf(auto iAutoEventComponentDestroySelf, subscriber EventComponentDestroySelf, ...) event.Hook
- func BindEventComponentManagerAddComponents(auto iAutoEventComponentManagerAddComponents, ...) event.Hook
- func BindEventComponentManagerFirstTouchComponent(auto iAutoEventComponentManagerFirstTouchComponent, ...) event.Hook
- func BindEventComponentManagerRemoveComponent(auto iAutoEventComponentManagerRemoveComponent, ...) event.Hook
- func BindEventEntityDestroySelf(auto iAutoEventEntityDestroySelf, subscriber EventEntityDestroySelf, ...) event.Hook
- func BindEventTreeNodeAddChild(auto iAutoEventTreeNodeAddChild, subscriber EventTreeNodeAddChild, ...) event.Hook
- func BindEventTreeNodeEnterParent(auto iAutoEventTreeNodeEnterParent, subscriber EventTreeNodeEnterParent, ...) event.Hook
- func BindEventTreeNodeLeaveParent(auto iAutoEventTreeNodeLeaveParent, subscriber EventTreeNodeLeaveParent, ...) event.Hook
- func BindEventTreeNodeRemoveChild(auto iAutoEventTreeNodeRemoveChild, subscriber EventTreeNodeRemoveChild, ...) event.Hook
- func UnsafeComponent(comp Component) _UnsafeComponentdeprecated
- func UnsafeConcurrentEntity(entity ConcurrentEntity) _UnsafeConcurrentEntitydeprecated
- func UnsafeEntity(entity Entity) _UnsafeEntitydeprecated
- type BuiltinComponent
- type Component
- type ComponentBehavior
- func (comp *ComponentBehavior) DestroySelf()
- func (comp *ComponentBehavior) EventComponentDestroySelf() event.IEvent
- func (comp *ComponentBehavior) GetBuiltin() BuiltinComponent
- func (comp *ComponentBehavior) GetConcurrentContext() iface.Cache
- func (comp *ComponentBehavior) GetCurrentContext() iface.Cache
- func (comp *ComponentBehavior) GetEntity() Entity
- func (comp *ComponentBehavior) GetId() uid.Id
- func (comp *ComponentBehavior) GetName() string
- func (comp *ComponentBehavior) GetNonRemovable() bool
- func (comp *ComponentBehavior) GetReflected() reflect.Value
- func (comp *ComponentBehavior) GetState() ComponentState
- func (comp *ComponentBehavior) ManagedHooks(hooks ...event.Hook)
- func (comp *ComponentBehavior) String() string
- func (comp *ComponentBehavior) Terminated() <-chan struct{}
- type ComponentPT
- type ComponentState
- type ConcurrentEntity
- type Entity
- type EntityBehavior
- func (entity *EntityBehavior) AddComponent(name string, components ...Component) error
- func (entity *EntityBehavior) ContainsComponent(name string) bool
- func (entity *EntityBehavior) ContainsComponentById(id uid.Id) bool
- func (entity *EntityBehavior) ContainsComponentByPT(prototype string) bool
- func (entity *EntityBehavior) CountComponents() int
- func (entity *EntityBehavior) DestroySelf()
- func (entity *EntityBehavior) EventComponentManagerAddComponents() event.IEvent
- func (entity *EntityBehavior) EventComponentManagerFirstTouchComponent() event.IEvent
- func (entity *EntityBehavior) EventComponentManagerRemoveComponent() event.IEvent
- func (entity *EntityBehavior) EventEntityDestroySelf() event.IEvent
- func (entity *EntityBehavior) EventTreeNodeAddChild() event.IEvent
- func (entity *EntityBehavior) EventTreeNodeEnterParent() event.IEvent
- func (entity *EntityBehavior) EventTreeNodeLeaveParent() event.IEvent
- func (entity *EntityBehavior) EventTreeNodeRemoveChild() event.IEvent
- func (entity *EntityBehavior) FilterComponents(fun generic.Func1[Component, bool]) []Component
- func (entity *EntityBehavior) GetComponent(name string) Component
- func (entity *EntityBehavior) GetComponentById(id uid.Id) Component
- func (entity *EntityBehavior) GetComponentByPT(prototype string) Component
- func (entity *EntityBehavior) GetComponents() []Component
- func (entity *EntityBehavior) GetConcurrentContext() iface.Cache
- func (entity *EntityBehavior) GetCurrentContext() iface.Cache
- func (entity *EntityBehavior) GetId() uid.Id
- func (entity *EntityBehavior) GetInstanceFaceCache() iface.Cache
- func (entity *EntityBehavior) GetMeta() meta.Meta
- func (entity *EntityBehavior) GetPT() EntityPT
- func (entity *EntityBehavior) GetReflected() reflect.Value
- func (entity *EntityBehavior) GetScope() Scope
- func (entity *EntityBehavior) GetState() EntityState
- func (entity *EntityBehavior) GetTreeNodeParent() (Entity, bool)
- func (entity *EntityBehavior) GetTreeNodeState() TreeNodeState
- func (entity *EntityBehavior) ManagedHooks(hooks ...event.Hook)
- func (entity *EntityBehavior) RangeComponents(fun generic.Func1[Component, bool])
- func (entity *EntityBehavior) RemoveComponent(name string)
- func (entity *EntityBehavior) RemoveComponentById(id uid.Id)
- func (entity *EntityBehavior) ReversedRangeComponents(fun generic.Func1[Component, bool])
- func (entity *EntityBehavior) String() string
- func (entity *EntityBehavior) Terminated() <-chan struct{}
- type EntityOptions
- type EntityPT
- type EntityState
- type EventComponentDestroySelf
- type EventComponentDestroySelfHandler
- type EventComponentManagerAddComponents
- type EventComponentManagerAddComponentsHandler
- type EventComponentManagerFirstTouchComponent
- type EventComponentManagerFirstTouchComponentHandler
- type EventComponentManagerRemoveComponent
- type EventComponentManagerRemoveComponentHandler
- type EventEntityDestroySelf
- type EventEntityDestroySelfHandler
- type EventTreeNodeAddChild
- type EventTreeNodeAddChildHandler
- type EventTreeNodeEnterParent
- type EventTreeNodeEnterParentHandler
- type EventTreeNodeLeaveParent
- type EventTreeNodeLeaveParentHandler
- type EventTreeNodeRemoveChild
- type EventTreeNodeRemoveChildHandler
- type IComponentEventTab
- type IEntityComponentManagerEventTab
- type IEntityEventTab
- type IEntityTreeNodeEventTab
- type Scope
- type TreeNodeState
Constants ¶
This section is empty.
Variables ¶
var ( EventComponentManagerAddComponentsId = _entityComponentManagerEventTabId + 0 EventComponentManagerRemoveComponentId = _entityComponentManagerEventTabId + 1 EventComponentManagerFirstTouchComponentId = _entityComponentManagerEventTabId + 2 )
var ( EventTreeNodeAddChildId = _entityTreeNodeEventTabId + 0 EventTreeNodeRemoveChildId = _entityTreeNodeEventTabId + 1 EventTreeNodeEnterParentId = _entityTreeNodeEventTabId + 2 EventTreeNodeLeaveParentId = _entityTreeNodeEventTabId + 3 )
var (
ErrEC = fmt.Errorf("%w: ec", exception.ErrCore) // EC错误
)
var (
EventComponentDestroySelfId = _componentEventTabId + 0
)
var (
EventEntityDestroySelfId = _entityEventTabId + 0
)
var With _Option
Functions ¶
func BindEventComponentDestroySelf ¶
func BindEventComponentDestroySelf(auto iAutoEventComponentDestroySelf, subscriber EventComponentDestroySelf, priority ...int32) event.Hook
func BindEventComponentManagerAddComponents ¶ added in v0.3.66
func BindEventComponentManagerAddComponents(auto iAutoEventComponentManagerAddComponents, subscriber EventComponentManagerAddComponents, priority ...int32) event.Hook
func BindEventComponentManagerFirstTouchComponent ¶ added in v0.3.66
func BindEventComponentManagerFirstTouchComponent(auto iAutoEventComponentManagerFirstTouchComponent, subscriber EventComponentManagerFirstTouchComponent, priority ...int32) event.Hook
func BindEventComponentManagerRemoveComponent ¶ added in v0.3.66
func BindEventComponentManagerRemoveComponent(auto iAutoEventComponentManagerRemoveComponent, subscriber EventComponentManagerRemoveComponent, priority ...int32) event.Hook
func BindEventEntityDestroySelf ¶
func BindEventEntityDestroySelf(auto iAutoEventEntityDestroySelf, subscriber EventEntityDestroySelf, priority ...int32) event.Hook
func BindEventTreeNodeAddChild ¶ added in v0.2.58
func BindEventTreeNodeAddChild(auto iAutoEventTreeNodeAddChild, subscriber EventTreeNodeAddChild, priority ...int32) event.Hook
func BindEventTreeNodeEnterParent ¶ added in v0.2.58
func BindEventTreeNodeEnterParent(auto iAutoEventTreeNodeEnterParent, subscriber EventTreeNodeEnterParent, priority ...int32) event.Hook
func BindEventTreeNodeLeaveParent ¶ added in v0.2.58
func BindEventTreeNodeLeaveParent(auto iAutoEventTreeNodeLeaveParent, subscriber EventTreeNodeLeaveParent, priority ...int32) event.Hook
func BindEventTreeNodeRemoveChild ¶ added in v0.2.58
func BindEventTreeNodeRemoveChild(auto iAutoEventTreeNodeRemoveChild, subscriber EventTreeNodeRemoveChild, priority ...int32) event.Hook
func UnsafeComponent
deprecated
func UnsafeComponent(comp Component) _UnsafeComponent
Deprecated: UnsafeComponent 访问组件内部函数
func UnsafeConcurrentEntity
deprecated
added in
v0.3.21
func UnsafeConcurrentEntity(entity ConcurrentEntity) _UnsafeConcurrentEntity
Deprecated: UnsafeConcurrentEntity 访问多线程安全的实体接口内部函数
func UnsafeEntity
deprecated
func UnsafeEntity(entity Entity) _UnsafeEntity
Deprecated: UnsafeEntity 访问实体内部函数
Types ¶
type BuiltinComponent ¶ added in v0.3.60
type BuiltinComponent struct { PT ComponentPT // 组件原型 Offset int // 组件位置 Name string // 组件名称 NonRemovable bool // 不可删除 Extra generic.SliceMap[string, any] // 自定义原型属性 }
BuiltinComponent 实体原型中的组件信息
type Component ¶
type Component interface { ictx.CurrentContextProvider fmt.Stringer // GetId 获取组件Id GetId() uid.Id // GetBuiltin 获取实体原型中的组件信息 GetBuiltin() BuiltinComponent // GetName 获取组件名称 GetName() string // GetEntity 获取组件依附的实体 GetEntity() Entity // GetState 获取组件状态 GetState() ComponentState // GetReflected 获取反射值 GetReflected() reflect.Value // GetNonRemovable 是否不可删除 GetNonRemovable() bool // DestroySelf 销毁自身 DestroySelf() IComponentEventTab // contains filtered or unexported methods }
Component 组件接口
type ComponentBehavior ¶
ComponentBehavior 组件行为,需要在开发新组件时,匿名嵌入至组件结构体中
func (*ComponentBehavior) DestroySelf ¶
func (comp *ComponentBehavior) DestroySelf()
DestroySelf 销毁自身
func (*ComponentBehavior) EventComponentDestroySelf ¶ added in v0.3.34
func (comp *ComponentBehavior) EventComponentDestroySelf() event.IEvent
EventComponentDestroySelf 事件:组件销毁自身
func (*ComponentBehavior) GetBuiltin ¶ added in v0.3.60
func (comp *ComponentBehavior) GetBuiltin() BuiltinComponent
GetBuiltin 获取实体原型中的组件信息
func (*ComponentBehavior) GetConcurrentContext ¶ added in v0.2.32
func (comp *ComponentBehavior) GetConcurrentContext() iface.Cache
GetConcurrentContext 获取多线程安全的上下文
func (*ComponentBehavior) GetCurrentContext ¶
func (comp *ComponentBehavior) GetCurrentContext() iface.Cache
GetCurrentContext 获取当前上下文
func (*ComponentBehavior) GetEntity ¶
func (comp *ComponentBehavior) GetEntity() Entity
GetEntity 获取组件依附的实体
func (*ComponentBehavior) GetNonRemovable ¶ added in v0.3.40
func (comp *ComponentBehavior) GetNonRemovable() bool
GetNonRemovable 是否不可删除
func (*ComponentBehavior) GetReflected ¶ added in v0.2.58
func (comp *ComponentBehavior) GetReflected() reflect.Value
GetReflected 获取反射值
func (*ComponentBehavior) GetState ¶
func (comp *ComponentBehavior) GetState() ComponentState
GetState 获取组件状态
func (*ComponentBehavior) ManagedHooks ¶ added in v0.2.27
func (comp *ComponentBehavior) ManagedHooks(hooks ...event.Hook)
ManagedHooks 托管hook,在组件销毁时自动解绑定
func (*ComponentBehavior) String ¶
func (comp *ComponentBehavior) String() string
String implements fmt.Stringer
func (*ComponentBehavior) Terminated ¶ added in v0.3.33
func (comp *ComponentBehavior) Terminated() <-chan struct{}
Terminated 已停止
type ComponentPT ¶ added in v0.3.55
type ComponentPT interface { // Prototype 组件原型名称 Prototype() string // InstanceRT 组件实例反射类型 InstanceRT() reflect.Type // Construct 创建组件 Construct() Component }
ComponentPT 组件原型接口
type ComponentState ¶
type ComponentState int8
ComponentState 组件状态
const ( ComponentState_Birth ComponentState = iota // 出生 ComponentState_Attach // 附着 ComponentState_Awake // 唤醒 ComponentState_Start // 开始 ComponentState_Alive // 活跃 ComponentState_Detach // 脱离 ComponentState_Shut // 结束 ComponentState_Death // 死亡 )
func (ComponentState) String ¶
func (i ComponentState) String() string
type ConcurrentEntity ¶
type ConcurrentEntity interface { ictx.ConcurrentContextProvider fmt.Stringer // GetId 获取实体Id GetId() uid.Id // GetPT 获取实体原型信息 GetPT() EntityPT // contains filtered or unexported methods }
ConcurrentEntity 多线程安全的实体接口
type Entity ¶
type Entity interface { ictx.CurrentContextProvider reinterpret.InstanceProvider fmt.Stringer // GetId 获取实体Id GetId() uid.Id // GetPT 获取实体原型信息 GetPT() EntityPT // GetScope 获取可访问作用域 GetScope() Scope // GetState 获取实体状态 GetState() EntityState // GetReflected 获取反射值 GetReflected() reflect.Value // GetMeta 获取Meta信息 GetMeta() meta.Meta // DestroySelf 销毁自身 DestroySelf() IEntityEventTab // contains filtered or unexported methods }
Entity 实体接口
func UnsafeNewEntity
deprecated
func UnsafeNewEntity(options EntityOptions) Entity
Deprecated: UnsafeNewEntity 内部创建实体
type EntityBehavior ¶
EntityBehavior 实体行为,在扩展实体能力时,匿名嵌入至实体结构体中
func (*EntityBehavior) AddComponent ¶
func (entity *EntityBehavior) AddComponent(name string, components ...Component) error
AddComponent 添加组件,允许组件同名
func (*EntityBehavior) ContainsComponent ¶ added in v0.2.58
func (entity *EntityBehavior) ContainsComponent(name string) bool
ContainsComponent 组件是否存在
func (*EntityBehavior) ContainsComponentById ¶ added in v0.2.58
func (entity *EntityBehavior) ContainsComponentById(id uid.Id) bool
ContainsComponentById 使用组件Id检测组件是否存在
func (*EntityBehavior) ContainsComponentByPT ¶ added in v0.3.65
func (entity *EntityBehavior) ContainsComponentByPT(prototype string) bool
ContainsComponentByPT 使用组件原型查询组件
func (*EntityBehavior) CountComponents ¶
func (entity *EntityBehavior) CountComponents() int
CountComponents 统计所有组件数量
func (*EntityBehavior) EventComponentManagerAddComponents ¶ added in v0.3.66
func (entity *EntityBehavior) EventComponentManagerAddComponents() event.IEvent
EventComponentManagerAddComponents 事件:实体的组件管理器添加组件
func (*EntityBehavior) EventComponentManagerFirstTouchComponent ¶ added in v0.3.66
func (entity *EntityBehavior) EventComponentManagerFirstTouchComponent() event.IEvent
EventComponentManagerFirstTouchComponent 事件:实体的组件管理器首次访问组件
func (*EntityBehavior) EventComponentManagerRemoveComponent ¶ added in v0.3.66
func (entity *EntityBehavior) EventComponentManagerRemoveComponent() event.IEvent
EventComponentManagerRemoveComponent 事件:实体的组件管理器删除组件
func (*EntityBehavior) EventEntityDestroySelf ¶ added in v0.3.34
func (entity *EntityBehavior) EventEntityDestroySelf() event.IEvent
EventEntityDestroySelf 事件:实体销毁自身
func (*EntityBehavior) EventTreeNodeAddChild ¶ added in v0.2.58
func (entity *EntityBehavior) EventTreeNodeAddChild() event.IEvent
EventTreeNodeAddChild 事件:实体节点添加子实体
func (*EntityBehavior) EventTreeNodeEnterParent ¶ added in v0.2.58
func (entity *EntityBehavior) EventTreeNodeEnterParent() event.IEvent
EventTreeNodeEnterParent 事件:实体加入父实体节点
func (*EntityBehavior) EventTreeNodeLeaveParent ¶ added in v0.2.58
func (entity *EntityBehavior) EventTreeNodeLeaveParent() event.IEvent
EventTreeNodeLeaveParent 事件:实体离开父实体节点
func (*EntityBehavior) EventTreeNodeRemoveChild ¶ added in v0.2.58
func (entity *EntityBehavior) EventTreeNodeRemoveChild() event.IEvent
EventTreeNodeRemoveChild 事件:实体节点删除子实体
func (*EntityBehavior) FilterComponents ¶ added in v0.2.58
FilterComponents 过滤并获取组件
func (*EntityBehavior) GetComponent ¶
func (entity *EntityBehavior) GetComponent(name string) Component
GetComponent 使用名称查询组件,组件同名时,返回首个组件
func (*EntityBehavior) GetComponentById ¶
func (entity *EntityBehavior) GetComponentById(id uid.Id) Component
GetComponentById 使用组件Id查询组件
func (*EntityBehavior) GetComponentByPT ¶ added in v0.3.65
func (entity *EntityBehavior) GetComponentByPT(prototype string) Component
GetComponentByPT 使用组件原型查询组件
func (*EntityBehavior) GetComponents ¶
func (entity *EntityBehavior) GetComponents() []Component
GetComponents 获取所有组件
func (*EntityBehavior) GetConcurrentContext ¶
func (entity *EntityBehavior) GetConcurrentContext() iface.Cache
GetConcurrentContext 解析线程安全的上下文
func (*EntityBehavior) GetCurrentContext ¶
func (entity *EntityBehavior) GetCurrentContext() iface.Cache
GetCurrentContext 获取当前上下文
func (*EntityBehavior) GetInstanceFaceCache ¶ added in v0.3.34
func (entity *EntityBehavior) GetInstanceFaceCache() iface.Cache
GetInstanceFaceCache 支持重新解释类型
func (*EntityBehavior) GetPT ¶ added in v0.3.55
func (entity *EntityBehavior) GetPT() EntityPT
GetPT 获取实体原型
func (*EntityBehavior) GetReflected ¶ added in v0.2.58
func (entity *EntityBehavior) GetReflected() reflect.Value
GetReflected 获取反射值
func (*EntityBehavior) GetScope ¶ added in v0.2.23
func (entity *EntityBehavior) GetScope() Scope
GetScope 获取可访问作用域
func (*EntityBehavior) GetState ¶
func (entity *EntityBehavior) GetState() EntityState
GetState 获取实体状态
func (*EntityBehavior) GetTreeNodeParent ¶ added in v0.2.58
func (entity *EntityBehavior) GetTreeNodeParent() (Entity, bool)
GetTreeNodeParent 获取在实体树中的父实体
func (*EntityBehavior) GetTreeNodeState ¶ added in v0.2.58
func (entity *EntityBehavior) GetTreeNodeState() TreeNodeState
GetTreeNodeState 获取实体树节点状态
func (*EntityBehavior) ManagedHooks ¶ added in v0.2.27
func (entity *EntityBehavior) ManagedHooks(hooks ...event.Hook)
ManagedHooks 托管hook,在实体销毁时自动解绑定
func (*EntityBehavior) RangeComponents ¶
func (entity *EntityBehavior) RangeComponents(fun generic.Func1[Component, bool])
RangeComponents 遍历所有组件
func (*EntityBehavior) RemoveComponent ¶
func (entity *EntityBehavior) RemoveComponent(name string)
RemoveComponent 使用名称删除组件,同名组件均会删除
func (*EntityBehavior) RemoveComponentById ¶
func (entity *EntityBehavior) RemoveComponentById(id uid.Id)
RemoveComponentById 使用组件Id删除组件
func (*EntityBehavior) ReversedRangeComponents ¶ added in v0.2.58
func (entity *EntityBehavior) ReversedRangeComponents(fun generic.Func1[Component, bool])
ReversedRangeComponents 反向遍历所有组件
func (*EntityBehavior) String ¶
func (entity *EntityBehavior) String() string
String implements fmt.Stringer
func (*EntityBehavior) Terminated ¶ added in v0.3.33
func (entity *EntityBehavior) Terminated() <-chan struct{}
Terminated 已停止
type EntityOptions ¶
type EntityOptions struct { InstanceFace iface.Face[Entity] // 实例,用于扩展实体能力 Scope Scope // 可访问作用域 PersistId uid.Id // 实体持久化Id ComponentAwakeOnFirstTouch bool // 开启组件被首次访问时,检测并调用Awake() ComponentUniqueID bool // 开启组件唯一Id Meta meta.Meta // Meta信息 }
EntityOptions 创建实体的所有选项
type EntityPT ¶ added in v0.3.55
type EntityPT interface { // Prototype 实体原型名称 Prototype() string // InstanceRT 实体实例反射类型 InstanceRT() reflect.Type // Scope 可访问作用域 Scope() *Scope // ComponentAwakeOnFirstTouch 开启组件被首次访问时,检测并调用Awake() ComponentAwakeOnFirstTouch() *bool // ComponentUniqueID 开启组件唯一Id ComponentUniqueID() *bool // Extra 自定义原型属性 Extra() generic.SliceMap[string, any] // CountComponents // 组件数量 CountComponents() int // Component 获取组件 Component(idx int) BuiltinComponent // Components 获取所有组件 Components() []BuiltinComponent // Construct 创建实体 Construct(settings ...option.Setting[EntityOptions]) Entity }
EntityPT 实体原型接口
type EntityState ¶
type EntityState int8
EntityState 实体状态
const ( EntityState_Birth EntityState = iota // 出生 EntityState_Enter // 进入容器 EntityState_Awake // 唤醒 EntityState_Start // 开始 EntityState_Alive // 活跃 EntityState_Leave // 离开容器 EntityState_Shut // 结束 EntityState_Death // 死亡 )
func (EntityState) String ¶
func (i EntityState) String() string
type EventComponentDestroySelf ¶
type EventComponentDestroySelf interface {
OnComponentDestroySelf(comp Component)
}
EventComponentDestroySelf 事件:组件销毁自身 +event-gen:export=0 +event-tab-gen:recursion=discard
type EventComponentDestroySelfHandler ¶ added in v0.2.51
type EventComponentDestroySelfHandler func(comp Component)
func HandleEventComponentDestroySelf ¶ added in v0.2.50
func HandleEventComponentDestroySelf(fun func(comp Component)) EventComponentDestroySelfHandler
func (EventComponentDestroySelfHandler) OnComponentDestroySelf ¶ added in v0.2.51
func (h EventComponentDestroySelfHandler) OnComponentDestroySelf(comp Component)
type EventComponentManagerAddComponents ¶ added in v0.3.66
type EventComponentManagerAddComponents interface {
OnComponentManagerAddComponents(entity Entity, components []Component)
}
EventComponentManagerAddComponents 事件:实体的组件管理器添加组件 +event-gen:export=0
type EventComponentManagerAddComponentsHandler ¶ added in v0.3.66
func HandleEventComponentManagerAddComponents ¶ added in v0.3.66
func HandleEventComponentManagerAddComponents(fun func(entity Entity, components []Component)) EventComponentManagerAddComponentsHandler
func (EventComponentManagerAddComponentsHandler) OnComponentManagerAddComponents ¶ added in v0.3.66
func (h EventComponentManagerAddComponentsHandler) OnComponentManagerAddComponents(entity Entity, components []Component)
type EventComponentManagerFirstTouchComponent ¶ added in v0.3.66
type EventComponentManagerFirstTouchComponent interface {
OnComponentManagerFirstTouchComponent(entity Entity, component Component)
}
EventComponentManagerFirstTouchComponent 事件:实体的组件管理器首次访问组件 +event-gen:export=0
type EventComponentManagerFirstTouchComponentHandler ¶ added in v0.3.66
func HandleEventComponentManagerFirstTouchComponent ¶ added in v0.3.66
func HandleEventComponentManagerFirstTouchComponent(fun func(entity Entity, component Component)) EventComponentManagerFirstTouchComponentHandler
func (EventComponentManagerFirstTouchComponentHandler) OnComponentManagerFirstTouchComponent ¶ added in v0.3.66
func (h EventComponentManagerFirstTouchComponentHandler) OnComponentManagerFirstTouchComponent(entity Entity, component Component)
type EventComponentManagerRemoveComponent ¶ added in v0.3.66
type EventComponentManagerRemoveComponent interface {
OnComponentManagerRemoveComponent(entity Entity, component Component)
}
EventComponentManagerRemoveComponent 事件:实体的组件管理器删除组件 +event-gen:export=0
type EventComponentManagerRemoveComponentHandler ¶ added in v0.3.66
func HandleEventComponentManagerRemoveComponent ¶ added in v0.3.66
func HandleEventComponentManagerRemoveComponent(fun func(entity Entity, component Component)) EventComponentManagerRemoveComponentHandler
func (EventComponentManagerRemoveComponentHandler) OnComponentManagerRemoveComponent ¶ added in v0.3.66
func (h EventComponentManagerRemoveComponentHandler) OnComponentManagerRemoveComponent(entity Entity, component Component)
type EventEntityDestroySelf ¶
type EventEntityDestroySelf interface {
OnEntityDestroySelf(entity Entity)
}
EventEntityDestroySelf 事件:实体销毁自身 +event-gen:export=0 +event-tab-gen:recursion=discard
type EventEntityDestroySelfHandler ¶ added in v0.2.51
type EventEntityDestroySelfHandler func(entity Entity)
func HandleEventEntityDestroySelf ¶ added in v0.2.50
func HandleEventEntityDestroySelf(fun func(entity Entity)) EventEntityDestroySelfHandler
func (EventEntityDestroySelfHandler) OnEntityDestroySelf ¶ added in v0.2.51
func (h EventEntityDestroySelfHandler) OnEntityDestroySelf(entity Entity)
type EventTreeNodeAddChild ¶ added in v0.2.58
type EventTreeNodeAddChild interface {
OnTreeNodeAddChild(self, child Entity)
}
EventTreeNodeAddChild 事件:实体节点添加子实体 +event-gen:export=0
type EventTreeNodeAddChildHandler ¶ added in v0.2.58
type EventTreeNodeAddChildHandler func(self, child Entity)
func HandleEventTreeNodeAddChild ¶ added in v0.2.58
func HandleEventTreeNodeAddChild(fun func(self, child Entity)) EventTreeNodeAddChildHandler
func (EventTreeNodeAddChildHandler) OnTreeNodeAddChild ¶ added in v0.2.58
func (h EventTreeNodeAddChildHandler) OnTreeNodeAddChild(self, child Entity)
type EventTreeNodeEnterParent ¶ added in v0.2.58
type EventTreeNodeEnterParent interface {
OnTreeNodeEnterParent(self, parent Entity)
}
EventTreeNodeEnterParent 事件:实体加入父实体节点 +event-gen:export=0
type EventTreeNodeEnterParentHandler ¶ added in v0.2.58
type EventTreeNodeEnterParentHandler func(self, parent Entity)
func HandleEventTreeNodeEnterParent ¶ added in v0.2.58
func HandleEventTreeNodeEnterParent(fun func(self, parent Entity)) EventTreeNodeEnterParentHandler
func (EventTreeNodeEnterParentHandler) OnTreeNodeEnterParent ¶ added in v0.2.58
func (h EventTreeNodeEnterParentHandler) OnTreeNodeEnterParent(self, parent Entity)
type EventTreeNodeLeaveParent ¶ added in v0.2.58
type EventTreeNodeLeaveParent interface {
OnTreeNodeLeaveParent(self, parent Entity)
}
EventTreeNodeLeaveParent 事件:实体离开父实体节点 +event-gen:export=0
type EventTreeNodeLeaveParentHandler ¶ added in v0.2.58
type EventTreeNodeLeaveParentHandler func(self, parent Entity)
func HandleEventTreeNodeLeaveParent ¶ added in v0.2.58
func HandleEventTreeNodeLeaveParent(fun func(self, parent Entity)) EventTreeNodeLeaveParentHandler
func (EventTreeNodeLeaveParentHandler) OnTreeNodeLeaveParent ¶ added in v0.2.58
func (h EventTreeNodeLeaveParentHandler) OnTreeNodeLeaveParent(self, parent Entity)
type EventTreeNodeRemoveChild ¶ added in v0.2.58
type EventTreeNodeRemoveChild interface {
OnTreeNodeRemoveChild(self, child Entity)
}
EventTreeNodeRemoveChild 事件:实体节点删除子实体 +event-gen:export=0
type EventTreeNodeRemoveChildHandler ¶ added in v0.2.58
type EventTreeNodeRemoveChildHandler func(self, child Entity)
func HandleEventTreeNodeRemoveChild ¶ added in v0.2.58
func HandleEventTreeNodeRemoveChild(fun func(self, child Entity)) EventTreeNodeRemoveChildHandler
func (EventTreeNodeRemoveChildHandler) OnTreeNodeRemoveChild ¶ added in v0.2.58
func (h EventTreeNodeRemoveChildHandler) OnTreeNodeRemoveChild(self, child Entity)
type IComponentEventTab ¶ added in v0.3.48
type IEntityComponentManagerEventTab ¶ added in v0.3.66
type IEntityEventTab ¶ added in v0.3.48
type IEntityTreeNodeEventTab ¶ added in v0.3.48
type TreeNodeState ¶ added in v0.2.58
type TreeNodeState int8
TreeNodeState 实体树节点状态
const ( TreeNodeState_Freedom TreeNodeState = iota // 自由实体 TreeNodeState_Attaching // 正在加入实体树 TreeNodeState_Attached // 在实体树中 TreeNodeState_Detaching // 正在脱离实体树 )
func (TreeNodeState) String ¶ added in v0.2.58
func (i TreeNodeState) String() string
Source Files ¶
- component.go
- component_event.gen.go
- component_event.go
- component_event.tab.gen.go
- component_managedhooks.go
- componentstate.go
- componentstate_string.go
- doc.go
- entity.go
- entity_componentmanager.go
- entity_componentmanager_event.gen.go
- entity_componentmanager_event.go
- entity_componentmanager_event.tab.gen.go
- entity_concurrent.go
- entity_event.gen.go
- entity_event.go
- entity_event.tab.gen.go
- entity_managedhooks.go
- entity_options.go
- entity_treenode.go
- entity_treenode_event.gen.go
- entity_treenode_event.go
- entity_treenode_event.tab.gen.go
- entitystate.go
- entitystate_string.go
- errors.go
- prototype.go
- scope.go
- scope_string.go
- treenodestate.go
- treenodestate_string.go
- unsafe_component.go
- unsafe_concurrententity.go
- unsafe_entity.go