7 Star 26 Fork 2

Gitee 极速下载 / goworld

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/xiaonanln/goworld
克隆/下载
space_ops.go 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
seis 提交于 2018-07-08 16:10 . CreateSpaceOnGame, CreateEntityOnGame
package entity
import (
"strconv"
"github.com/xiaonanln/goworld/engine/common"
"github.com/xiaonanln/goworld/engine/gwlog"
"github.com/xiaonanln/goworld/engine/uuid"
)
// CreateSpaceLocally creates a space in the local game server
func CreateSpaceLocally(kind int) *Space {
if kind == 0 {
gwlog.Panicf("Can not create nil space with kind=0. Game will create 1 nil space automatically.")
}
e := createEntity(_SPACE_ENTITY_TYPE, nil, Vector3{}, "", map[string]interface{}{
_SPACE_KIND_ATTR_KEY: kind,
})
return e.AsSpace()
}
// CreateSpaceSomewhere creates a space in any game server
func CreateSpaceSomewhere(gameid uint16, kind int) common.EntityID {
if kind == 0 {
gwlog.Panicf("Can not create nil space with kind=0. Game will create 1 nil space automatically.")
}
return createEntitySomewhere(gameid, _SPACE_ENTITY_TYPE, map[string]interface{}{
_SPACE_KIND_ATTR_KEY: kind,
})
}
// CreateNilSpace creates the nil space
func CreateNilSpace(gameid uint16) *Space {
spaceID := GetNilSpaceID(gameid)
e := createEntity(_SPACE_ENTITY_TYPE, nil, Vector3{}, spaceID, map[string]interface{}{
_SPACE_KIND_ATTR_KEY: 0,
})
return e.AsSpace()
}
// GetNilSpaceEntityID returns the EntityID for Nil Space on the specified game
// GoWorld uses fixed EntityID for nil spaces on each game
func GetNilSpaceID(gameid uint16) common.EntityID {
gameidStr := strconv.Itoa(int(gameid))
return common.EntityID(uuid.GenFixedUUID([]byte(gameidStr)))
}
func GetNilSpace() *Space {
return nilSpace
}
1
https://gitee.com/mirrors/goworld.git
git@gitee.com:mirrors/goworld.git
mirrors
goworld
goworld
v0.1.6

搜索帮助