Documentation ¶
Index ¶
- func Call(id common.EntityID, method string, args []interface{})
- func CallNilSpaces(method string, args []interface{}, gameid uint16)
- func CollectEntitySyncInfos()
- func CreateEntityAnywhere(typeName string) common.EntityID
- func CreateSpaceAnywhere(kind int) common.EntityID
- func GetNilSpaceID(gameid uint16) common.EntityID
- func LoadEntityAnywhere(typeName string, entityID common.EntityID)
- func LoadEntityOnGame(typeName string, entityID common.EntityID, gameid uint16)
- func OnAllGamesConnected()
- func OnCall(id common.EntityID, method string, args [][]byte, clientID common.ClientID)
- func OnCallNilSpaces(method string, args [][]byte)
- func OnClientDisconnected(clientid common.ClientID)
- func OnCreateEntityAnywhere(entityid common.EntityID, typeName string, data map[string]interface{})
- func OnGameTerminating()
- func OnGateDisconnected(gateid uint16)
- func OnLoadEntitySomewhere(typeName string, entityID common.EntityID)
- func OnMigrateRequestAck(entityid common.EntityID, spaceid common.EntityID, spaceGameID uint16)
- func OnQuerySpaceGameIDForMigrateAck(entityid common.EntityID, spaceid common.EntityID, spaceGameID uint16)
- func OnRealMigrate(entityid common.EntityID, data []byte)
- func OnSyncPositionYawFromClient(eid common.EntityID, x, y, z Coord, yaw Yaw)
- func RegisterSpace(spacePtr ISpace)
- func RestoreFreezedEntities(freeze *FreezeData) (err error)
- func SaveAllEntities()
- func SetSaveInterval(duration time.Duration)
- func TraverseEntityByType(etype string, cb func(e *Entity))
- type Coord
- type Entity
- func (e *Entity) AddCallback(d time.Duration, method string, args ...interface{}) EntityTimerID
- func (e *Entity) AddTimer(d time.Duration, method string, args ...interface{}) EntityTimerID
- func (e *Entity) AsSpace() *Space
- func (e *Entity) Call(id common.EntityID, method string, args ...interface{})
- func (e *Entity) CallAllClients(method string, args ...interface{})
- func (e *Entity) CallClient(method string, args ...interface{})
- func (e *Entity) CallFilteredClients(key, op, val string, method string, args ...interface{})
- func (e *Entity) CancelTimer(tid EntityTimerID)
- func (e *Entity) Destroy()
- func (e *Entity) DistanceTo(other *Entity) Coord
- func (e *Entity) EnterSpace(spaceid common.EntityID, pos Vector3)
- func (e *Entity) FaceTo(other *Entity)
- func (e *Entity) FaceToPos(pos Vector3)
- func (e *Entity) ForAllClients(f func(client *GameClient))
- func (e *Entity) GetBool(key string) bool
- func (e *Entity) GetClient() *GameClient
- func (e *Entity) GetFloat(key string) float64
- func (e *Entity) GetInt(key string) int64
- func (e *Entity) GetListAttr(key string) *ListAttr
- func (e *Entity) GetMapAttr(key string) *MapAttr
- func (e *Entity) GetMigrateData(spaceid common.EntityID) *entityMigrateData
- func (e *Entity) GetPosition() Vector3
- func (e *Entity) GetStr(key string) string
- func (e *Entity) GetYaw() Yaw
- func (e *Entity) GiveClientTo(other *Entity)
- func (e *Entity) IsDestroyed() bool
- func (e *Entity) IsNeighbor(other *Entity) bool
- func (e *Entity) IsPersistent() bool
- func (e *Entity) IsSpaceEntity() bool
- func (e *Entity) IsUseAOI() bool
- func (e *Entity) OnAttrsReady()
- func (e *Entity) OnClientConnected()
- func (e *Entity) OnClientDisconnected()
- func (e *Entity) OnCreated()
- func (e *Entity) OnDestroy()
- func (e *Entity) OnEnterAOI(otherAoi *aoi.AOI)
- func (e *Entity) OnEnterSpace()
- func (e *Entity) OnFreeze()
- func (e *Entity) OnInit()
- func (e *Entity) OnLeaveAOI(otherAoi *aoi.AOI)
- func (e *Entity) OnLeaveSpace(space *Space)
- func (e *Entity) OnMigrateIn()
- func (e *Entity) OnMigrateOut()
- func (e *Entity) OnRestored()
- func (e *Entity) PanicOnError(err error)
- func (e *Entity) Post(cb func())
- func (e *Entity) Save()
- func (e *Entity) SetClient(client *GameClient)
- func (e *Entity) SetClientFilterProp(key string, val string)
- func (e *Entity) SetClientSyncing(syncing bool)
- func (e *Entity) SetPosition(pos Vector3)
- func (e *Entity) SetYaw(yaw Yaw)
- func (e *Entity) String() string
- type EntityMap
- type EntitySet
- type EntityTimerID
- type EntityTypeDesc
- type FreezeData
- type GameClient
- type IEntity
- type ISpace
- type ListAttr
- func (a *ListAttr) AppendBool(v bool)
- func (a *ListAttr) AppendFloat(v float64)
- func (a *ListAttr) AppendInt(v int64)
- func (a *ListAttr) AppendListAttr(attr *ListAttr)
- func (a *ListAttr) AppendMapAttr(attr *MapAttr)
- func (a *ListAttr) AppendStr(v string)
- func (a *ListAttr) AssignList(l []interface{})
- func (a *ListAttr) GetBool(index int) bool
- func (a *ListAttr) GetFloat(index int) float64
- func (a *ListAttr) GetInt(index int) int64
- func (a *ListAttr) GetListAttr(index int) *ListAttr
- func (a *ListAttr) GetMapAttr(index int) *MapAttr
- func (a *ListAttr) GetStr(index int) string
- func (a *ListAttr) PopBool() bool
- func (a *ListAttr) PopFloat() float64
- func (a *ListAttr) PopInt() int64
- func (a *ListAttr) PopListAttr() *ListAttr
- func (a *ListAttr) PopMapAttr() *MapAttr
- func (a *ListAttr) PopStr() string
- func (a *ListAttr) SetBool(index int, v bool)
- func (a *ListAttr) SetFloat(index int, v float64)
- func (a *ListAttr) SetInt(index int, v int64)
- func (a *ListAttr) SetListAttr(index int, attr *ListAttr)
- func (a *ListAttr) SetMapAttr(index int, attr *MapAttr)
- func (a *ListAttr) SetStr(index int, v string)
- func (a *ListAttr) Size() int
- func (a *ListAttr) String() string
- func (a *ListAttr) ToList() []interface{}
- type MapAttr
- func (a *MapAttr) AssignMap(doc map[string]interface{})
- func (a *MapAttr) AssignMapWithFilter(doc map[string]interface{}, filter func(string) bool)
- func (a *MapAttr) Clear()
- func (a *MapAttr) Del(key string)
- func (a *MapAttr) ForEach(f func(key string, val interface{}))
- func (a *MapAttr) ForEachKey(f func(key string))
- func (a *MapAttr) GetBool(key string) bool
- func (a *MapAttr) GetFloat(key string) float64
- func (a *MapAttr) GetInt(key string) int64
- func (a *MapAttr) GetListAttr(key string) *ListAttr
- func (a *MapAttr) GetMapAttr(key string) *MapAttr
- func (a *MapAttr) GetStr(key string) string
- func (a *MapAttr) HasKey(key string) bool
- func (a *MapAttr) Keys() []string
- func (a *MapAttr) PopBool(key string) bool
- func (a *MapAttr) PopFloat(key string) float64
- func (a *MapAttr) PopInt(key string) int64
- func (a *MapAttr) PopListAttr(key string) *ListAttr
- func (a *MapAttr) PopMapAttr(key string) *MapAttr
- func (a *MapAttr) PopStr(key string) string
- func (a *MapAttr) SetBool(key string, v bool)
- func (a *MapAttr) SetDefaultBool(key string, v bool)
- func (a *MapAttr) SetDefaultFloat(key string, v float64)
- func (a *MapAttr) SetDefaultInt(key string, v int64)
- func (a *MapAttr) SetDefaultListAttr(key string, attr *ListAttr)
- func (a *MapAttr) SetDefaultMapAttr(key string, attr *MapAttr)
- func (a *MapAttr) SetDefaultStr(key string, v string)
- func (a *MapAttr) SetFloat(key string, v float64)
- func (a *MapAttr) SetInt(key string, v int64)
- func (a *MapAttr) SetListAttr(key string, attr *ListAttr)
- func (a *MapAttr) SetMapAttr(key string, attr *MapAttr)
- func (a *MapAttr) SetStr(key string, v string)
- func (a *MapAttr) Size() int
- func (a *MapAttr) String() string
- func (a *MapAttr) ToMap() map[string]interface{}
- func (a *MapAttr) ToMapWithFilter(filter func(string) bool) map[string]interface{}
- type Space
- func (space *Space) CountEntities(typeName string) int
- func (space *Space) CreateEntity(typeName string, pos Vector3)
- func (space *Space) DescribeEntityType(desc *EntityTypeDesc)
- func (space *Space) EnableAOI()
- func (space *Space) ForEachEntity(f func(e *Entity))
- func (space *Space) GetEntity(entityID common.EntityID) *Entity
- func (space *Space) GetEntityCount() int
- func (space *Space) GetSpaceRange() (minX, minY, maxX, maxY Coord)
- func (space *Space) GetTowerRange() (minX, minY, maxX, maxY Coord)
- func (space *Space) IsNil() bool
- func (space *Space) LoadEntity(typeName string, entityID common.EntityID, pos Vector3)
- func (space *Space) OnCreated()
- func (space *Space) OnDestroy()
- func (space *Space) OnEntityEnterSpace(entity *Entity)
- func (space *Space) OnEntityLeaveSpace(entity *Entity)
- func (space *Space) OnGameReady()
- func (space *Space) OnInit()
- func (space *Space) OnRestored()
- func (space *Space) OnSpaceCreated()
- func (space *Space) OnSpaceDestroy()
- func (space *Space) OnSpaceInit()
- func (space *Space) String() string
- type Vector3
- type Yaw
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallNilSpaces ¶ added in v0.1.3
func CollectEntitySyncInfos ¶
func CollectEntitySyncInfos()
CollectEntitySyncInfos is called by game service to collect and broadcast entity sync infos to all clients
func CreateEntityAnywhere ¶
CreateEntityAnywhere creates new entity in any game
func CreateSpaceAnywhere ¶
CreateSpaceAnywhere creates a space in any game server
func GetNilSpaceID ¶ added in v0.1.4
GetNilSpaceEntityID returns the EntityID for Nil Space on the specified game GoWorld uses fixed EntityID for nil spaces on each game
func LoadEntityAnywhere ¶
LoadEntityAnywhere loads entity in the any game
LoadEntityAnywhere has no effect if entity already exists on any game
func LoadEntityOnGame ¶ added in v0.1.4
LoadEntityOnGame
func OnAllGamesConnected ¶ added in v0.1.3
func OnAllGamesConnected()
OnAllGamesConnected is called when all games are connected to dispatcher cluster
func OnCallNilSpaces ¶ added in v0.1.3
func OnClientDisconnected ¶
OnClientDisconnected is called by engine when Client is disconnected
func OnCreateEntityAnywhere ¶ added in v0.1.2
OnCreateEntityAnywhere is called when CreateEntityAnywhere chooses this game
func OnGameTerminating ¶
func OnGameTerminating()
OnGameTerminating is called when game is terminating
func OnGateDisconnected ¶
func OnGateDisconnected(gateid uint16)
OnGateDisconnected is called when gate is down
func OnLoadEntitySomewhere ¶ added in v0.1.4
OnLoadEntitySomewhere loads entity in the local game.
func OnMigrateRequestAck ¶
OnMigrateRequestAck is called by engine when mgirate request Ack is received
func OnQuerySpaceGameIDForMigrateAck ¶ added in v0.1.2
func OnQuerySpaceGameIDForMigrateAck(entityid common.EntityID, spaceid common.EntityID, spaceGameID uint16)
OnQuerySpaceGameIDForMigrateAck is called by engine when query entity gameid ACK is received
func OnRealMigrate ¶
OnRealMigrate is used by entity migration
func OnSyncPositionYawFromClient ¶
OnSyncPositionYawFromClient is called by engine to sync entity infos from Client
func RegisterSpace ¶
func RegisterSpace(spacePtr ISpace)
RegisterSpace registers the user custom space type
func RestoreFreezedEntities ¶
func RestoreFreezedEntities(freeze *FreezeData) (err error)
RestoreFreezedEntities restore entity system from freeze data
func SetSaveInterval ¶
SetSaveInterval sets the save interval for entity system
func TraverseEntityByType ¶ added in v0.1.4
TraverseEntityByType traverses entities of the specified type
Types ¶
type Entity ¶
type Entity struct { ID common.EntityID TypeName string I IEntity V reflect.Value Space *Space Position Vector3 Neighbors EntitySet Attrs *MapAttr // contains filtered or unexported fields }
Entity is the basic execution unit in GoWorld server. Entities can be used to represent players, NPCs, monsters. Entities can migrate among spaces.
func CreateEntityLocally ¶
CreateEntityLocally creates new entity in the local game
func (*Entity) AddCallback ¶
func (e *Entity) AddCallback(d time.Duration, method string, args ...interface{}) EntityTimerID
AddCallback adds a one-time callback for the entity
The callback will be cancelled if entity is destroyed
func (*Entity) AddTimer ¶
func (e *Entity) AddTimer(d time.Duration, method string, args ...interface{}) EntityTimerID
AddTimer adds a repeat timer for the entity
The callback will be cancelled if entity is destroyed
func (*Entity) AsSpace ¶ added in v0.1.4
AsSpace converts entity to space (only works for space entity)
func (*Entity) CallAllClients ¶
CallAllClients calls the entity method on all clients
func (*Entity) CallClient ¶
CallClient calls the Client entity
func (*Entity) CallFilteredClients ¶ added in v0.1.3
CallFilteredClients calls the filtered clients with prop key == value supported op includes "=", "!=", "<", "<=", ">", ">=" if key = "", all clients are called despite the value of op and val
The message is broadcast to filtered clientproxies directly without going through entities, and therefore more efficient
func (*Entity) CancelTimer ¶
func (e *Entity) CancelTimer(tid EntityTimerID)
CancelTimer cancels the Callback / Timer
func (*Entity) DistanceTo ¶
DistanceTo calculates the distance between two entities
func (*Entity) EnterSpace ¶
EnterSpace let the entity enters space
func (*Entity) ForAllClients ¶
func (e *Entity) ForAllClients(f func(client *GameClient))
ForAllClients visits all clients (own Client and clients of neighbors)
func (*Entity) GetClient ¶
func (e *Entity) GetClient() *GameClient
GetClient returns the Client of entity
func (*Entity) GetListAttr ¶
GetListAttr gets an outtermost attribute as ListAttr
func (*Entity) GetMapAttr ¶
GetMapAttr gets an outtermost attribute as MapAttr
func (*Entity) GetMigrateData ¶
GetMigrateData gets the migration data
func (*Entity) GetPosition ¶
GetPosition returns the entity position
func (*Entity) GiveClientTo ¶
GiveClientTo gives Client to other entity
func (*Entity) IsDestroyed ¶
IsDestroyed returns if the entity is destroyed
func (*Entity) IsNeighbor ¶
IsNeighbor checks if other entity is a neighbor
func (*Entity) IsPersistent ¶
IsPersistent returns if the entity is persistent
Default implementation check entity for persistent attributes
func (*Entity) IsSpaceEntity ¶
IsSpaceEntity returns if the entity is actually a space
func (*Entity) IsUseAOI ¶
IsUseAOI returns if entity type is using aoi
Entities like Account, Service entities should not be using aoi
func (*Entity) OnAttrsReady ¶ added in v0.1.3
func (e *Entity) OnAttrsReady()
OnAttrsReady is called when entity's attribute is ready
Can override this function in custom entity type
func (*Entity) OnClientConnected ¶
func (e *Entity) OnClientConnected()
OnClientConnected is called when Client is connected
Can override this function in custom entity type
func (*Entity) OnClientDisconnected ¶
func (e *Entity) OnClientDisconnected()
OnClientDisconnected is called when Client is disconnected
Can override this function in custom entity type
func (*Entity) OnCreated ¶
func (e *Entity) OnCreated()
OnCreated is called when entity is created
Can override this function in custom entity type
func (*Entity) OnDestroy ¶
func (e *Entity) OnDestroy()
OnDestroy is called when entity is destroying
Can override this function in custom entity type
func (*Entity) OnEnterAOI ¶ added in v0.1.1
func (e *Entity) OnEnterAOI(otherAoi *aoi.AOI)
func (*Entity) OnEnterSpace ¶
func (e *Entity) OnEnterSpace()
OnEnterSpace is called when entity enters space
Can override this function in custom entity type
func (*Entity) OnFreeze ¶
func (e *Entity) OnFreeze()
OnFreeze is called when entity is freezed
Can override this function in custom entity type
func (*Entity) OnInit ¶
func (e *Entity) OnInit()
OnInit is called when entity is initializing
Can override this function in custom entity type
func (*Entity) OnLeaveAOI ¶ added in v0.1.1
func (e *Entity) OnLeaveAOI(otherAoi *aoi.AOI)
func (*Entity) OnLeaveSpace ¶
OnLeaveSpace is called when entity leaves space
Can override this function in custom entity type
func (*Entity) OnMigrateIn ¶
func (e *Entity) OnMigrateIn()
OnMigrateIn is called when entity is migrating in
Can override this function in custom entity type
func (*Entity) OnMigrateOut ¶
func (e *Entity) OnMigrateOut()
OnMigrateOut is called when entity is migrating out
Can override this function in custom entity type
func (*Entity) OnRestored ¶
func (e *Entity) OnRestored()
OnRestored is called when entity is restored
Can override this function in custom entity type
func (*Entity) PanicOnError ¶
PanicOnError panics if err != nil
func (*Entity) Post ¶
func (e *Entity) Post(cb func())
Post a function which will be executed immediately but not in the current stack frames
func (*Entity) SetClient ¶
func (e *Entity) SetClient(client *GameClient)
SetClient sets the Client of entity
func (*Entity) SetClientFilterProp ¶ added in v0.1.4
SetClientFilterProp sets a filter property key-value
func (*Entity) SetClientSyncing ¶
SetClientSyncing set if entity infos (position, Yaw) is syncing with Client
func (*Entity) SetPosition ¶
SetPosition sets the entity position
type EntityMap ¶
EntityMap is the data structure for maintaining entity IDs to entities
func Entities ¶
func Entities() EntityMap
Entities gets all entities
Never modify the return value !
func GetEntitiesByType ¶ added in v0.1.4
type EntitySet ¶
type EntitySet map[*Entity]struct{}
EntitySet is the data structure for a set of entities
type EntityTimerID ¶
type EntityTimerID int
EntityTimerID is the type of entity timer ID
func (EntityTimerID) IsValid ¶
func (tid EntityTimerID) IsValid() bool
IsValid returns if the EntityTimerID is still valid (not fired and not cancelled)
type EntityTypeDesc ¶
type EntityTypeDesc struct { IsPersistent bool // contains filtered or unexported fields }
EntityTypeDesc is the entity type description for registering entity types
func GetEntityTypeDesc ¶ added in v0.1.4
func GetEntityTypeDesc(typeName string) *EntityTypeDesc
func RegisterEntity ¶
func RegisterEntity(typeName string, entity IEntity, isService bool) *EntityTypeDesc
RegisterEntity registers custom entity type and define entity behaviors
func (*EntityTypeDesc) DefineAttr ¶ added in v0.1.1
func (desc *EntityTypeDesc) DefineAttr(attr string, defs ...string) *EntityTypeDesc
func (*EntityTypeDesc) SetPersistent ¶ added in v0.1.3
func (desc *EntityTypeDesc) SetPersistent(persistent bool) *EntityTypeDesc
func (*EntityTypeDesc) SetUseAOI ¶ added in v0.1.3
func (desc *EntityTypeDesc) SetUseAOI(useAOI bool) *EntityTypeDesc
type FreezeData ¶
FreezeData is the data structure for storing entity freeze data
func Freeze ¶
func Freeze(gameid uint16) (*FreezeData, error)
Freeze freezes the entity system and returns all freeze data
type GameClient ¶
type GameClient struct {
// contains filtered or unexported fields
}
GameClient represents the game Client of entity
Each entity can have at most one GameClient, and GameClient can be given to other entities
func MakeGameClient ¶
func MakeGameClient(clientid common.ClientID, gateid uint16) *GameClient
MakeGameClient creates a GameClient object using Client ID and Game ID
func (*GameClient) String ¶
func (client *GameClient) String() string
type IEntity ¶ added in v0.1.1
type IEntity interface { // Entity Lifetime OnInit() // Called when initializing entity struct, override to initialize entity custom fields OnAttrsReady() // Called when entity attributes are ready. OnCreated() // Called when entity is just created OnDestroy() // Called when entity is destroying (just before destroy) // Migration OnMigrateOut() // Called just before entity is migrating out OnMigrateIn() // Called just after entity is migrating in // Freeze && Restore OnFreeze() // Called when entity is freezing OnRestored() // Called when entity is restored // Space Operations OnEnterSpace() // Called when entity leaves space OnLeaveSpace(space *Space) // Called when entity enters space // Client Notifications OnClientConnected() // Called when Client is connected to entity (become player) OnClientDisconnected() // Called when Client disconnected DescribeEntityType(desc *EntityTypeDesc) // Define entity attributes in this function }
IEntity declares functions that is defined in Entity These functions are mostly component functions
type ISpace ¶ added in v0.1.1
type ISpace interface { IEntity OnSpaceInit() // Called when initializing space struct, override to initialize custom space fields OnSpaceCreated() // Called when space is created OnSpaceDestroy() // Called just before space is destroyed // Space Operations OnEntityEnterSpace(entity *Entity) // Called when any entity enters space OnEntityLeaveSpace(entity *Entity) // Called when any entity leaves space // Game releated callbacks on nil space only OnGameReady() }
ISpace is the space delegate interface
User custom space class can override these functions for their own game logic
type ListAttr ¶
type ListAttr struct {
// contains filtered or unexported fields
}
ListAttr is a attribute for a list of attributes
func (*ListAttr) AppendBool ¶
AppendBool puts bool value to the end of list
func (*ListAttr) AppendFloat ¶
AppendFloat puts float value to the end of list
func (*ListAttr) AppendListAttr ¶
AppendListAttr puts ListAttr value to the end of list
func (*ListAttr) AppendMapAttr ¶
AppendMapAttr puts MapAttr value to the end of list
func (*ListAttr) AssignList ¶
func (a *ListAttr) AssignList(l []interface{})
AssignList assigns slice to ListAttr, recursively
func (*ListAttr) GetListAttr ¶
GetListAttr gets item value as ListAttr
func (*ListAttr) GetMapAttr ¶
GetMapAttr gets item value as MapAttr
func (*ListAttr) PopListAttr ¶
PopListAttr removes the last item and returns as ListAttr
func (*ListAttr) PopMapAttr ¶
PopMapAttr removes the last item and returns as MapAttr
func (*ListAttr) SetListAttr ¶
SetListAttr sets ListAttr value at the index
func (*ListAttr) SetMapAttr ¶
SetMapAttr sets MapAttr value at the index
type MapAttr ¶
type MapAttr struct {
// contains filtered or unexported fields
}
MapAttr is a map attribute containing muiltiple attributes indexed by string keys
func (*MapAttr) AssignMapWithFilter ¶
AssignMapWithFilter assigns filtered fields of native map to MapAttr recursively
func (*MapAttr) Clear ¶ added in v0.1.4
func (a *MapAttr) Clear()
Clear removes all key-values from the MapAttr
func (*MapAttr) ForEachKey ¶
ForEachKey calls f on all keys
func (*MapAttr) GetListAttr ¶
GetListAttr returns the attribute of specified key in MapAttr as ListAttr
func (*MapAttr) GetMapAttr ¶
GetMapAttr returns the attribute of specified key in MapAttr as MapAttr
func (*MapAttr) PopBool ¶ added in v0.1.4
PopBool deletes a key in MapAttr and returns the attribute as bool
func (*MapAttr) PopFloat ¶ added in v0.1.4
PopFloat deletes a key in MapAttr and returns the attribute as float64
func (*MapAttr) PopInt ¶ added in v0.1.4
PopInt deletes a key in MapAttr and returns the attribute as int64
func (*MapAttr) PopListAttr ¶ added in v0.1.4
PopListAttr deletes a key in MapAttr and returns the attribute as MapAttr
func (*MapAttr) PopMapAttr ¶
PopMapAttr deletes a key in MapAttr and returns the attribute as MapAttr
func (*MapAttr) PopStr ¶ added in v0.1.4
PopStr deletes a key in MapAttr and returns the attribute as str
func (*MapAttr) SetDefaultBool ¶
SetDefaultBool sets default bool value at the key
func (*MapAttr) SetDefaultFloat ¶
SetDefaultFloat sets default float value at the key
func (*MapAttr) SetDefaultInt ¶
SetDefaultInt sets default int value at the key
func (*MapAttr) SetDefaultListAttr ¶
SetDefaultListAttr sets default ListAttr value at the key
func (*MapAttr) SetDefaultMapAttr ¶
SetDefaultMapAttr sets default MapAttr value at the key
func (*MapAttr) SetDefaultStr ¶
SetDefaultStr sets default string value at the key
func (*MapAttr) SetListAttr ¶
SetListAttr sets ListAttr value at the key
func (*MapAttr) SetMapAttr ¶
SetMapAttr sets MapAttr value at the key
type Space ¶
Space is the entity type of spaces
Spaces are also entities but with space management logics
func CreateNilSpace ¶ added in v0.1.3
CreateNilSpace creates the nil space
func CreateSpaceLocally ¶
CreateSpaceLocally creates a space in the local game server
func GetNilSpace ¶ added in v0.1.4
func GetNilSpace() *Space
func (*Space) CountEntities ¶
CountEntities returns the number of entities of specified type in space
func (*Space) CreateEntity ¶
CreateEntity creates a new local entity in this space
func (*Space) DescribeEntityType ¶ added in v0.1.3
func (space *Space) DescribeEntityType(desc *EntityTypeDesc)
func (*Space) ForEachEntity ¶
ForEachEntity visits all entities in space and call function f with each entity
func (*Space) GetEntityCount ¶
GetEntityCount returns the total count of entities in space
func (*Space) GetSpaceRange ¶ added in v0.1.1
func (*Space) GetTowerRange ¶ added in v0.1.1
func (*Space) LoadEntity ¶
LoadEntity loads a entity of specified entityID to the space
If the entity already exists on server, this call has no effect
func (*Space) OnCreated ¶
func (space *Space) OnCreated()
OnCreated is called when Space entity is created
func (*Space) OnDestroy ¶
func (space *Space) OnDestroy()
OnDestroy is called when Space entity is destroyed
func (*Space) OnEntityEnterSpace ¶
OnEntityEnterSpace is called when entity enters space
Custom space type can override this function
func (*Space) OnEntityLeaveSpace ¶
OnEntityLeaveSpace is called when entity leaves space
Custom space type can override this function
func (*Space) OnGameReady ¶ added in v0.1.3
func (space *Space) OnGameReady()
OnGameReady is called when the game server is ready on NilSpace only
func (*Space) OnRestored ¶
func (space *Space) OnRestored()
OnRestored is called when space entity is restored
func (*Space) OnSpaceCreated ¶
func (space *Space) OnSpaceCreated()
OnSpaceCreated is called when space is created
Custom space type can override to provide custom logic
func (*Space) OnSpaceDestroy ¶
func (space *Space) OnSpaceDestroy()
OnSpaceDestroy is called when space is destroying
Custom space type can override to provide custom logic
func (*Space) OnSpaceInit ¶ added in v0.1.1
func (space *Space) OnSpaceInit()
OnSpaceInit is a compositive method for initializing space fields
type Vector3 ¶
Vector3 is type of entity position
func (Vector3) DistanceTo ¶
DistanceTo calculates distance between two positions