go_dreamfactory/modules/reddot/module.go
2024-03-06 16:58:23 +08:00

164 lines
4.1 KiB
Go

package reddot
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
)
/*
模块名:红点系统
描述:统一获取红点信息
开发:李伟
*/
func NewModule() core.IModule {
m := new(Reddot)
return m
}
type Reddot struct {
modules.ModuleBase
service base.IRPCXService
smithy comm.ISmithy //铁匠铺
library comm.ILibrary //羁绊
mail comm.Imail //邮件
sociaty comm.ISociaty //工会
pagoda comm.IPagoda
horoscope comm.IHoroscope
arena comm.IArena //竞技场
practice comm.IPractice //武馆
dailytask comm.IDailytask //每日任务
friend comm.IFriend
gourmet comm.IGourmet
viking comm.IViking
hunting comm.IHunting
guildgve comm.IGuildgve //工会boos战
expedition comm.IExpedition //工会远征
api_comp *apiComp
mainline comm.IMainline
atlas comm.IPandaAtlas
color comm.IDColor
catchbugs comm.ICatchBugs
}
// 模块名
func (this *Reddot) GetType() core.M_Modules {
return comm.ModuleReddot
}
// 模块初始化接口 注册用户创建角色事件
func (this *Reddot) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
if err = this.ModuleBase.Init(service, module, options); err != nil {
return
}
this.service = service.(base.IRPCXService)
return
}
func (this *Reddot) Start() (err error) {
if err = this.ModuleBase.Start(); err != nil {
return
}
var module core.IModule
if module, err = this.service.GetModule(comm.ModuleMainline); err != nil {
return
}
this.mainline = module.(comm.IMainline)
if module, err = this.service.GetModule(comm.ModuleSmithy); err != nil {
return
}
this.smithy = module.(comm.ISmithy)
if module, err = this.service.GetModule(comm.ModuleFriend); err != nil {
return
}
this.friend = module.(comm.IFriend)
if module, err = this.service.GetModule(comm.ModulePagoda); err != nil {
return
}
this.pagoda = module.(comm.IPagoda)
if module, err = this.service.GetModule(comm.ModuleHoroscope); err != nil {
return
}
this.horoscope = module.(comm.IHoroscope)
if module, err = this.service.GetModule(comm.ModuleArena); err != nil {
return
}
this.arena = module.(comm.IArena)
if module, err = this.service.GetModule(comm.ModulePractice); err != nil {
return
}
this.practice = module.(comm.IPractice)
if module, err = this.service.GetModule(comm.ModuleGourmet); err != nil {
return
}
this.gourmet = module.(comm.IGourmet)
if module, err = this.service.GetModule(comm.ModuleSociaty); err != nil {
return
}
this.sociaty = module.(comm.ISociaty)
if module, err = this.service.GetModule(comm.ModuleMail); err != nil {
return
}
this.mail = module.(comm.Imail)
if module, err = this.service.GetModule(comm.ModuleViking); err != nil {
return
}
this.viking = module.(comm.IViking)
if module, err = this.service.GetModule(comm.ModuleHunting); err != nil {
return
}
this.hunting = module.(comm.IHunting)
if module, err = this.service.GetModule(comm.ModuleLibrary); err != nil {
return
}
this.library = module.(comm.ILibrary)
if module, err = this.service.GetModule(comm.ModuleDailytask); err != nil {
return
}
this.dailytask = module.(comm.IDailytask)
if module, err = this.service.GetModule(comm.ModuleGuildGve); err != nil {
return
}
this.guildgve = module.(comm.IGuildgve)
if module, err = this.service.GetModule(comm.ModulePandaAtlas); err != nil {
return
}
this.atlas = module.(comm.IPandaAtlas)
if module, err = this.service.GetModule(comm.ModuleDcolor); err != nil {
return
}
this.color = module.(comm.IDColor)
if module, err = this.service.GetModule(comm.ModuleCatchbugs); err != nil {
return
}
this.catchbugs = module.(comm.ICatchBugs)
return
}
// 装备组件
func (this *Reddot) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
}
// 推送红点
func (this *Reddot) PushReddot(session comm.IUserSession, reddot ...*pb.ReddotItem) (errdata *pb.ErrorData) {
if len(reddot) <= 0 {
return
}
session.SendMsg(string(this.GetType()), "change", &pb.ReddotChangePush{Rids: reddot})
return
}