本文整理汇总了Golang中server/data/datatype.Entityer类的典型用法代码示例。如果您正苦于以下问题:Golang Entityer类的具体用法?Golang Entityer怎么用?Golang Entityer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entityer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: teleportToBase
//传送回base
func (t *TeleportHelper) teleportToBase(app *RemoteApp, object datatype.Entityer, mailbox rpc.Mailbox, args ...interface{}) error {
sd := object.GetSceneData()
infos := make([]interface{}, 0, len(args)+1)
infos = append(infos, sd)
infos = append(infos, args)
return app.CallBack(&mailbox, "Teleport.SyncBaseWithSceneData", t.OnSyncBaseWithSceneData, infos)
}
示例2: GetSaveData
func GetSaveData(ent datatype.Entityer) *DbSave {
data := &DbSave{}
data.Data = GetEntityData(ent, false, 0)
roleinfo := ent.GetExtraData("roleinfo")
if roleinfo != nil {
data.RoleInfo = roleinfo.(string)
}
return data
}
示例3: FreeObj
//释放对象,如果有子对象一并释放
func (p *Pool) FreeObj(e datatype.Entityer) {
chds := e.GetChilds()
for _, ch := range chds {
if ch != nil {
p.FreeObj(ch)
}
}
e.ClearChilds()
p.Free(e)
}
示例4: SyncTable
func (ts *TableSync) SyncTable(player datatype.Entityer) {
recs := player.GetRecNames()
for _, r := range recs {
rec := player.GetRec(r)
if !rec.IsVisible() {
continue
}
out := tt.SyncTable(rec)
if out == nil {
continue
}
err := MailTo(nil, &ts.mailbox, "Entity.RecordInfo", out)
if err != nil {
log.LogError(err)
}
}
}
示例5: RecClear
func (gd *GlobalDataHelper) RecClear(self datatype.Entityer, rec datatype.Recorder) {
if !gd.isServer {
return
}
v := gd.dataChange()
for _, client := range gd.globalclients {
if client.disable || client.status == STATUS_NONE { //没有开启
continue
}
app := GetAppById(client.appid)
if app == nil {
continue
}
app.CallBack(nil, "GlobalHelper.GlobalDataRecClear", gd.OnDataChanged, self.GetIndex(), v, rec.GetName())
}
}
示例6: Update
//数据属性变动同步
func (gd *GlobalDataHelper) Update(self datatype.Entityer, index int16, value interface{}) {
if !gd.isServer {
return
}
v := gd.dataChange()
for _, client := range gd.globalclients {
if client.disable || client.status == STATUS_NONE { //没有开启
continue
}
app := GetAppById(client.appid)
if app == nil {
continue
}
app.CallBack(nil, "GlobalHelper.GlobalDataUpdate", gd.OnDataChanged, self.GetIndex(), v, index, datatype.NewAny(0, value))
}
}
示例7: Free
//释放一个具体对象,如果池中有空间,则回收,如果空闲的超过一定数量,则不回收,直接删除
func (p *Pool) Free(e datatype.Entityer) {
if l, exist := p.pool[e.ObjTypeName()]; exist {
if l.Len() <= MAX_POOL_FREE {
e.Reset()
l.PushBack(e)
}
} else {
l := list.New()
e.Reset()
l.PushBack(e)
p.pool[e.ObjTypeName()] = l
}
}
示例8: OnRemove
func (gd *GlobalDataHelper) OnRemove(self datatype.Entityer, sender datatype.Entityer, index int) int {
if !gd.isServer {
return 1
}
sender.SetPropSyncer(nil)
recs := sender.GetRecNames()
for _, v := range recs {
rec := sender.GetRec(v)
if rec.IsVisible() {
rec.SetSyncer(nil)
}
}
return 1
}
示例9: GetEntityData
func GetEntityData(ent datatype.Entityer, base bool, depth int) *SaveEntity {
if !base && !ent.IsSave() {
return nil
}
s := &SaveEntity{}
ent.SyncToDb()
s.Typ = ent.ObjTypeName()
s.DBId = ent.GetDbId()
s.Obj = ent.GetSaveLoader()
s.Index = ent.GetIndex()
if ent.Base() != nil {
s.Base = GetEntityData(ent.Base(), true, depth)
}
if base {
return s
}
if depth > 1 {
return s
}
clds := ent.GetChilds()
l := len(clds)
if l > 0 {
s.Childs = make([]*SaveEntity, 0, l)
for _, e := range clds {
if e != nil {
if child := GetEntityData(e, false, depth+1); child != nil {
s.Childs = append(s.Childs, child)
}
}
}
}
return s
}
示例10: GetItemInfo
func GetItemInfo(obj datatype.Entityer, syncchild bool) (*datatype.EntityInfo, error) {
item := &datatype.EntityInfo{}
buffer := new(bytes.Buffer)
enc := gob.NewEncoder(buffer)
err := enc.Encode(obj)
if err != nil {
log.LogError("encode ", obj.ObjTypeName(), "error,", err)
return nil, err
}
item.Type = obj.ObjTypeName()
item.Caps = obj.GetCapacity()
item.DbId = obj.GetDbId()
item.ObjId = obj.GetObjId()
item.Index = obj.GetIndex()
item.Data = buffer.Bytes()
if syncchild {
ls := obj.GetChilds()
if len(ls) > 0 {
item.Childs = make([]*datatype.EntityInfo, 0, len(ls))
}
for _, c := range ls {
if c != nil {
child, err := GetItemInfo(c, syncchild)
if err != nil {
return nil, err
}
item.Childs = append(item.Childs, child)
}
}
}
return item, nil
}