entity

package
v0.0.0-...-135b9b9 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegEntityProxy

func RegEntityProxy(name string, proxy *EntityProxy)

RegEntityProxy 注册Proxy信息至global变量

Types

type Def

type Def struct {
	Name        string
	Props       map[string]*PropDef
	ClientProps map[string]uint8
}

Def 独立的实体定义

type Defs

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

Defs 所有的实体定义

func GetDefs

func GetDefs() *Defs

GetDefs 获取实体定义信息

func (*Defs) GetDef

func (defs *Defs) GetDef(name string) *Def

GetDef 获取一个entity定义

func (*Defs) Init

func (defs *Defs) Init()

Init 初始化文件定义结构

type Entities

type Entities struct {
	msghandler.IMsgHandlers
	*timer.Timer
	*events.GlobalEvents
	// contains filtered or unexported fields
}

Entities entity的集合

func NewEntities

func NewEntities(isMutilThread bool) *Entities

NewEntities 创建一个新的Entities

func (*Entities) CreateEntity

func (es *Entities) CreateEntity(entityType string, entityID uint64, dbid uint64, cellID uint64, initParam interface{}, syncInit bool, realServerID uint64) (iserver.IEntity, error)

CreateEntity 创建实体

func (*Entities) CreateEntityAll

func (es *Entities) CreateEntityAll(entityType string, dbid uint64, initParam interface{}, syncInit bool) (iserver.IEntity, error)

CreateEntityAll 创建实体的所有部分

func (*Entities) Destroy

func (es *Entities) Destroy()

Destroy 删除所有的实体

func (*Entities) DestroyEntity

func (es *Entities) DestroyEntity(entityID uint64) error

DestroyEntity 删除Entity

func (*Entities) DestroyEntityAll

func (es *Entities) DestroyEntityAll(entityID uint64) error

DestroyEntityAll 销毁实体的所有部分

func (*Entities) DestroyEntityByDBID

func (es *Entities) DestroyEntityByDBID(entityType string, dbID uint64) error

DestroyEntityByDBID 删除 Entity

func (*Entities) EntityCount

func (es *Entities) EntityCount() uint32

EntityCount 返回实体数

func (*Entities) GetEntity

func (es *Entities) GetEntity(entityID uint64) iserver.IEntity

GetEntity 获取Entity

func (*Entities) GetEntityByDBID

func (es *Entities) GetEntityByDBID(entityType string, dbid uint64) iserver.IEntity

GetEntityByDBID 获取Entity

func (*Entities) Init

func (es *Entities) Init()

Init 初始化

func (*Entities) MainLoop

func (es *Entities) MainLoop()

MainLoop 自己的逻辑线程

func (*Entities) MsgProc_CreateEntityReq

func (es *Entities) MsgProc_CreateEntityReq(content msgdef.IMsg)

MsgProc_CreateEntityReq 请求创建Entity

func (*Entities) MsgProc_DestroyEntityReq

func (es *Entities) MsgProc_DestroyEntityReq(content msgdef.IMsg)

MsgProc_DestroyEntityReq 请求删除Entity

func (*Entities) MsgProc_EntityMsgTransport

func (es *Entities) MsgProc_EntityMsgTransport(content msgdef.IMsg)

MsgProc_EntityMsgTransport Entity之间转发消息

func (*Entities) MsgProc_SrvMsgTransport

func (es *Entities) MsgProc_SrvMsgTransport(content msgdef.IMsg)

func (*Entities) Range

func (es *Entities) Range(f func(k, v interface{}) bool)

Range 遍历所有Entity

func (*Entities) SyncDestroy

func (es *Entities) SyncDestroy()

SyncDestroy 删除所有Entity, 并等待所有Entity删除结束

func (*Entities) TravsalEntity

func (es *Entities) TravsalEntity(entityType string, f func(iserver.IEntity))

TravsalEntity 遍历某一类型的entity

type Entity

type Entity struct {
	msghandler.IMsgHandlers
	// contains filtered or unexported fields
}

Entity 代表服务器端一个可通讯对象

func (*Entity) Debug

func (e *Entity) Debug(v ...interface{})

Debug 日志

func (*Entity) Debugf

func (e *Entity) Debugf(format string, v ...interface{})

Debugf 日志

func (*Entity) DelayPost

func (e *Entity) DelayPost(srvType uint8, msg msgdef.IMsg) error

DelayPost 延迟发送消息, 在帧尾发送

func (*Entity) DoLooper

func (e *Entity) DoLooper()

DoLooper 调用后代类的loop函数

func (*Entity) Error

func (e *Entity) Error(v ...interface{})

Error 日志

func (*Entity) Errorf

func (e *Entity) Errorf(format string, v ...interface{})

Errorf 日志

func (*Entity) ExportPackMsg

func (e *Entity) ExportPackMsg(srvType uint8, cellID uint64, msg msgdef.IMsg) (msgdef.IMsg, error)

func (*Entity) FlushDelayedMsgs

func (e *Entity) FlushDelayedMsgs()

发送所有延迟发送的消息

func (*Entity) GetCellID

func (e *Entity) GetCellID() uint64

GetCellID

func (*Entity) GetClientSess

func (e *Entity) GetClientSess() iserver.ISess

GetClientSess 获取客户端连接

func (*Entity) GetDBID

func (e *Entity) GetDBID() uint64

GetDBID 获取实体的DBID

func (*Entity) GetEntities

func (e *Entity) GetEntities() iserver.IEntities

GetEntities 获取包含自己的Entities指针

func (*Entity) GetEntityState

func (e *Entity) GetEntityState() uint8

GetEntityState 获取当前状态

func (*Entity) GetID

func (e *Entity) GetID() uint64

GetID 获取实体ID

func (*Entity) GetInitParam

func (e *Entity) GetInitParam() interface{}

GetInitParam 获取初始化参数

func (*Entity) GetProp

func (e *Entity) GetProp(name string) interface{}

GetProp 获取一个属生的值

func (*Entity) GetProxy

func (e *Entity) GetProxy() iserver.IEntityProxy

GetProxy 获取实体的代理对象

func (*Entity) GetRealCellID

func (e *Entity) GetRealCellID() uint64

GetRealCellID

func (*Entity) GetRealPtr

func (e *Entity) GetRealPtr() interface{}

GetRealPtr 获取真实的后代对象的指针

func (*Entity) GetRealServerID

func (e *Entity) GetRealServerID() uint64

GetRealServerID 获取realServerID

func (*Entity) GetSrvIDS

func (e *Entity) GetSrvIDS() map[uint8]*dbservice.EntitySrvInfo

GetSrvIDS 获取玩家的分布式实体所在的服务器列表

func (*Entity) GetType

func (e *Entity) GetType() string

GetType 获取实体类型

func (*Entity) Info

func (e *Entity) Info(v ...interface{})

Info 日志

func (*Entity) Infof

func (e *Entity) Infof(format string, v ...interface{})

Infof 日志

func (*Entity) InitProp

func (e *Entity) InitProp(def *Def)

InitProp 初始化属性列表

func (*Entity) IsCell

func (e *Entity) IsCell() bool

IsCell 是否是空间

func (*Entity) IsCellEntity

func (e *Entity) IsCellEntity() bool

IsCellEntity 是否是个空间实体

func (*Entity) IsDestroyed

func (e *Entity) IsDestroyed() bool

IsDestroyed 是否删除

func (*Entity) IsGhost

func (e *Entity) IsGhost() bool

IsGhost 是否是ghost实体

func (*Entity) IsOwnerCellEntity

func (e *Entity) IsOwnerCellEntity() bool

IsOwnerCellEntity 是否拥有SpaceEntity的部分

func (*Entity) JcmiaoTempLog

func (e *Entity) JcmiaoTempLog(v ...interface{})

func (*Entity) LeaveCell

func (e *Entity) LeaveCell()

LeaveCell 离开场景

func (*Entity) MainLoop

func (e *Entity) MainLoop()

MainLoop 主循环

func (*Entity) MsgProc_EntitySrvInfoNotify

func (e *Entity) MsgProc_EntitySrvInfoNotify(msgdef.IMsg)

func (*Entity) MsgProc_PropsSync

func (e *Entity) MsgProc_PropsSync(content msgdef.IMsg)

MsgProc_PropsSync 实体间同步数据的消息

func (*Entity) MsgProc_RPCMsg

func (e *Entity) MsgProc_RPCMsg(content msgdef.IMsg)

MsgProc_RPCMsg 实体间RPC调用消息处理

func (*Entity) OnAfterInit

func (e *Entity) OnAfterInit()

OnAfterInit 后代的初始化

func (*Entity) OnDestroy

func (e *Entity) OnDestroy()

OnDestroy 销毁

func (*Entity) OnEntityCreated

func (e *Entity) OnEntityCreated(entityID uint64, entityType string, dbid uint64, cellID uint64, protoType interface{}, entities iserver.IEntities, initParam interface{}, syncInit bool, realServerID uint64)

OnEntityCreated 初始化

func (*Entity) OnEntityDestroyed

func (e *Entity) OnEntityDestroyed()

OnEntityDestroyed 当Entity销毁时调用

func (*Entity) OnInit

func (e *Entity) OnInit()

OnInit 初始化

func (*Entity) OnLoop

func (e *Entity) OnLoop()

OnLoop 运行时

func (*Entity) PackMRoleProps

func (e *Entity) PackMRoleProps() (int, []byte)

PackMRoleProps 打包主角关心的属性

func (*Entity) PackProps

func (e *Entity) PackProps(isClientInterest bool) (int, []byte)

PackProps 打包属性

func (*Entity) PackPropsToBytes

func (e *Entity) PackPropsToBytes(props []*PropInfo) []byte

PackPropsToBytes 把属列表打包成bytes

func (*Entity) Post

func (e *Entity) Post(srvType uint8, msg msgdef.IMsg) error

Post 投递一个消息给指定的部分 发送消息可能失败,在极端情况下

func (*Entity) PostGateRaw

func (e *Entity) PostGateRaw(srvType uint8, rawMsg []byte) error

PostGateRaw 投递一个gateway原始消息

func (*Entity) PostGateRawToCell

func (e *Entity) PostGateRawToCell(rawMsg []byte) error

PostGateRawToCell 投递一个原始消息给它的SpaceEntity部分

func (*Entity) PostToCell

func (e *Entity) PostToCell(msg msgdef.IMsg) error

PostToCell 投递一个消息给它的SpaceEntity部分

func (*Entity) PropDirty

func (e *Entity) PropDirty(name string)

PropDirty 设置某属性为Dirty

func (*Entity) RPC

func (e *Entity) RPC(srvType uint8, methodName string, args ...interface{}) error

RPC 快速消息调用

func (*Entity) ReflushDirtyProp

func (e *Entity) ReflushDirtyProp()

ReflushDirtyProp 每一帧刷新属性通知

func (*Entity) ReflushFromMsg

func (e *Entity) ReflushFromMsg(num int, data []byte)

ReflushFromMsg 从消息中更新属性

func (*Entity) RefreshSrvIDS

func (e *Entity) RefreshSrvIDS()

RefreshSrvIDS 从redis上更新 当前 entity所有的分布式信息

func (*Entity) RegSrvID

func (e *Entity) RegSrvID()

RegSrvID 将当前部分的Entity注册到Redis上

func (*Entity) SetClient

func (e *Entity) SetClient(s iserver.ISess)

SetClient 设置客户端的连接

func (*Entity) SetProp

func (e *Entity) SetProp(name string, v interface{})

SetProp 设置一个属性的值

func (*Entity) SetRealCellID

func (e *Entity) SetRealCellID(cellID uint64)

func (*Entity) SetRealServerID

func (e *Entity) SetRealServerID(srvID uint64)

func (*Entity) String

func (e *Entity) String() string

String Entity基础信息

func (*Entity) UnregSrvID

func (e *Entity) UnregSrvID()

unregSrvID 将当前部分的Entity从Redis上删除

func (*Entity) Warn

func (e *Entity) Warn(v ...interface{})

Warn 日志

func (*Entity) Warnf

func (e *Entity) Warnf(format string, v ...interface{})

Warnf 日志

type EntityProxy

type EntityProxy struct {
	SrvID    uint64
	CellID   uint64
	EntityID uint64
}

EntityProxy 实体的一个代理,可以方便的传递

func GetEntityProxy

func GetEntityProxy(name string) *EntityProxy

GetEntityProxy 从global变量获取Proxy

func NewEntityProxy

func NewEntityProxy(srvID uint64, cellID uint64, entityID uint64) *EntityProxy

NewEntityProxy 创建一个新的实体代理

func (*EntityProxy) Post

func (e *EntityProxy) Post(msg msgdef.IMsg) error

Post 将某个消息投递给该实体

func (*EntityProxy) RPC

func (e *EntityProxy) RPC(srvType uint8, methodName string, args ...interface{}) error

RPC 快速消息调用,可以快速触发一个其它实体的方法, 服务器间使用

func (*EntityProxy) String

func (e *EntityProxy) String() string

type PropDef

type PropDef struct {
	Name             string
	Desc             string
	Type             reflect.Type
	TypeName         string
	InterestSrvs     []uint8
	IsClientInterest bool
	IsMRoleInterest  bool
	Persistence      bool //是否需要持久化, 默认true
	Sync             bool //是否需要同步至其他服务器, 默认true
}

PropDef 字段定义

func (*PropDef) CreateInst

func (pd *PropDef) CreateInst() (interface{}, error)

CreateInst 创建该属性的一个实例

func (*PropDef) IsValidValue

func (pd *PropDef) IsValidValue(value interface{}) bool

IsValidValue 当前值是否能设置到该属性上

type PropInfo

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

PropInfo 属性相关

func (*PropInfo) GetValueStreamSize

func (p *PropInfo) GetValueStreamSize() int

GetValueStreamSize 获取某个属性需要的尺寸

func (*PropInfo) PackValue

func (p *PropInfo) PackValue() []byte

PackValue 打包value 给Redis用

func (*PropInfo) ReadValueFromStream

func (p *PropInfo) ReadValueFromStream(bs *common.ByteStream) error

ReadValueFromStream 从Stream中读取属性

func (*PropInfo) UnPackValue

func (p *PropInfo) UnPackValue(data interface{})

UnPackValue 从Redis中恢复Value

func (*PropInfo) WriteValueToStream

func (p *PropInfo) WriteValueToStream(bs *common.ByteStream) error

WriteValueToStream 把属性值加入到ByteStream中

type ProtoType

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

ProtoType 保存实体映射列表

func NewProtoType

func NewProtoType() *ProtoType

NewProtoType 创建新的对象

func (*ProtoType) NewEntityByProtoType

func (es *ProtoType) NewEntityByProtoType(entityType string) interface{}

NewEntityByProtoType 创建 一个对象

func (*ProtoType) RegProtoType

func (es *ProtoType) RegProtoType(name string, protoType iserver.IEntity, autoCreate bool)

RegProtoType 注册原型

Jump to

Keyboard shortcuts

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