Documentation ¶
Overview ¶
Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi
Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi
Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi
Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi
Created by xuzhuoxi on 2019-03-08. @author xuzhuoxi
Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi
Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi
Created by xuzhuoxi on 2019-03-16. @author xuzhuoxi
Created by xuzhuoxi on 2019-02-19. @author xuzhuoxi
Created by xuzhuoxi on 2019-03-09. @author xuzhuoxi
Created by xuzhuoxi on 2019-03-09. @author xuzhuoxi
Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi
Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi
Index ¶
- Constants
- Variables
- func EntityEqual(entity1 IEntity, entity2 IEntity) bool
- func GetTeamCorpsId() string
- func GetTeamId() string
- func NearXY(pos1 XY, pos2 XY, distance float64) bool
- func NearXYZ(pos1 XYZ, pos2 XYZ, distance float64) bool
- func NewVarSet() encodingx.IKeyValue
- type ChannelType
- type EntityType
- type IChannelBehavior
- type IChannelEntity
- type IChannelIndex
- type IDestroyEntity
- type IEntity
- type IEntityChild
- type IEntityContainer
- type IEntityGroup
- type IEntityIndex
- type IInitEntity
- type IManagerBase
- type IRoomEntity
- type IRoomGroup
- type IRoomIndex
- type ITeamControl
- type ITeamCorpsEntity
- type ITeamCorpsIndex
- type ITeamEntity
- type ITeamGroup
- type ITeamIndex
- type IUserBlackList
- type IUserEntity
- type IUserGroup
- type IUserIndex
- type IUserSubscriber
- type IUserWhiteList
- type IVariableSupport
- type IWorldEntity
- type IWorldIndex
- type IZoneEntity
- type IZoneGroup
- type IZoneIndex
- type XY
- type XYZ
Constants ¶
const ( PidVarWorld = iota + 1000 PidVarZone PidVarRoom PidVarUser PidVarCorps PidVarTeam PidVarChannel )
const ( EventUserJoinRoom = "EventUserJoinRoom" EventUserLeaveRoom = "EventUserLeaveRoom" )
const (
EventVariableChanged = "EventVariableChanged"
)
const (
ExtMmoVar = "EVar"
)
Variables ¶
var ( MaxTeamMember = 0 TeamId = 1000 TeamName = "的队伍" )
var ( TeamCorpsId = 1000 TeamCorpsName = "的军团" )
Functions ¶
func EntityEqual ¶
func GetTeamCorpsId ¶
func GetTeamCorpsId() string
Types ¶
type ChannelType ¶
type ChannelType uint16
const ( //无效 None ChannelType = iota //状态 StatusChannel //聊天 ChatChannel //事件 EventChannel )
type EntityType ¶
type EntityType uint16
const ( EntityWorld EntityType = 1 << iota EntityZone EntityRoom EntityUser EntityTeamCorps EntityTeam EntityChannel EntityNone EntityType = 0 EntityAll EntityType = EntityWorld | EntityZone | EntityRoom | EntityUser | EntityTeamCorps | EntityTeam | EntityChannel )
func (EntityType) Include ¶
func (t EntityType) Include(check EntityType) bool
func (EntityType) Match ¶
func (t EntityType) Match(check EntityType) bool
type IChannelBehavior ¶
type IChannelBehavior interface { MyChannel() IChannelEntity //订阅频道 TouchChannel(subscriber string) //取消频道订阅 UnTouchChannel(subscriber string) //消息广播 Broadcast(speaker string, handler func(receiver string)) int //消息指定目标广播 BroadcastSome(speaker string, receiver []string, handler func(receiver string)) int }
频道行为
type IChannelIndex ¶
type IChannelIndex interface { IEntityIndex //检查Channel是否存在 CheckChannel(chanId string) bool //获取Channel GetChannel(chanId string) IChannelEntity //从索引中增加一个Channel AddChannel(channel IChannelEntity) error //从索引中移除一个Channel RemoveChannel(chanId string) (IChannelEntity, error) //从索引中更新一个Channel UpdateChannel(channel IChannelEntity) error }
频道索引
type IDestroyEntity ¶
type IDestroyEntity interface {
//释放实体
DestroyEntity()
}
type IEntity ¶
type IEntity interface { //唯一标识 UID() string //昵称,显示使用 NickName() string //实体类型 EntityType() EntityType }
type IEntityChild ¶
type IEntityContainer ¶
type IEntityContainer interface { NumChildren() int Full() bool Contains(entity IEntity) (isContains bool) ContainsById(entityId string) (isContains bool) GetChildById(entityId string) (entity IEntity, ok bool) ReplaceChildInto(entity IEntity) error AddChild(entity IEntity) error RemoveChild(entity IEntity) error RemoveChildById(entityId string) (entity IEntity, ok bool) ForEachChild(each func(child IEntity) (interruptCurrent bool, interruptRecurse bool)) ForEachChildByType(entityType EntityType, each func(child IEntity), recurse bool) }
type IEntityGroup ¶
type IEntityGroup interface { //接纳实体的类型 EntityType() EntityType //最大实例数 MaxLen() int //实体数量 Len() int //实体已满 IsFull() bool //包含实体id Entities() []string //包含实体id CopyEntities() []string //检查实体是否属于当前组 ContainEntity(entityId string) bool //加入实体到组,进行唯一性检查 Accept(entity string) error //加入实体到组,进行唯一性检查 AcceptMulti(entityId []string) (count int, err error) //从组中移除实体 Drop(entityId string) error //从组中移除实体 DropMulti(entityId []string) (count int, err error) }
组
type IEntityIndex ¶
type IInitEntity ¶
type IInitEntity interface {
//初始化实体
InitEntity()
}
type IManagerBase ¶
type IManagerBase interface { logx.ILoggerSetter InitManager() DisposeManager() }
type IRoomEntity ¶
type IRoomEntity interface { IEntity IInitEntity IEntityChild //IUserGroup IEntityContainer IVariableSupport }
房间实体
type IRoomGroup ¶
type IRoomIndex ¶
type IRoomIndex interface { IEntityIndex //检查Room是否存在 CheckRoom(roomId string) bool //获取Room GetRoom(roomId string) IRoomEntity //添加一个新Room到索引中 AddRoom(room IRoomEntity) error //从索引中移除一个Room RemoveRoom(roomId string) (IRoomEntity, error) //从索引中更新一个Room UpdateRoom(room IRoomEntity) error }
房间索引
type ITeamControl ¶
type ITeamCorpsEntity ¶
type ITeamCorpsEntity interface { IEntity IEntityChild IInitEntity IEntityContainer //ITeamGroup IVariableSupport }
兵团实体
type ITeamCorpsIndex ¶
type ITeamCorpsIndex interface { IEntityIndex //检查Corps是否存在 CheckCorps(corpsId string) bool //获取Corps GetCorps(corpsId string) ITeamCorpsEntity //添加一个新Corps到索引中 AddCorps(corps ITeamCorpsEntity) error //从索引中移除一个Corps RemoveCorps(corpsId string) (ITeamCorpsEntity, error) //更新一个新Corps到索引中 UpdateCorps(corps ITeamCorpsEntity) error }
type ITeamEntity ¶
type ITeamEntity interface { IEntity IInitEntity IEntityChild IEntityContainer IVariableSupport }
队伍实体
type ITeamGroup ¶
type ITeamIndex ¶
type ITeamIndex interface { IEntityIndex //检查Team是否存在 CheckTeam(teamId string) bool //获取Team GetTeam(teamId string) ITeamEntity //添加一个新Team到索引中 AddTeam(team ITeamEntity) error //从索引中移除一个Team RemoveTeam(teamId string) (ITeamEntity, error) //从索引中更新一个Team UpdateTeam(team ITeamEntity) error }
队伍索引
type IUserBlackList ¶
type IUserBlackList interface { //通信黑名单,返回原始切片,如果要修改的,请先copy Blacks() []string //增加黑名单 AddBlack(targetId string) error //移除黑名单 RemoveBlack(targetId string) error //处于 OnBlack(targetId string) bool }
黑名单
type IUserEntity ¶
type IUserEntity interface { IEntity IInitEntity IDestroyEntity IUserSubscriber IVariableSupport //用户名 UserName() string GetLocation() (idType EntityType, id string) SetLocation(idType EntityType, id string) GetTeamInfo() (teamId string, corpsId string) SetTeam(teamId string) SetCorps(corpsId string) GetPosition() XYZ SetPosition(pos XYZ) }
用户实体
type IUserGroup ¶
type IUserIndex ¶
type IUserIndex interface { IEntityIndex //检查User是否存在 CheckUser(userId string) bool //获取User GetUser(userId string) IUserEntity //添加一个新User到索引中 AddUser(user IUserEntity) error //从索引中移除一个User RemoveUser(userId string) (IUserEntity, error) //从索引中更新一个User UpdateUser(user IUserEntity) error }
玩家索引
type IUserSubscriber ¶
type IUserSubscriber interface { IUserWhiteList IUserBlackList //处于激活 OnActive(targetId string) bool }
参与者
type IUserWhiteList ¶
type IUserWhiteList interface { //通信白名单,返回原始切片,如果要修改的,请先copy Whites() []string //增加白名单 AddWhite(targetId string) error //移除白名单 RemoveWhite(targetId string) error //处于 OnWhite(targetId string) bool }
黑名单
type IVariableSupport ¶
type IVariableSupport interface { eventx.IEventDispatcher SetVar(key string, value interface{}) SetVars(kv encodingx.IKeyValue) GetVar(key string) (interface{}, bool) Vars() encodingx.IKeyValue CheckVar(key string) bool RemoveVar(key string) }
变量列表
type IWorldEntity ¶
type IWorldEntity interface { IEntity IInitEntity IEntityContainer //IZoneGroup IVariableSupport }
世界实体
type IWorldIndex ¶
type IWorldIndex interface { IEntityIndex //检查World是否存在 CheckWorld(worldId string) bool //获取World GetWorld(worldId string) IWorldEntity //添加一个新World到索引中 AddWorld(world IWorldEntity) error //从索引中移除一个World RemoveWorld(worldId string) (IWorldEntity, error) //更新一个新World到索引中 UpdateWorld(zone IWorldEntity) error }
type IZoneEntity ¶
type IZoneEntity interface { IEntity IEntityChild IInitEntity IEntityContainer //IRoomGroup IVariableSupport }
区域实体
type IZoneGroup ¶
type IZoneIndex ¶
type IZoneIndex interface { IEntityIndex //检查Zone是否存在 CheckZone(zoneId string) bool //获取Zone GetZone(zoneId string) IZoneEntity //添加一个新Zone到索引中 AddZone(zone IZoneEntity) error //从索引中移除一个Zone RemoveZone(zoneId string) (IZoneEntity, error) //更新一个新Zone到索引中 UpdateZone(zone IZoneEntity) error }