Documentation ¶
Index ¶
- func LoadEntityData(handler func(activityType, activityId, entityId, data any))
- func LoadGlobalData(handler func(activityType, activityId, data any))
- func LoadOrRefreshActivity[Type, ID generic.Basic](activityType Type, activityId ID, options ...*Options) error
- func OnEndedEvent[Type, ID generic.Basic](activity *Activity[Type, ID])
- func OnExtendedShowEndedEvent[Type, ID generic.Basic](activity *Activity[Type, ID])
- func OnExtendedShowStartedEvent[Type, ID generic.Basic](activity *Activity[Type, ID])
- func OnNewDayEvent[Type, ID generic.Basic](activity *Activity[Type, ID])
- func OnStartedEvent[Type, ID generic.Basic](activity *Activity[Type, ID])
- func OnUpcomingEvent[Type, ID generic.Basic](activity *Activity[Type, ID])
- func RegEndedEvent[Type, ID generic.Basic](activityType Type, handler EndedEventHandler[ID], priority ...int)
- func RegExtendedShowEndedEvent[Type, ID generic.Basic](activityType Type, handler ExtendedShowEndedEventHandler[ID], priority ...int)
- func RegExtendedShowStartedEvent[Type, ID generic.Basic](activityType Type, handler ExtendedShowStartedEventHandler[ID], ...)
- func RegNewDayEvent[Type, ID generic.Basic](activityType Type, handler NewDayEventHandler[ID], priority ...int)
- func RegStartedEvent[Type, ID generic.Basic](activityType Type, handler StartedEventHandler[ID], priority ...int)
- func RegUpcomingEvent[Type, ID generic.Basic](activityType Type, handler UpcomingEventHandler[ID], priority ...int)
- func SetTicker(size int, options ...timer.Option)
- type Activity
- type BasicActivityController
- type Controller
- func (slf *Controller[Type, ID, Data, EntityID, EntityData]) GetEntityData(activityId ID, entityId EntityID) EntityData
- func (slf *Controller[Type, ID, Data, EntityID, EntityData]) GetGlobalData(activityId ID) Data
- func (slf *Controller[Type, ID, Data, EntityID, EntityData]) InitializeEntityData(...) EntityDataActivityController[Type, ID, Data, EntityID, EntityData]
- func (slf *Controller[Type, ID, Data, EntityID, EntityData]) InitializeGlobalAndEntityData(handler func(activityId ID, data *DataMeta[Data]), ...) GlobalAndEntityDataActivityController[Type, ID, Data, EntityID, EntityData]
- func (slf *Controller[Type, ID, Data, EntityID, EntityData]) InitializeGlobalData(handler func(activityId ID, data *DataMeta[Data])) GlobalDataActivityController[Type, ID, Data, EntityID, EntityData]
- func (slf *Controller[Type, ID, Data, EntityID, EntityData]) InitializeNoneData(handler func(activityId ID, data *DataMeta[Data])) NoneDataActivityController[Type, ID, Data, EntityID, EntityData]
- func (slf *Controller[Type, ID, Data, EntityID, EntityData]) IsOpen(activityId ID) bool
- func (slf *Controller[Type, ID, Data, EntityID, EntityData]) IsOpenOrShow(activityId ID) bool
- func (slf *Controller[Type, ID, Data, EntityID, EntityData]) IsShow(activityId ID) bool
- func (slf *Controller[Type, ID, Data, EntityID, EntityData]) Refresh(activityId ID)
- type DataMeta
- type EndedEventHandler
- type EntityDataActivityController
- type EntityDataMeta
- type ExtendedShowEndedEventHandler
- type ExtendedShowStartedEventHandler
- type GlobalAndEntityDataActivityController
- type GlobalDataActivityController
- type NewDayEventHandler
- type NoneDataActivityController
- type Options
- type StartedEventHandler
- type UpcomingEventHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadEntityData ¶ added in v0.3.2
func LoadEntityData(handler func(activityType, activityId, entityId, data any))
LoadEntityData 加载所有活动实体数据
func LoadGlobalData ¶ added in v0.3.2
func LoadGlobalData(handler func(activityType, activityId, data any))
LoadGlobalData 加载所有活动全局数据
func LoadOrRefreshActivity ¶ added in v0.3.2
func LoadOrRefreshActivity[Type, ID generic.Basic](activityType Type, activityId ID, options ...*Options) error
LoadOrRefreshActivity 加载或刷新活动
- 通常在活动配置刷新时候将活动通过该方法注册或刷新
func OnEndedEvent ¶ added in v0.3.2
OnEndedEvent 活动结束事件
func OnExtendedShowEndedEvent ¶ added in v0.3.2
OnExtendedShowEndedEvent 活动结束后延长展示结束事件
func OnExtendedShowStartedEvent ¶ added in v0.3.2
OnExtendedShowStartedEvent 活动结束后延长展示开始事件
func OnNewDayEvent ¶ added in v0.3.2
OnNewDayEvent 新的一天事件
func OnStartedEvent ¶ added in v0.3.2
OnStartedEvent 活动开始事件
func OnUpcomingEvent ¶ added in v0.3.2
OnUpcomingEvent 即将开始的活动事件
func RegEndedEvent ¶ added in v0.3.2
func RegEndedEvent[Type, ID generic.Basic](activityType Type, handler EndedEventHandler[ID], priority ...int)
RegEndedEvent 注册活动结束事件处理器
func RegExtendedShowEndedEvent ¶ added in v0.3.2
func RegExtendedShowEndedEvent[Type, ID generic.Basic](activityType Type, handler ExtendedShowEndedEventHandler[ID], priority ...int)
RegExtendedShowEndedEvent 注册活动结束后延长展示结束事件处理器
func RegExtendedShowStartedEvent ¶ added in v0.3.2
func RegExtendedShowStartedEvent[Type, ID generic.Basic](activityType Type, handler ExtendedShowStartedEventHandler[ID], priority ...int)
RegExtendedShowStartedEvent 注册活动结束后延长展示开始事件处理器
func RegNewDayEvent ¶ added in v0.3.2
func RegNewDayEvent[Type, ID generic.Basic](activityType Type, handler NewDayEventHandler[ID], priority ...int)
RegNewDayEvent 注册新的一天事件处理器
func RegStartedEvent ¶ added in v0.3.2
func RegStartedEvent[Type, ID generic.Basic](activityType Type, handler StartedEventHandler[ID], priority ...int)
RegStartedEvent 注册活动开始事件处理器
func RegUpcomingEvent ¶ added in v0.3.2
func RegUpcomingEvent[Type, ID generic.Basic](activityType Type, handler UpcomingEventHandler[ID], priority ...int)
RegUpcomingEvent 注册即将开始的活动事件处理器
Types ¶
type BasicActivityController ¶ added in v0.3.2
type BasicActivityController[Type, ID generic.Basic, Data any, EntityID generic.Basic, EntityData any] interface { // IsOpen 活动是否开启 IsOpen(activityId ID) bool // IsShow 活动是否展示 IsShow(activityId ID) bool // IsOpenOrShow 活动是否开启或展示 IsOpenOrShow(activityId ID) bool // Refresh 刷新活动 Refresh(activityId ID) }
type Controller ¶ added in v0.3.2
type Controller[Type, ID generic.Basic, Data any, EntityID generic.Basic, EntityData any] struct { // contains filtered or unexported fields }
Controller 活动控制器
func (*Controller[Type, ID, Data, EntityID, EntityData]) GetEntityData ¶ added in v0.3.2
func (slf *Controller[Type, ID, Data, EntityID, EntityData]) GetEntityData(activityId ID, entityId EntityID) EntityData
GetEntityData 获取特定活动实体数据
func (*Controller[Type, ID, Data, EntityID, EntityData]) GetGlobalData ¶ added in v0.3.2
func (slf *Controller[Type, ID, Data, EntityID, EntityData]) GetGlobalData(activityId ID) Data
GetGlobalData 获取特定活动全局数据
func (*Controller[Type, ID, Data, EntityID, EntityData]) InitializeEntityData ¶ added in v0.3.3
func (slf *Controller[Type, ID, Data, EntityID, EntityData]) InitializeEntityData(handler func(activityId ID, entityId EntityID, data *EntityDataMeta[EntityData])) EntityDataActivityController[Type, ID, Data, EntityID, EntityData]
func (*Controller[Type, ID, Data, EntityID, EntityData]) InitializeGlobalAndEntityData ¶ added in v0.3.3
func (slf *Controller[Type, ID, Data, EntityID, EntityData]) InitializeGlobalAndEntityData(handler func(activityId ID, data *DataMeta[Data]), entityHandler func(activityId ID, entityId EntityID, data *EntityDataMeta[EntityData])) GlobalAndEntityDataActivityController[Type, ID, Data, EntityID, EntityData]
func (*Controller[Type, ID, Data, EntityID, EntityData]) InitializeGlobalData ¶ added in v0.3.3
func (slf *Controller[Type, ID, Data, EntityID, EntityData]) InitializeGlobalData(handler func(activityId ID, data *DataMeta[Data])) GlobalDataActivityController[Type, ID, Data, EntityID, EntityData]
func (*Controller[Type, ID, Data, EntityID, EntityData]) InitializeNoneData ¶ added in v0.3.3
func (slf *Controller[Type, ID, Data, EntityID, EntityData]) InitializeNoneData(handler func(activityId ID, data *DataMeta[Data])) NoneDataActivityController[Type, ID, Data, EntityID, EntityData]
func (*Controller[Type, ID, Data, EntityID, EntityData]) IsOpen ¶ added in v0.3.2
func (slf *Controller[Type, ID, Data, EntityID, EntityData]) IsOpen(activityId ID) bool
IsOpen 活动是否开启
func (*Controller[Type, ID, Data, EntityID, EntityData]) IsOpenOrShow ¶ added in v0.3.2
func (slf *Controller[Type, ID, Data, EntityID, EntityData]) IsOpenOrShow(activityId ID) bool
IsOpenOrShow 活动是否开启或展示
func (*Controller[Type, ID, Data, EntityID, EntityData]) IsShow ¶ added in v0.3.2
func (slf *Controller[Type, ID, Data, EntityID, EntityData]) IsShow(activityId ID) bool
IsShow 活动是否展示
func (*Controller[Type, ID, Data, EntityID, EntityData]) Refresh ¶ added in v0.3.2
func (slf *Controller[Type, ID, Data, EntityID, EntityData]) Refresh(activityId ID)
Refresh 刷新活动
type DataMeta ¶ added in v0.3.2
type DataMeta[Data any] struct { Data Data `json:"data,omitempty"` // 活动数据 LastNewDay time.Time `json:"last_new_day,omitempty"` // 上次跨天时间 // contains filtered or unexported fields }
DataMeta 全局活动数据
type EndedEventHandler ¶ added in v0.3.2
type EntityDataActivityController ¶ added in v0.3.2
type EntityDataActivityController[Type, ID generic.Basic, Data any, EntityID generic.Basic, EntityData any] interface { BasicActivityController[Type, ID, Data, EntityID, EntityData] // GetEntityData 获取实体数据 GetEntityData(activityId ID, entityId EntityID) EntityData // InitializeEntityData 初始化活动 // - 该函数提供了一个操作活动数据的入口,可以在该函数中对传入的活动数据进行初始化 InitializeEntityData(handler func(activityId ID, entityId EntityID, data *EntityDataMeta[EntityData])) EntityDataActivityController[Type, ID, Data, EntityID, EntityData] }
EntityDataActivityController 实体数据活动控制器
func DefineEntityDataActivity ¶ added in v0.3.2
func DefineEntityDataActivity[Type, ID, EntityID generic.Basic, EntityData any](activityType Type) EntityDataActivityController[Type, ID, *none, EntityID, EntityData]
DefineEntityDataActivity 声明拥有实体数据的活动类型
type EntityDataMeta ¶ added in v0.3.2
type EntityDataMeta[Data any] struct { Data Data `json:"data,omitempty"` // 活动数据 LastNewDay time.Time `json:"last_new_day,omitempty"` // 上次跨天时间 // contains filtered or unexported fields }
EntityDataMeta 活动实体数据
type ExtendedShowEndedEventHandler ¶ added in v0.3.2
type ExtendedShowStartedEventHandler ¶ added in v0.3.2
type GlobalAndEntityDataActivityController ¶ added in v0.3.2
type GlobalAndEntityDataActivityController[Type, ID generic.Basic, Data any, EntityID generic.Basic, EntityData any] interface { BasicActivityController[Type, ID, Data, EntityID, EntityData] // GetGlobalData 获取全局数据 GetGlobalData(activityId ID) Data // GetEntityData 获取实体数据 GetEntityData(activityId ID, entityId EntityID) EntityData // InitializeGlobalAndEntityData 初始化活动 // - 该函数提供了一个操作活动数据的入口,可以在该函数中对传入的活动数据进行初始化 InitializeGlobalAndEntityData(handler func(activityId ID, data *DataMeta[Data]), entityHandler func(activityId ID, entityId EntityID, data *EntityDataMeta[EntityData])) GlobalAndEntityDataActivityController[Type, ID, Data, EntityID, EntityData] }
GlobalAndEntityDataActivityController 全局数据和实体数据活动控制器
func DefineGlobalAndEntityDataActivity ¶ added in v0.3.2
func DefineGlobalAndEntityDataActivity[Type, ID generic.Basic, Data any, EntityID generic.Basic, EntityData any](activityType Type) GlobalAndEntityDataActivityController[Type, ID, Data, EntityID, EntityData]
DefineGlobalAndEntityDataActivity 声明拥有全局数据和实体数据的活动类型
type GlobalDataActivityController ¶ added in v0.3.2
type GlobalDataActivityController[Type, ID generic.Basic, Data any, EntityID generic.Basic, EntityData any] interface { BasicActivityController[Type, ID, Data, EntityID, EntityData] // GetGlobalData 获取全局数据 GetGlobalData(activityId ID) Data // InitializeGlobalData 初始化活动 // - 该函数提供了一个操作活动数据的入口,可以在该函数中对传入的活动数据进行初始化 InitializeGlobalData(handler func(activityId ID, data *DataMeta[Data])) GlobalDataActivityController[Type, ID, Data, EntityID, EntityData] }
GlobalDataActivityController 全局数据活动控制器
func DefineGlobalDataActivity ¶ added in v0.3.2
func DefineGlobalDataActivity[Type, ID generic.Basic, Data any](activityType Type) GlobalDataActivityController[Type, ID, Data, none, *none]
DefineGlobalDataActivity 声明拥有全局数据的活动类型
type NewDayEventHandler ¶ added in v0.3.2
type NoneDataActivityController ¶ added in v0.3.2
type NoneDataActivityController[Type, ID generic.Basic, Data any, EntityID generic.Basic, EntityData any] interface { BasicActivityController[Type, ID, Data, EntityID, EntityData] // InitializeNoneData 初始化活动 // - 该函数提供了一个操作活动数据的入口,可以在该函数中对传入的活动数据进行初始化 // // 对于无数据活动,该函数的意义在于,可以在该函数中对活动进行初始化,比如设置活动的状态等,虽然为无数据活动,但是例如活动本身携带的状态数据也是需要加载的 InitializeNoneData(handler func(activityId ID, data *DataMeta[Data])) NoneDataActivityController[Type, ID, Data, EntityID, EntityData] }
NoneDataActivityController 无数据活动控制器
func DefineNoneDataActivity ¶ added in v0.3.2
func DefineNoneDataActivity[Type, ID generic.Basic](activityType Type) NoneDataActivityController[Type, ID, *none, none, *none]
DefineNoneDataActivity 声明无数据的活动类型
type Options ¶ added in v0.3.3
type Options struct { Tl *times.StateLine[byte] // 活动时间线 Loop time.Duration // 活动循环,时间间隔小于等于 0 表示不循环 }
Options 活动选项
func (*Options) WithEndTime ¶ added in v0.3.3
WithEndTime 设置活动结束时间
func (*Options) WithExtendedShowTime ¶ added in v0.3.3
WithExtendedShowTime 设置延长展示时间
func (*Options) WithLoop ¶ added in v0.3.3
WithLoop 设置活动循环,时间间隔小于等于 0 表示不循环
- 当活动状态展示结束后,会根据该选项设置的时间间隔重新开始
func (*Options) WithStartTime ¶ added in v0.3.3
WithStartTime 设置活动开始时间