goworld: github.com/xiaonanln/goworld/engine/entity Index | Files

package entity

import "github.com/xiaonanln/goworld/engine/entity"

Index

Package Files

AOI.go AOICalculator.go Entity.go EntityManager.go GameClient.go ISpace.go ListAttr.go MapAttr.go Space.go SpaceManager.go attr.go component.go entity_map.go rpc_desc.go space_ops.go xAOIList.go zAOIList.go

func CollectEntitySyncInfos Uses

func CollectEntitySyncInfos()

CollectEntitySyncInfos is called by game service to collect and broadcast entity sync infos to all clients

func CreateEntityAnywhere Uses

func CreateEntityAnywhere(typeName string)

CreateEntityAnywhere creates new entity in any game

func CreateEntityLocally Uses

func CreateEntityLocally(typeName string, data map[string]interface{}, client *GameClient) common.EntityID

CreateEntityLocally creates new entity in the local game

func CreateSpaceAnywhere Uses

func CreateSpaceAnywhere(kind int)

CreateSpaceAnywhere creates a space in any game server

func CreateSpaceLocally Uses

func CreateSpaceLocally(kind int) common.EntityID

CreateSpaceLocally creates a space in the local game server

func LoadEntityAnywhere Uses

func LoadEntityAnywhere(typeName string, entityID common.EntityID)

LoadEntityAnywhere loads entity in the any game

LoadEntityAnywhere has no effect if entity already exists on any game

func LoadEntityLocally Uses

func LoadEntityLocally(typeName string, entityID common.EntityID)

LoadEntityLocally loads entity in the local game.

LoadEntityLocally has no effect if entity already exists on any game

func OnCall Uses

func OnCall(id common.EntityID, method string, args [][]byte, clientID common.ClientID)

OnCall is called by engine when method call reaches in the game

func OnClientDisconnected Uses

func OnClientDisconnected(clientid common.ClientID)

OnClientDisconnected is called by engine when client is disconnected

func OnDeclareService Uses

func OnDeclareService(serviceName string, entityid common.EntityID)

OnDeclareService is called by engine when service is declared

func OnGameTerminating Uses

func OnGameTerminating()

OnGameTerminating is called when game is terminating

func OnGateDisconnected Uses

func OnGateDisconnected(gateid uint16)

OnGateDisconnected is called when gate is down

func OnMigrateRequestAck Uses

func OnMigrateRequestAck(entityID common.EntityID, spaceID common.EntityID, spaceLoc uint16)

OnMigrateRequestAck is called by engine when mgirate request Ack is received

func OnRealMigrate Uses

func OnRealMigrate(entityID common.EntityID, spaceID common.EntityID, x, y, z float32, typeName string,
    migrateData map[string]interface{}, timerData []byte,
    clientid common.ClientID, clientsrv uint16)

OnRealMigrate is used by entity migration

func OnSyncPositionYawFromClient Uses

func OnSyncPositionYawFromClient(eid common.EntityID, x, y, z Coord, yaw Yaw)

OnSyncPositionYawFromClient is called by engine to sync entity infos from client

func OnUndeclareService Uses

func OnUndeclareService(serviceName string, entityid common.EntityID)

OnUndeclareService is called by engine when service is undeclared

func RegisterEntity Uses

func RegisterEntity(typeName string, entity IEntity, isPersistent bool, useAOI bool)

RegisterEntity registers custom entity type and define entity behaviors

func RegisterSpace Uses

func RegisterSpace(spacePtr IEntity)

RegisterSpace registers the user custom space type

func RestoreFreezedEntities Uses

func RestoreFreezedEntities(freeze *FreezeData) (err error)

RestoreFreezedEntities restore entity system from freeze data

func SaveAllEntities Uses

func SaveAllEntities()

SaveAllEntities saves all entities

func SetSaveInterval Uses

func SetSaveInterval(duration time.Duration)

SetSaveInterval sets the save interval for entity system

type AOICalculator Uses

type AOICalculator interface {
    // Let Entity aoi enter at specified position
    Enter(aoi *aoi, pos Vector3)
    // Let Entity aoi leave
    Leave(aoi *aoi)
    // Let Entity aoi move
    Move(aoi *aoi, newPos Vector3)
    // Calculate EntityAOI Adjustment of neighbors
    Adjust(aoi *aoi) (enter []*aoi, leave []*aoi)
}

AOICalculator defines interface for aoi Calculators

type Component Uses

type Component struct {
    *Entity
}

type Coord Uses

type Coord float32

Coord is the of coordinations entity position (x, y, z)

type Entity Uses

type Entity struct {
    ID       common.EntityID
    TypeName string
    I        IEntity
    V        reflect.Value

    Space *Space

    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 GetEntity Uses

func GetEntity(id common.EntityID) *Entity

GetEntity returns the entity with specified ID

func (*Entity) AddCallback Uses

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 Uses

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) Call Uses

func (e *Entity) Call(id common.EntityID, method string, args ...interface{})

Call other entities

func (*Entity) CallAllClients Uses

func (e *Entity) CallAllClients(method string, args ...interface{})

CallAllClients calls the entity method on all clients

func (*Entity) CallClient Uses

func (e *Entity) CallClient(method string, args ...interface{})

CallClient calls the client entity

func (*Entity) CallFitleredClients Uses

func (e *Entity) CallFitleredClients(key string, val string, method string, args ...interface{})

CallFitleredClients calls the filtered clients with prop key == value

The message is broadcast to filtered clientproxies directly without going through entities

func (*Entity) CallService Uses

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

CallService calls a service provider

func (*Entity) CancelTimer Uses

func (e *Entity) CancelTimer(tid EntityTimerID)

CancelTimer cancels the Callback / Timer

func (*Entity) DeclareService Uses

func (e *Entity) DeclareService(serviceName string)

DeclareService declares global service for service entity

func (*Entity) Destroy Uses

func (e *Entity) Destroy()

Destroy destroys the entity

func (*Entity) DistanceTo Uses

func (e *Entity) DistanceTo(other *Entity) Coord

DistanceTo calculates the distance between two entities

func (*Entity) EnterSpace Uses

func (e *Entity) EnterSpace(spaceID common.EntityID, pos Vector3)

EnterSpace let the entity enters space

func (*Entity) FaceTo Uses

func (e *Entity) FaceTo(other *Entity)

FaceTo let entity face to another entity by setting yaw accordingly

func (*Entity) FaceToPos Uses

func (e *Entity) FaceToPos(pos Vector3)

func (*Entity) ForAllClients Uses

func (e *Entity) ForAllClients(f func(client *GameClient))

ForAllClients visits all clients (own client and clients of neighbors)

func (*Entity) GetClient Uses

func (e *Entity) GetClient() *GameClient

GetClient returns the client of entity

func (*Entity) GetFloat Uses

func (e *Entity) GetFloat(key string) float64

GetFloat gets an outtermost attribute as float64

func (*Entity) GetFreezeData Uses

func (e *Entity) GetFreezeData() *entityFreezeData

GetFreezeData gets freezed data

func (*Entity) GetInt Uses

func (e *Entity) GetInt(key string) int64

GetInt gets an outtermost attribute as int

func (*Entity) GetListAttr Uses

func (e *Entity) GetListAttr(key string) *ListAttr

GetListAttr gets an outtermost attribute as ListAttr

func (*Entity) GetMapAttr Uses

func (e *Entity) GetMapAttr(key string) *MapAttr

GetMapAttr gets an outtermost attribute as MapAttr

func (*Entity) GetMigrateData Uses

func (e *Entity) GetMigrateData() map[string]interface{}

GetMigrateData gets the migration data

func (*Entity) GetPosition Uses

func (e *Entity) GetPosition() Vector3

GetPosition returns the entity position

func (*Entity) GetStr Uses

func (e *Entity) GetStr(key string) string

GetStr gets an outtermost attribute as string

func (*Entity) GetYaw Uses

func (e *Entity) GetYaw() Yaw

GetYaw gets entity yaw

func (*Entity) GiveClientTo Uses

func (e *Entity) GiveClientTo(other *Entity)

GiveClientTo gives client to other entity

func (*Entity) IsDestroyed Uses

func (e *Entity) IsDestroyed() bool

IsDestroyed returns if the entity is destroyed

func (*Entity) IsNeighbor Uses

func (e *Entity) IsNeighbor(other *Entity) bool

func (*Entity) IsPersistent Uses

func (e *Entity) IsPersistent() bool

IsPersistent returns if the entity is persistent

Default implementation check entity for persistent attributes

func (*Entity) IsSpaceEntity Uses

func (e *Entity) IsSpaceEntity() bool

IsSpaceEntity returns if the entity is actually a space

func (*Entity) IsUseAOI Uses

func (e *Entity) IsUseAOI() bool

IsUseAOI returns if entity type is using aoi

Entities like Account, Service entities should not be using aoi

func (*Entity) LoadMigrateData Uses

func (e *Entity) LoadMigrateData(data map[string]interface{})

LoadMigrateData loads migrate data

func (*Entity) Neighbors Uses

func (e *Entity) Neighbors() EntitySet

Neighbors get all neighbors in an EntitySet

Never modify the return value !

func (*Entity) OnClientConnected Uses

func (e *Entity) OnClientConnected()

OnClientConnected is called when client is connected

Can override this function in custom entity type

func (*Entity) OnClientDisconnected Uses

func (e *Entity) OnClientDisconnected()

OnClientDisconnected is called when client is disconnected

Can override this function in custom entity type

func (*Entity) OnCreated Uses

func (e *Entity) OnCreated()

OnCreated is called when entity is created

Can override this function in custom entity type

func (*Entity) OnDestroy Uses

func (e *Entity) OnDestroy()

OnDestroy is called when entity is destroying

Can override this function in custom entity type

func (*Entity) OnEnterSpace Uses

func (e *Entity) OnEnterSpace()

OnEnterSpace is called when entity enters space

Can override this function in custom entity type

func (*Entity) OnFreeze Uses

func (e *Entity) OnFreeze()

OnFreeze is called when entity is freezed

Can override this function in custom entity type

func (*Entity) OnInit Uses

func (e *Entity) OnInit()

OnInit is called when entity is initializing

Can override this function in custom entity type

func (*Entity) OnLeaveSpace Uses

func (e *Entity) OnLeaveSpace(space *Space)

OnLeaveSpace is called when entity leaves space

Can override this function in custom entity type

func (*Entity) OnMigrateIn Uses

func (e *Entity) OnMigrateIn()

OnMigrateIn is called when entity is migrating in

Can override this function in custom entity type

func (*Entity) OnMigrateOut Uses

func (e *Entity) OnMigrateOut()

OnMigrateOut is called when entity is migrating out

Can override this function in custom entity type

func (*Entity) OnRestored Uses

func (e *Entity) OnRestored()

OnRestored is called when entity is restored

Can override this function in custom entity type

func (*Entity) PanicOnError Uses

func (e *Entity) PanicOnError(err error)

PanicOnError panics if err != nil

func (*Entity) Post Uses

func (e *Entity) Post(cb func())

Post a function which will be executed immediately but not in the current stack frames

func (*Entity) Save Uses

func (e *Entity) Save()

Save the entity

func (*Entity) SetClient Uses

func (e *Entity) SetClient(client *GameClient)

SetClient sets the client of entity

func (*Entity) SetClientSyncing Uses

func (e *Entity) SetClientSyncing(syncing bool)

SetClientSyncing set if entity infos (position, yaw) is syncing with client

func (*Entity) SetFilterProp Uses

func (e *Entity) SetFilterProp(key string, val string)

SetFilterProp sets a filter property key-value

func (*Entity) SetPosition Uses

func (e *Entity) SetPosition(pos Vector3)

SetPosition sets the entity position

func (*Entity) SetYaw Uses

func (e *Entity) SetYaw(yaw Yaw)

SetYaw sets entity yaw

func (*Entity) String Uses

func (e *Entity) String() string

func (*Entity) ToSpace Uses

func (e *Entity) ToSpace() *Space

ToSpace converts entity to space (only works for space entity)

type EntityIDSet Uses

type EntityIDSet map[common.EntityID]struct{}

EntityIDSet is the data structure for a set of entity IDs

func GetServiceProviders Uses

func GetServiceProviders(serviceName string) EntityIDSet

GetServiceProviders returns all service providers

func (EntityIDSet) Add Uses

func (es EntityIDSet) Add(id common.EntityID)

Add adds an entity ID to EntityIDSet

func (EntityIDSet) Contains Uses

func (es EntityIDSet) Contains(id common.EntityID) bool

Contains checks if entity ID is in EntityIDSet

func (EntityIDSet) Del Uses

func (es EntityIDSet) Del(id common.EntityID)

Del removes an entity ID from EntityIDSet

func (EntityIDSet) ToList Uses

func (es EntityIDSet) ToList() []common.EntityID

ToList convert EntityIDSet to a slice of entity IDs

type EntityMap Uses

type EntityMap map[common.EntityID]*Entity

EntityMap is the data structure for maintaining entity IDs to entities

func Entities Uses

func Entities() EntityMap

Entities gets all entities

Never modify the return value !

func (EntityMap) Add Uses

func (em EntityMap) Add(entity *Entity)

Add adds a new entity to EntityMap

func (EntityMap) Del Uses

func (em EntityMap) Del(id common.EntityID)

Del deletes an entity from EntityMap

func (EntityMap) Get Uses

func (em EntityMap) Get(id common.EntityID) *Entity

Get returns the Entity of specified entity ID in EntityMap

type EntitySet Uses

type EntitySet map[*Entity]struct{}

EntitySet is the data structure for a set of entities

func (EntitySet) Add Uses

func (es EntitySet) Add(entity *Entity)

Add adds an entity to the EntitySet

func (EntitySet) Contains Uses

func (es EntitySet) Contains(entity *Entity) bool

Contains returns if the entity is in the EntitySet

func (EntitySet) Del Uses

func (es EntitySet) Del(entity *Entity)

Del deletes an entity from the EntitySet

func (EntitySet) String Uses

func (es EntitySet) String() string

type EntityTimerID Uses

type EntityTimerID int

EntityTimerID is the type of entity timer ID

func (EntityTimerID) IsValid Uses

func (tid EntityTimerID) IsValid() bool

IsValid returns if the EntityTimerID is still valid (not fired and not cancelled)

type EntityTypeDesc Uses

type EntityTypeDesc struct {
    // contains filtered or unexported fields
}

EntityTypeDesc is the entity type description for registering entity types

func (*EntityTypeDesc) DefineAttr Uses

func (desc *EntityTypeDesc) DefineAttr(attr string, defs ...string)

type FreezeData Uses

type FreezeData struct {
    Entities map[common.EntityID]*entityFreezeData
    Services map[string][]common.EntityID
}

FreezeData is the data structure for storing entity freeze data

func Freeze Uses

func Freeze(gameid uint16) (*FreezeData, error)

Freeze freezes the entity system and returns all freeze data

type GameClient Uses

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 Uses

func MakeGameClient(clientid common.ClientID, gid uint16) *GameClient

MakeGameClient creates a GameClient object using Client ID and Game ID

func (*GameClient) String Uses

func (client *GameClient) String() string

type IEntity Uses

type IEntity interface {
    // Entity Lifetime
    OnInit()    // Called when initializing entity struct, override to initialize entity custom fields
    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

    DefineAttrs(desc *EntityTypeDesc)
}

IEntity declares functions that is defined in Entity These functions are mostly component functions

type ListAttr Uses

type ListAttr struct {
    // contains filtered or unexported fields
}

ListAttr is a attribute for a list of attributes

func NewListAttr Uses

func NewListAttr() *ListAttr

NewListAttr creates a new ListAttr

func (*ListAttr) AppendBool Uses

func (a *ListAttr) AppendBool(v bool)

AppendBool puts bool value to the end of list

func (*ListAttr) AppendFloat Uses

func (a *ListAttr) AppendFloat(v float64)

AppendFloat puts float value to the end of list

func (*ListAttr) AppendInt Uses

func (a *ListAttr) AppendInt(v int64)

AppendInt puts int value to the end of list

func (*ListAttr) AppendListAttr Uses

func (a *ListAttr) AppendListAttr(attr *ListAttr)

AppendListAttr puts ListAttr value to the end of list

func (*ListAttr) AppendMapAttr Uses

func (a *ListAttr) AppendMapAttr(attr *MapAttr)

AppendMapAttr puts MapAttr value to the end of list

func (*ListAttr) AppendStr Uses

func (a *ListAttr) AppendStr(v string)

AppendStr puts string value to the end of list

func (*ListAttr) AssignList Uses

func (a *ListAttr) AssignList(l []interface{})

AssignList assigns slice to ListAttr, recursively

func (*ListAttr) GetBool Uses

func (a *ListAttr) GetBool(index int) bool

GetBool gets item value as bool

func (*ListAttr) GetFloat Uses

func (a *ListAttr) GetFloat(index int) float64

GetFloat gets item value as float64

func (*ListAttr) GetInt Uses

func (a *ListAttr) GetInt(index int) int64

GetInt gets item value as int

func (*ListAttr) GetListAttr Uses

func (a *ListAttr) GetListAttr(index int) *ListAttr

GetListAttr gets item value as ListAttr

func (*ListAttr) GetMapAttr Uses

func (a *ListAttr) GetMapAttr(index int) *MapAttr

GetMapAttr gets item value as MapAttr

func (*ListAttr) GetStr Uses

func (a *ListAttr) GetStr(index int) string

GetStr gets item value as string

func (*ListAttr) PopBool Uses

func (a *ListAttr) PopBool() bool

func (*ListAttr) PopFloat Uses

func (a *ListAttr) PopFloat() float64

func (*ListAttr) PopInt Uses

func (a *ListAttr) PopInt() int64

func (*ListAttr) PopListAttr Uses

func (a *ListAttr) PopListAttr() *ListAttr

PopListAttr removes the last item and returns as ListAttr

func (*ListAttr) PopMapAttr Uses

func (a *ListAttr) PopMapAttr() *MapAttr

PopMapAttr removes the last item and returns as MapAttr

func (*ListAttr) PopStr Uses

func (a *ListAttr) PopStr() string

func (*ListAttr) SetBool Uses

func (a *ListAttr) SetBool(index int, v bool)

SetBool sets bool value at the index

func (*ListAttr) SetFloat Uses

func (a *ListAttr) SetFloat(index int, v float64)

SetFloat sets float value at the index

func (*ListAttr) SetInt Uses

func (a *ListAttr) SetInt(index int, v int64)

SetInt sets int value at the index

func (*ListAttr) SetListAttr Uses

func (a *ListAttr) SetListAttr(index int, attr *ListAttr)

SetListAttr sets ListAttr value at the index

func (*ListAttr) SetMapAttr Uses

func (a *ListAttr) SetMapAttr(index int, attr *MapAttr)

SetMapAttr sets MapAttr value at the index

func (*ListAttr) SetStr Uses

func (a *ListAttr) SetStr(index int, v string)

SetStr sets string value at the index

func (*ListAttr) Size Uses

func (a *ListAttr) Size() int

Size returns size of ListAttr

func (*ListAttr) ToList Uses

func (a *ListAttr) ToList() []interface{}

ToList converts ListAttr to slice, recursively

type MapAttr Uses

type MapAttr struct {
    // contains filtered or unexported fields
}

MapAttr is a map attribute containing muiltiple attributes indexed by string keys

func NewMapAttr Uses

func NewMapAttr() *MapAttr

NewMapAttr creates a new MapAttr

func (*MapAttr) AssignMap Uses

func (a *MapAttr) AssignMap(doc map[string]interface{})

AssignMap assigns native map to MapAttr recursively

func (*MapAttr) AssignMapWithFilter Uses

func (a *MapAttr) AssignMapWithFilter(doc map[string]interface{}, filter func(string) bool)

AssignMapWithFilter assigns filtered fields of native map to MapAttr recursively

func (*MapAttr) Del Uses

func (a *MapAttr) Del(key string)

Del deletes a key in MapAttr

func (*MapAttr) ForEach Uses

func (a *MapAttr) ForEach(f func(key string, val interface{}))

ForEach calls f on all items Be careful about the type of val

func (*MapAttr) ForEachKey Uses

func (a *MapAttr) ForEachKey(f func(key string))

ForEachKey calls f on all keys

func (*MapAttr) Get Uses

func (a *MapAttr) Get(key string) interface{}

Get returns the attribute of specified key in MapAttr

func (*MapAttr) GetBool Uses

func (a *MapAttr) GetBool(key string) bool

GetBool returns the attribute of specified key in MapAttr as bool

func (*MapAttr) GetFloat Uses

func (a *MapAttr) GetFloat(key string) float64

GetFloat returns the attribute of specified key in MapAttr as float64

func (*MapAttr) GetInt Uses

func (a *MapAttr) GetInt(key string) int64

GetInt returns the attribute of specified key in MapAttr as int64

func (*MapAttr) GetListAttr Uses

func (a *MapAttr) GetListAttr(key string) *ListAttr

GetListAttr returns the attribute of specified key in MapAttr as ListAttr

func (*MapAttr) GetMapAttr Uses

func (a *MapAttr) GetMapAttr(key string) *MapAttr

GetMapAttr returns the attribute of specified key in MapAttr as MapAttr

func (*MapAttr) GetStr Uses

func (a *MapAttr) GetStr(key string) string

GetStr returns the attribute of specified key in MapAttr as string

func (*MapAttr) HasKey Uses

func (a *MapAttr) HasKey(key string) bool

HasKey returns if the key exists in MapAttr

func (*MapAttr) Keys Uses

func (a *MapAttr) Keys() []string

Keys returns all keys of attrs

func (*MapAttr) Pop Uses

func (a *MapAttr) Pop(key string) interface{}

Pop deletes a key in MapAttr and returns the attribute

func (*MapAttr) PopMapAttr Uses

func (a *MapAttr) PopMapAttr(key string) *MapAttr

PopMapAttr deletes a key in MapAttr and returns the attribute as MapAttr

func (*MapAttr) SetBool Uses

func (a *MapAttr) SetBool(key string, v bool)

SetBool sets bool value at the key

func (*MapAttr) SetDefaultBool Uses

func (a *MapAttr) SetDefaultBool(key string, v bool)

SetDefaultBool sets default bool value at the key

func (*MapAttr) SetDefaultFloat Uses

func (a *MapAttr) SetDefaultFloat(key string, v float64)

SetDefaultFloat sets default float value at the key

func (*MapAttr) SetDefaultInt Uses

func (a *MapAttr) SetDefaultInt(key string, v int64)

SetDefaultInt sets default int value at the key

func (*MapAttr) SetDefaultListAttr Uses

func (a *MapAttr) SetDefaultListAttr(key string, attr *ListAttr)

SetDefaultListAttr sets default ListAttr value at the key

func (*MapAttr) SetDefaultMapAttr Uses

func (a *MapAttr) SetDefaultMapAttr(key string, attr *MapAttr)

SetDefaultMapAttr sets default MapAttr value at the key

func (*MapAttr) SetDefaultStr Uses

func (a *MapAttr) SetDefaultStr(key string, v string)

SetDefaultStr sets default string value at the key

func (*MapAttr) SetFloat Uses

func (a *MapAttr) SetFloat(key string, v float64)

SetFloat sets float value at the key

func (*MapAttr) SetInt Uses

func (a *MapAttr) SetInt(key string, v int64)

SetInt sets int value at the key

func (*MapAttr) SetListAttr Uses

func (a *MapAttr) SetListAttr(key string, attr *ListAttr)

SetListAttr sets ListAttr value at the key

func (*MapAttr) SetMapAttr Uses

func (a *MapAttr) SetMapAttr(key string, attr *MapAttr)

SetMapAttr sets MapAttr value at the key

func (*MapAttr) SetStr Uses

func (a *MapAttr) SetStr(key string, v string)

SetStr sets string value at the key

func (*MapAttr) Size Uses

func (a *MapAttr) Size() int

Size returns the size of MapAttr

func (*MapAttr) ToMap Uses

func (a *MapAttr) ToMap() map[string]interface{}

ToMap converts MapAttr to native map, recursively

func (*MapAttr) ToMapWithFilter Uses

func (a *MapAttr) ToMapWithFilter(filter func(string) bool) map[string]interface{}

ToMapWithFilter converts filtered fields of MapAttr to to native map, recursively

type Space Uses

type Space struct {
    Entity

    Kind int
    // contains filtered or unexported fields
}

Space is the entity type of spaces

Spaces are also entities but with space management logics

func (*Space) CountEntities Uses

func (space *Space) CountEntities(typeName string) int

CountEntities returns the number of entities of specified type in space

func (*Space) CreateEntity Uses

func (space *Space) CreateEntity(typeName string, pos Vector3)

CreateEntity creates a new local entity in this space

func (*Space) DefineAttrs Uses

func (space *Space) DefineAttrs(desc *EntityTypeDesc)

func (*Space) ForEachEntity Uses

func (space *Space) ForEachEntity(f func(e *Entity))

ForEachEntity visits all entities in space and call function f with each entity

func (*Space) GetEntity Uses

func (space *Space) GetEntity(entityID common.EntityID) *Entity

GetEntity returns the entity in space with specified ID, nil otherwise

func (*Space) GetEntityCount Uses

func (space *Space) GetEntityCount() int

GetEntityCount returns the total count of entities in space

func (*Space) IsNil Uses

func (space *Space) IsNil() bool

IsNil checks if the space is the nil space

func (*Space) LoadEntity Uses

func (space *Space) LoadEntity(typeName string, entityID common.EntityID, pos Vector3)

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 Uses

func (space *Space) OnCreated()

OnCreated is called when Space entity is created

func (*Space) OnDestroy Uses

func (space *Space) OnDestroy()

OnDestroy is called when Space entity is destroyed

func (*Space) OnEntityEnterSpace Uses

func (space *Space) OnEntityEnterSpace(entity *Entity)

OnEntityEnterSpace is called when entity enters space

Custom space type can override this function

func (*Space) OnEntityLeaveSpace Uses

func (space *Space) OnEntityLeaveSpace(entity *Entity)

OnEntityLeaveSpace is called when entity leaves space

Custom space type can override this function

func (*Space) OnInit Uses

func (space *Space) OnInit()

OnInit initialize Space entity

func (*Space) OnRestored Uses

func (space *Space) OnRestored()

OnRestored is called when space entity is restored

func (*Space) OnSpaceCreated Uses

func (space *Space) OnSpaceCreated()

OnSpaceCreated is called when space is created

Custom space type can override to provide custom logic

func (*Space) OnSpaceDestroy Uses

func (space *Space) OnSpaceDestroy()

OnSpaceDestroy is called when space is destroying

Custom space type can override to provide custom logic

func (*Space) String Uses

func (space *Space) String() string

type Vector3 Uses

type Vector3 struct {
    X   Coord
    Y   Coord
    Z   Coord
}

Vector3 is type of entity position

func (Vector3) Add Uses

func (p Vector3) Add(o Vector3) Vector3

func (Vector3) DirToYaw Uses

func (dir Vector3) DirToYaw() Yaw

DirToYaw convert direction represented by Vector3 to Yaw

func (Vector3) DistanceTo Uses

func (p Vector3) DistanceTo(o Vector3) Coord

DistanceTo calculates distance between two positions

func (Vector3) Mul Uses

func (p Vector3) Mul(m Coord) Vector3

Mul calculates Vector3 p * m

func (*Vector3) Normalize Uses

func (p *Vector3) Normalize()

func (Vector3) Normalized Uses

func (p Vector3) Normalized() Vector3

func (Vector3) String Uses

func (p Vector3) String() string

func (Vector3) Sub Uses

func (p Vector3) Sub(o Vector3) Vector3

Sub calculates Vector3 p - Vector3 o

type XZListAOICalculator Uses

type XZListAOICalculator struct {
    // contains filtered or unexported fields
}

XZListAOICalculator is an implementation of AOICalculator using XZ lists

func (*XZListAOICalculator) Adjust Uses

func (cal *XZListAOICalculator) Adjust(aoi *aoi) (enter []*aoi, leave []*aoi)

Adjust is called by Entity to adjust neighbors

func (*XZListAOICalculator) Enter Uses

func (cal *XZListAOICalculator) Enter(aoi *aoi, pos Vector3)

Enter is called when Entity enters Space

func (*XZListAOICalculator) Leave Uses

func (cal *XZListAOICalculator) Leave(aoi *aoi)

Leave is called when Entity leaves Space

func (*XZListAOICalculator) Move Uses

func (cal *XZListAOICalculator) Move(aoi *aoi, pos Vector3)

Move is called when Entity moves in Space

type Yaw Uses

type Yaw float32

Yaw is the type of entity yaw

Package entity imports 22 packages (graph) and is imported by 3 packages. Updated 2017-11-18. Refresh now. Tools for package owners.