Documentation ¶
Index ¶
- Variables
- func BindActorName(typ TActor, name string)
- func BindComponent(typ TComponent, name string)
- func BindEvent(typ TEvent, name string, new func() interface{})
- func ExistObject() error
- func NewSpace() *space
- func NotExistObject() error
- func NotExistObjectFactory() error
- func NotExistObjectGroup() error
- func NotExistObjectGroupTag() error
- func RecycleEvents(events ...IEvent)
- type FEventSetter
- type FInt64
- type FObjectAction
- type FObjectEvent
- type FObjectFac
- type FObjectTick
- type FSpaceAction
- type IActor
- type IComponent
- type IEvent
- type ISpace
- type TActor
- type TComponent
- type TEvent
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //检测事件是否有效 CheckEvent func(actor IActor, event IEvent) bool )
Functions ¶
func BindActorName ¶
func BindComponent ¶
func BindComponent(typ TComponent, name string)
func ExistObject ¶
func ExistObject() error
func NotExistObject ¶
func NotExistObject() error
func NotExistObjectFactory ¶
func NotExistObjectFactory() error
func NotExistObjectGroup ¶
func NotExistObjectGroup() error
func NotExistObjectGroupTag ¶
func NotExistObjectGroupTag() error
func RecycleEvents ¶
func RecycleEvents(events ...IEvent)
Types ¶
type FObjectAction ¶
@Description: 对象行为函数 @param tid 链路id @param obj 对象 @param data 数据 @param complete 行为执行完成回调
type FObjectEvent ¶
@Description: 对象事件监听函数 @param tid @param obj @param event
type FObjectFac ¶
@Description: 对象工厂函数,用于组装对象 @param tid 链路id @param obj 对象 @param data 数据
type FObjectTick ¶
@Description: 对象事件心跳处理 @param tid 链路id @param obj 对象 @param data 数据 @param ms 心跳间隔
type FSpaceAction ¶
@Description: 空间行为 @param tid 链路id @param data 数据
type IActor ¶
type IActor interface { utils.IWorker // @Description: 所在空间 // @return ISpace Space() ISpace // @Description: 对象id // @return int64 Id() int64 // @Description: 对象类型 // @return TActor Type() TActor // @Description: 添加数据组件 // @param data AddComponent(data ...IComponent) // @Description: 移除数据组件 // @param typ RemoveComponent(typ TComponent) // @Description: 是否有数据组件 // @param typ // @return ok HasComponent(typ TComponent) (ok bool) // @Description: 获取数据 // @param typ 数据类型 // @return IComponent 数据 // @return bool 是否有该数据 GetComponent(typ TComponent) (IComponent, bool) // @Description: 绑定事件监听器 // @param typ 事件类型 // @param listener 事件监听器 BindEvent(typ TEvent, listener FObjectEvent) // @Description: 派发事件 // @param tid 链路id // @param complete 所有监听器处理完成,可用于回收事件等 // @param event DispatchEvents(tid int64, event ...IEvent) // @Description: 添加心跳 // @param tid 链路id // @param data 心跳需要的数据 // @param tick 心跳处理函数 // @return int64 心跳处理id,用于移除 AddTick(tid int64, data interface{}, tick FObjectTick) int64 // @Description: 移除心跳处理函数 // @param id 添加心跳时返回的id RemoveTick(id int64) // @Description: 启动对象协程 Start() //停止对象协程 Dispose() // contains filtered or unexported methods }
@Description: 对象 所有方法必需在该对象的协程内执行 使用ISpace的相关方法传递执行,
type ISpace ¶
type ISpace interface { utils.IWorker // @Description: 空间数据,并发安全 // @return utils.IComponent Data() utils.IData // @Description: 绑定对象的工厂函数, 需要调用Object的Start方法启动对象协程 // @param typ 类型 // @param fac 工厂函数 BindActorFac(typ TActor, fac FObjectFac) // @Description: 空间协程生成对象 // @param tid 链路id // @param objectId 对象id // @param typ 对象类型 // @param data 构建对象需要的数据 // @param tags 对象的标签 SpawnObject(tid int64, objectId int64, typ TActor, data interface{}, tags ...string) // @Description: 空间协程回收对象 // @param tid 链路id // @param objectId 对象id RecycleObject(tid, objectId int64) // @Description: 空间协程判断是否有对象 // @param objectId // @return bool HasObject(objectId int64) bool // @Description: 空间协程指定对象执行行为 // @param tid 链路id // @param objectId 对象id // @param data 行为需要的数据 // @param action 行为回调 // @param complete 在对象协程执行的回调 ActionObject(tid, objectId int64, data interface{}, action FObjectAction, complete utils.Action) // @Description: 空间协程添加对象标签 // @param objectId 对象id // @param tags 标签 // @return error 对象id不存在返回_NotExistObject AddObjectTags(objectId int64, tags ...string) error // @Description: 空间协程移除对象标签 // @param objectId 对象id // @param tags 标签 // @return error 对象id不存在返回_NotExistObject RemoveObjectTags(objectId int64, tags ...string) error // @Description: 空间协程批量添加标签对象 // @param tid 链路id // @param tag 标签 // @param objectIds 对象id AddTagObjects(tid int64, tag string, objectIds ...int64) // @Description: 空间协程批量移除标签对象 // @param tid 链路id // @param tag 标签 // @param objectIds 对象id RemoveTagObjects(tid int64, tag string, objectIds ...int64) // @Description: 空间协程指定标签的所有对象执行行为 // @param tid 链路id // @param data 行为所需数据 // @param action 行为回调 // @param complete 新协程执行完成回调 // @param tags 标签 ActionTagObjects(tid int64, data interface{}, action FObjectAction, complete utils.Action, tags ...string) // @Description: 空间协程获取对象的标签 // @param objectId 对象id // @return []string 对象的标签 // @return bool 是否有指定对象id GetObjectTags(objectId int64) ([]string, bool) // @Description: 启动协程 // @param complete // @param tickDur Start(complete utils.Action, tickDur time.Duration) // contains filtered or unexported methods }
@Description: 管理对象的空间 内部一个协程管理对象及标签,调用Unsafe开头的方法必需在Action的FSpaceAction参数中执行,否则会有数据竞争 每个对象内部数据都由一个单独协程处理
type TComponent ¶
type TComponent uint16
func (TComponent) String ¶
func (t TComponent) String() string
Click to show internal directories.
Click to hide internal directories.