goworld: github.com/xiaonanln/goworld Index | Files | Directories

package goworld

import "github.com/xiaonanln/goworld"

Index

Package Files

goworld.go

func AddCallback Uses

func AddCallback(d time.Duration, callback func())

AddTimer adds a timer to be executed after specified duration

func AddTimer Uses

func AddTimer(d time.Duration, callback func())

AddTimer adds a repeat timer to be executed every specified duration

func Call Uses

func Call(id EntityID, method string, args ...interface{})

Call other entities

func CallNilSpaces Uses

func CallNilSpaces(method string, args ...interface{})

CallNilSpaces calls methods of all nil spaces on all games

func CallService Uses

func CallService(serviceName string, method string, args ...interface{})

CallService calls a service entity

func Entities Uses

func Entities() entity.EntityMap

Entities gets all entities as an EntityMap (do not modify it!)

func Exists Uses

func Exists(typeName string, entityID EntityID, callback storage.ExistsCallbackFunc)

Exists checks if entityID exists in entity storage

returns result in callback

func GetGameID Uses

func GetGameID() uint16

GetGameID gets the local server ID

server ID is a uint16 number starts from 1, which should be different for each servers server ID is also in the game config section name of goworld.ini

func GetKVDB Uses

func GetKVDB(key string, callback kvdb.KVDBGetCallback)

GetKVDB gets value of key from KVDB

func GetOrPutKVDB Uses

func GetOrPutKVDB(key string, val string, callback kvdb.KVDBGetOrPutCallback)

GetOrPut gets value of key from KVDB, if val not exists or is "", put key-value to KVDB.

func GetServiceEntityID Uses

func GetServiceEntityID(serviceName string) common.EntityID

GetServiceEntityID returns the entityid of the service

func ListAttr Uses

func ListAttr() *entity.ListAttr

ListAttr creates a new ListAttr

func ListEntityIDs Uses

func ListEntityIDs(typeName string, callback storage.ListCallbackFunc)

ListEntityIDs gets all saved entity ids in storage, may take long time and block the main routine

returns result in callback

func ListGameIDs Uses

func ListGameIDs() []uint16

ListGameIDs returns all game IDs

func LoadEntityAnywhere Uses

func LoadEntityAnywhere(typeName string, entityID EntityID)

LoadEntityAnywhere loads the specified entity from entity storage

func LoadEntityLocally Uses

func LoadEntityLocally(typeName string, entityID EntityID)

LoadEntityLocally load entity in the local game If the entity already exists on any server, LoadEntityLocally will do nothing

func LoadEntityOnGame Uses

func LoadEntityOnGame(typeName string, entityID EntityID, gameid uint16)

LoadEntityOnGame loads entity in the specified game If the entity already exists on any server, LoadEntityOnGame will do nothing

func MapAttr Uses

func MapAttr() *entity.MapAttr

MapAttr creates a new MapAttr

func Post Uses

func Post(callback post.PostCallback)

Post posts a callback to be executed It is almost same as AddCallback(0, callback)

func PutKVDB Uses

func PutKVDB(key string, val string, callback kvdb.KVDBPutCallback)

PutKVDB puts key-value to KVDB

func RegisterCrontab Uses

func RegisterCrontab(minute, hour, day, month, dayofweek int, cb func())

RegisterCrontab a callack which will be executed when time condition is satisfied

param minute: time condition satisfied on the specified minute, or every -minute if minute is negative param hour: time condition satisfied on the specified hour, or every -hour when hour is negative param day: time condition satisfied on the specified day, or every -day when day is negative param month: time condition satisfied on the specified month, or every -month when month is negative param dayofweek: time condition satisfied on the specified week day, or every -dayofweek when dayofweek is negative param cb: callback function to be executed when time is satisfied

func RegisterEntity Uses

func RegisterEntity(typeName string, entityPtr entity.IEntity) *entity.EntityTypeDesc

RegisterEntity registers the entity type so that entities can be created or loaded

returns the entity type description object which can be used to define more properties of entity type

func RegisterService Uses

func RegisterService(typeName string, entityPtr entity.IEntity)

RegisterService registeres an service type After registeration, the service entity will be created automatically on some game

func RegisterSpace Uses

func RegisterSpace(spacePtr entity.ISpace)

RegisterSpace registers the space entity type.

All spaces will be created as an instance of this type

func Run Uses

func Run()

Run runs the server endless loop

This is the main routine for the server and all entity logic, and this function never quit

type Entity Uses

type Entity = entity.Entity

func CreateEntityLocally Uses

func CreateEntityLocally(typeName string) *Entity

CreateEntityLocally creates a entity on the local server

returns EntityID

func GetEntity Uses

func GetEntity(id EntityID) *Entity

GetEntity gets the entity by EntityID

type EntityID Uses

type EntityID = common.EntityID

func CreateEntityAnywhere Uses

func CreateEntityAnywhere(typeName string) EntityID

CreateEntitySomewhere creates a entity on any server

func CreateEntityOnGame Uses

func CreateEntityOnGame(gameid uint16, typeName string) EntityID

func CreateSpaceAnywhere Uses

func CreateSpaceAnywhere(kind int) EntityID

CreateSpaceAnywhere creates a space with specified kind in any game server

func CreateSpaceOnGame Uses

func CreateSpaceOnGame(gameid uint16, kind int) EntityID

CreateSpaceOnGame creates a space with specified kind on the specified game

returns the space EntityID

func GetNilSpaceID Uses

func GetNilSpaceID(gameid uint16) EntityID

GetNilSpaceID returns the Entity ID of nil space on the specified game

type Space Uses

type Space = entity.Space

func CreateSpaceLocally Uses

func CreateSpaceLocally(kind int) *Space

CreateSpaceLocally creates a space with specified kind in the local game server

returns the space EntityID

func GetNilSpace Uses

func GetNilSpace() *Space

GetNilSpace returns the nil space on this game Nil space is a special space with Kind = 0. Nil space is the default space for all created entities. Each game has one nil space with fixed EntityID for each game, which can be acquired by calling `GetNilSpaceID`

Since nil game exists on each game with fixed EntityID, an entity can migrate to target game by calling `e.EnterSpace(GetNilSpaceID(gameid), Vector3{})`

func GetSpace Uses

func GetSpace(id EntityID) *Space

GetSpace gets the space by ID

type Vector3 Uses

type Vector3 = entity.Vector3

Export useful types

Directories

PathSynopsis
cn
components/dispatcher
components/game
components/game/lbc
components/gate
engine/async
engine/binutil
engine/common
engine/config
engine/consts
engine/crontab
engine/dispatchercluster
engine/dispatchercluster/dispatcherclient
engine/entity
engine/gwioutil
engine/gwlog
engine/gwutils
engine/kvdb
engine/kvdb/backend/kvdb_mongodb
engine/kvdb/backend/kvdbmysql
engine/kvdb/backend/kvdbredis
engine/kvdb/backend/kvdbrediscluster
engine/kvdb/types
engine/lib/gwsnappyPackage snappy implements the snappy block-based compression format.
engine/netutil
engine/netutil/compress
engine/opmon
engine/post
engine/proto
engine/service
engine/srvdis
engine/storage
engine/storage/backend/filesystem
engine/storage/backend/mongodb
engine/storage/backend/mysql
engine/storage/backend/redis
engine/storage/backend/redis_cluster
engine/storage/storage_common
engine/uuid

Package goworld imports 11 packages (graph). Updated 2018-07-14. Refresh now. Tools for package owners.