1 Star 0 Fork 0

liuxuezhan / mylib

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Asset_BattleNotice.go 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
liuxuezhan 提交于 2020-12-19 16:15 . 'ok'
package cache
import (
proto "gitee.com/liuxuezhan/mylib/Protocol"
"gitee.com/liuxuezhan/mylib/common"
"gitee.com/liuxuezhan/mylib/wtime"
)
//战斗通知(右下角提示框)
type Asset_BattleNotice struct {
Basic
AssetData map[int64]*proto.ST_BattleNotice_PB
}
func (this *Asset_BattleNotice) ReUse() {
this.Lock()
defer this.Unlock()
this.AssetData = make(map[int64]*proto.ST_BattleNotice_PB)
}
func (this *Asset_BattleNotice) ToServerPB() proto.Message {
battleNoticeAsset := &proto.ST_BattleNoticesAsset_PB{}
for _, v := range this.AssetData {
if int64(0) == v.GetNoticeUID() {
continue
}
battleNoticeAsset.Notices = append(battleNoticeAsset.Notices, v)
}
return battleNoticeAsset
}
func (this *Asset_BattleNotice) ToClientString() []byte {
strData := common.AddVersionInfoBeforeData(this.ToServerString(), this.versionid)
//数据同步给客户端后重置
this.ReUse()
return strData
}
func (this *Asset_BattleNotice) ToServerString() []byte {
this.RLock()
defer this.RUnlock()
return proto.Marshal(this.ToServerPB())
}
/**
@brief 创建战斗通知
*/
func (userData *Info) CreateBattleNotice(BIUID int64, battleNotice *proto.ST_BattleNotice_PB) {
battleNotice.Timestamp = proto.SetUint64(wtime.GetNow())
battleNotice.NoticeUID = proto.SetInt64(BIUID)
assetData := userData.info.AssetData_BattleNotice
assetData.Lock()
defer assetData.Unlock()
assetData.AssetData[BIUID] = battleNotice
assetData.Dirty()
userData.DirtyAll()
}
1
https://gitee.com/liuxuezhan/mylib.git
git@gitee.com:liuxuezhan/mylib.git
liuxuezhan
mylib
mylib
v1.1.3

搜索帮助