/
ClientSpace.go
43 lines (35 loc) · 776 Bytes
/
ClientSpace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"sync"
"github.com/xiaonanln/goworld/engine/common"
"github.com/xiaonanln/typeconv"
)
// ClientSpace is the space on client
type ClientSpace struct {
sync.Mutex
owner *ClientBot
ID common.EntityID
Kind int
Attrs clientAttrs
destroyed bool
}
func newClientSpace(owner *ClientBot, entityid common.EntityID, data map[string]interface{}) *ClientSpace {
space := &ClientSpace{
owner: owner,
ID: entityid,
Attrs: data,
}
space.Kind = int(typeconv.Int(data["_K"]))
return space
}
func (space *ClientSpace) String() string {
return fmt.Sprintf("ClientSpace<%d|%s>", space.Kind, space.ID)
}
// Destroy the client space
func (space *ClientSpace) Destroy() {
if space.destroyed {
return
}
space.destroyed = true
}