entity

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectEntitySyncInfos

func CollectEntitySyncInfos()

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

func CreateEntityAnywhere

func CreateEntityAnywhere(typeName string)

CreateEntityAnywhere creates new entity in any game

func CreateEntityLocally

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

CreateEntityLocally creates new entity in the local game

func CreateSpaceAnywhere

func CreateSpaceAnywhere(kind int)

CreateSpaceAnywhere creates a space in any game server

func CreateSpaceLocally

func CreateSpaceLocally(kind int) common.EntityID

CreateSpaceLocally creates a space in the local game server

func LoadEntityAnywhere

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

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

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

func OnClientDisconnected(clientid common.ClientID)

OnClientDisconnected is called by engine when client is disconnected

func OnDeclareService

func OnDeclareService(serviceName string, entityid common.EntityID)

OnDeclareService is called by engine when service is declared

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 OnMigrateRequestAck

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

OnMigrateRequestAck is called by engine when mgirate request Ack is received

func OnRealMigrate

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

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

OnSyncPositionYawFromClient is called by engine to sync entity infos from client

func OnUndeclareService

func OnUndeclareService(serviceName string, entityid common.EntityID)

OnUndeclareService is called by engine when service is undeclared

func RegisterSpace

func RegisterSpace(spacePtr interface{})

RegisterSpace registers the user custom space type

func RestoreFreezedEntities

func RestoreFreezedEntities(freeze *FreezeData) (err error)

RestoreFreezedEntities restore entity system from freeze data

func SaveAllEntities

func SaveAllEntities()

SaveAllEntities saves all entities

func SetSaveInterval

func SetSaveInterval(duration time.Duration)

SetSaveInterval sets the save interval for entity system

Types

type AOICalculator

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

type Component struct {
	*Entity
}

type Coord

type Coord float32

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

type Entity

type Entity struct {
	ID       common.EntityID
	TypeName string
	I        interface{}
	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

func GetEntity(id common.EntityID) *Entity

GetEntity returns the entity with specified ID

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

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

Call other entities

func (*Entity) CallAllClients

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

CallAllClients calls the entity method on all clients

func (*Entity) CallClient

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

CallClient calls the client entity

func (*Entity) CallFitleredClients

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

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

CallService calls a service provider

func (*Entity) CancelTimer

func (e *Entity) CancelTimer(tid EntityTimerID)

CancelTimer cancels the Callback / Timer

func (*Entity) DeclareService

func (e *Entity) DeclareService(serviceName string)

DeclareService declares global service for service entity

func (*Entity) Destroy

func (e *Entity) Destroy()

Destroy destroys the entity

func (*Entity) DistanceTo

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

DistanceTo calculates the distance between two entities

func (*Entity) EnterSpace

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

EnterSpace let the entity enters space

func (*Entity) FaceTo

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

FaceTo let entity face to another entity by setting yaw accordingly

func (*Entity) FaceToPos

func (e *Entity) FaceToPos(pos Vector3)

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) GetFloat

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

GetFloat gets an outtermost attribute as float64

func (*Entity) GetFreezeData

func (e *Entity) GetFreezeData() *entityFreezeData

GetFreezeData gets freezed data

func (*Entity) GetInt

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

GetInt gets an outtermost attribute as int

func (*Entity) GetListAttr

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

GetListAttr gets an outtermost attribute as ListAttr

func (*Entity) GetMapAttr

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

GetMapAttr gets an outtermost attribute as MapAttr

func (*Entity) GetMigrateData

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

GetMigrateData gets the migration data

func (*Entity) GetPosition

func (e *Entity) GetPosition() Vector3

GetPosition returns the entity position

func (*Entity) GetStr

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

GetStr gets an outtermost attribute as string

func (*Entity) GetYaw

func (e *Entity) GetYaw() Yaw

GetYaw gets entity yaw

func (*Entity) GiveClientTo

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

GiveClientTo gives client to other entity

func (*Entity) IsDestroyed

func (e *Entity) IsDestroyed() bool

IsDestroyed returns if the entity is destroyed

func (*Entity) IsNeighbor

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

func (*Entity) IsPersistent

func (e *Entity) IsPersistent() bool

IsPersistent returns if the entity is persistent

Default implementation check entity for persistent attributes

func (*Entity) IsSpaceEntity

func (e *Entity) IsSpaceEntity() bool

IsSpaceEntity returns if the entity is actually a space

func (*Entity) IsUseAOI

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

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

LoadMigrateData loads migrate data

func (*Entity) Neighbors

func (e *Entity) Neighbors() EntitySet

Neighbors get all neighbors in an EntitySet

Never modify the return value !

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) 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) OnLeaveSpace

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

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

func (e *Entity) PanicOnError(err error)

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) Save

func (e *Entity) Save()

Save the entity

func (*Entity) SetClient

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

SetClient sets the client of entity

func (*Entity) SetClientSyncing

func (e *Entity) SetClientSyncing(syncing bool)

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

func (*Entity) SetFilterProp

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

SetFilterProp sets a filter property key-value

func (*Entity) SetPosition

func (e *Entity) SetPosition(pos Vector3)

SetPosition sets the entity position

func (*Entity) SetYaw

func (e *Entity) SetYaw(yaw Yaw)

SetYaw sets entity yaw

func (*Entity) String

func (e *Entity) String() string

func (*Entity) ToSpace

func (e *Entity) ToSpace() *Space

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

type EntityIDSet

type EntityIDSet map[common.EntityID]struct{}

EntityIDSet is the data structure for a set of entity IDs

func GetServiceProviders

func GetServiceProviders(serviceName string) EntityIDSet

GetServiceProviders returns all service providers

func (EntityIDSet) Add

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

Add adds an entity ID to EntityIDSet

func (EntityIDSet) Contains

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

Contains checks if entity ID is in EntityIDSet

func (EntityIDSet) Del

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

Del removes an entity ID from EntityIDSet

func (EntityIDSet) ToList

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

ToList convert EntityIDSet to a slice of entity IDs

type EntityMap

type EntityMap map[common.EntityID]*Entity

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 (EntityMap) Add

func (em EntityMap) Add(entity *Entity)

Add adds a new entity to EntityMap

func (EntityMap) Del

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

Del deletes an entity from EntityMap

func (EntityMap) Get

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

Get returns the Entity of specified entity ID in EntityMap

type EntitySet

type EntitySet map[*Entity]struct{}

EntitySet is the data structure for a set of entities

func (EntitySet) Add

func (es EntitySet) Add(entity *Entity)

Add adds an entity to the EntitySet

func (EntitySet) Contains

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

Contains returns if the entity is in the EntitySet

func (EntitySet) Del

func (es EntitySet) Del(entity *Entity)

Del deletes an entity from the EntitySet

func (EntitySet) String

func (es EntitySet) String() string

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 {
	// contains filtered or unexported fields
}

EntityTypeDesc is the entity type description for registering entity types

func RegisterEntity

func RegisterEntity(typeName string, entity interface{}, isPersistent bool, useAOI bool) *EntityTypeDesc

RegisterEntity registers custom entity type and define entity behaviors

func (*EntityTypeDesc) DefineAttrs

func (desc *EntityTypeDesc) DefineAttrs(attrDefs map[string][]string)

DefineAttrs defines properties of entity attributes

Valid attribute properties includes Client, AllClient, Persistent

type FreezeData

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

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, gid uint16) *GameClient

MakeGameClient creates a GameClient object using Client ID and Game ID

func (*GameClient) String

func (client *GameClient) String() string

type ListAttr

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

ListAttr is a attribute for a list of attributes

func NewListAttr

func NewListAttr() *ListAttr

NewListAttr creates a new ListAttr

func (*ListAttr) AppendBool

func (a *ListAttr) AppendBool(v bool)

AppendBool puts bool value to the end of list

func (*ListAttr) AppendFloat

func (a *ListAttr) AppendFloat(v float64)

AppendFloat puts float value to the end of list

func (*ListAttr) AppendInt

func (a *ListAttr) AppendInt(v int64)

AppendInt puts int value to the end of list

func (*ListAttr) AppendListAttr

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

AppendListAttr puts ListAttr value to the end of list

func (*ListAttr) AppendMapAttr

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

AppendMapAttr puts MapAttr value to the end of list

func (*ListAttr) AppendStr

func (a *ListAttr) AppendStr(v string)

AppendStr puts string value to the end of list

func (*ListAttr) AssignList

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

AssignList assigns slice to ListAttr, recursively

func (*ListAttr) GetBool

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

GetBool gets item value as bool

func (*ListAttr) GetFloat

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

GetFloat gets item value as float64

func (*ListAttr) GetInt

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

GetInt gets item value as int

func (*ListAttr) GetListAttr

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

GetListAttr gets item value as ListAttr

func (*ListAttr) GetMapAttr

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

GetMapAttr gets item value as MapAttr

func (*ListAttr) GetStr

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

GetStr gets item value as string

func (*ListAttr) PopBool

func (a *ListAttr) PopBool() bool

func (*ListAttr) PopFloat

func (a *ListAttr) PopFloat() float64

func (*ListAttr) PopInt

func (a *ListAttr) PopInt() int64

func (*ListAttr) PopListAttr

func (a *ListAttr) PopListAttr() *ListAttr

PopListAttr removes the last item and returns as ListAttr

func (*ListAttr) PopMapAttr

func (a *ListAttr) PopMapAttr() *MapAttr

PopMapAttr removes the last item and returns as MapAttr

func (*ListAttr) PopStr

func (a *ListAttr) PopStr() string

func (*ListAttr) SetBool

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

SetBool sets bool value at the index

func (*ListAttr) SetFloat

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

SetFloat sets float value at the index

func (*ListAttr) SetInt

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

SetInt sets int value at the index

func (*ListAttr) SetListAttr

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

SetListAttr sets ListAttr value at the index

func (*ListAttr) SetMapAttr

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

SetMapAttr sets MapAttr value at the index

func (*ListAttr) SetStr

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

SetStr sets string value at the index

func (*ListAttr) Size

func (a *ListAttr) Size() int

Size returns size of ListAttr

func (*ListAttr) ToList

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

ToList converts ListAttr to slice, recursively

type MapAttr

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

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

func NewMapAttr

func NewMapAttr() *MapAttr

NewMapAttr creates a new MapAttr

func (*MapAttr) AssignMap

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

AssignMap assigns native map to MapAttr recursively

func (*MapAttr) AssignMapWithFilter

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

func (a *MapAttr) Del(key string)

Del deletes a key in MapAttr

func (*MapAttr) ForEach

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

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

ForEachKey calls f on all keys

func (*MapAttr) Get

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

Get returns the attribute of specified key in MapAttr

func (*MapAttr) GetBool

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

GetBool returns the attribute of specified key in MapAttr as bool

func (*MapAttr) GetFloat

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

GetFloat returns the attribute of specified key in MapAttr as float64

func (*MapAttr) GetInt

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

GetInt returns the attribute of specified key in MapAttr as int64

func (*MapAttr) GetListAttr

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

GetListAttr returns the attribute of specified key in MapAttr as ListAttr

func (*MapAttr) GetMapAttr

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

GetMapAttr returns the attribute of specified key in MapAttr as MapAttr

func (*MapAttr) GetStr

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

GetStr returns the attribute of specified key in MapAttr as string

func (*MapAttr) HasKey

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

HasKey returns if the key exists in MapAttr

func (*MapAttr) Keys

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

Keys returns all keys of attrs

func (*MapAttr) Pop

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

Pop deletes a key in MapAttr and returns the attribute

func (*MapAttr) PopMapAttr

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

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

func (*MapAttr) SetBool

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

SetBool sets bool value at the key

func (*MapAttr) SetDefaultBool

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

SetDefaultBool sets default bool value at the key

func (*MapAttr) SetDefaultFloat

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

SetDefaultFloat sets default float value at the key

func (*MapAttr) SetDefaultInt

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

SetDefaultInt sets default int value at the key

func (*MapAttr) SetDefaultListAttr

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

SetDefaultListAttr sets default ListAttr value at the key

func (*MapAttr) SetDefaultMapAttr

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

SetDefaultMapAttr sets default MapAttr value at the key

func (*MapAttr) SetDefaultStr

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

SetDefaultStr sets default string value at the key

func (*MapAttr) SetFloat

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

SetFloat sets float value at the key

func (*MapAttr) SetInt

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

SetInt sets int value at the key

func (*MapAttr) SetListAttr

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

SetListAttr sets ListAttr value at the key

func (*MapAttr) SetMapAttr

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

SetMapAttr sets MapAttr value at the key

func (*MapAttr) SetStr

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

SetStr sets string value at the key

func (*MapAttr) Size

func (a *MapAttr) Size() int

Size returns the size of MapAttr

func (*MapAttr) ToMap

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

ToMap converts MapAttr to native map, recursively

func (*MapAttr) ToMapWithFilter

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

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

type Space

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

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

CountEntities returns the number of entities of specified type in space

func (*Space) CreateEntity

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

CreateEntity creates a new local entity in this space

func (*Space) ForEachEntity

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

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

func (*Space) GetEntity

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

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

func (*Space) GetEntityCount

func (space *Space) GetEntityCount() int

GetEntityCount returns the total count of entities in space

func (*Space) IsNil

func (space *Space) IsNil() bool

IsNil checks if the space is the nil space

func (*Space) LoadEntity

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

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

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

OnEntityEnterSpace is called when entity enters space

Custom space type can override this function

func (*Space) OnEntityLeaveSpace

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

OnEntityLeaveSpace is called when entity leaves space

Custom space type can override this function

func (*Space) OnInit

func (space *Space) OnInit()

OnInit initialize Space entity

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) String

func (space *Space) String() string

type Vector3

type Vector3 struct {
	X Coord
	Y Coord
	Z Coord
}

Vector3 is type of entity position

func (Vector3) Add

func (p Vector3) Add(o Vector3) Vector3

func (Vector3) DirToYaw

func (dir Vector3) DirToYaw() Yaw

DirToYaw convert direction represented by Vector3 to Yaw

func (Vector3) DistanceTo

func (p Vector3) DistanceTo(o Vector3) Coord

DistanceTo calculates distance between two positions

func (Vector3) Mul

func (p Vector3) Mul(m Coord) Vector3

Mul calculates Vector3 p * m

func (*Vector3) Normalize

func (p *Vector3) Normalize()

func (Vector3) Normalized

func (p Vector3) Normalized() Vector3

func (Vector3) String

func (p Vector3) String() string

func (Vector3) Sub

func (p Vector3) Sub(o Vector3) Vector3

Sub calculates Vector3 p - Vector3 o

type XZListAOICalculator

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

XZListAOICalculator is an implementation of AOICalculator using XZ lists

func (*XZListAOICalculator) Adjust

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

Adjust is called by Entity to adjust neighbors

func (*XZListAOICalculator) Enter

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

Enter is called when Entity enters Space

func (*XZListAOICalculator) Leave

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

Leave is called when Entity leaves Space

func (*XZListAOICalculator) Move

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

Move is called when Entity moves in Space

type Yaw

type Yaw float32

Yaw is the type of entity yaw

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL